diff --git a/cmd/crawl.go b/cmd/crawl.go index 6d61c34..fa087c6 100644 --- a/cmd/crawl.go +++ b/cmd/crawl.go @@ -6,6 +6,7 @@ import ( "github.com/italia/publiccode-crawler/v4/crawler" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" + "github.com/spf13/viper" ) func init() { @@ -22,6 +23,10 @@ var crawlCmd = &cobra.Command{ otherwise the passed YAML files are used.`, Args: cobra.MinimumNArgs(0), Run: func(_ *cobra.Command, args []string) { + if token := viper.GetString("GITHUB_TOKEN"); token == "" { + log.Fatal("Please set GITHUB_TOKEN, it's needed to use the GitHub API'") + } + c := crawler.NewCrawler(dryRun) var publishers []common.Publisher diff --git a/main.go b/main.go index e438899..84c118f 100644 --- a/main.go +++ b/main.go @@ -23,6 +23,7 @@ func main() { viper.SetDefault("ACTIVITY_DAYS", 60) viper.SetDefault("API_BASEURL", "https://api.developers.italia.it/v1/") viper.SetDefault("MAIN_PUBLISHER_ID", "") + viper.SetDefault("GITHUB_TOKEN", "") if err := viper.ReadInConfig(); err != nil { var notFoundError viper.ConfigFileNotFoundError