Skip to content

Commit

Permalink
feat(crawl): error out if GITHUB_TOKEN not set
Browse files Browse the repository at this point in the history
  • Loading branch information
bfabio committed May 25, 2024
1 parent c8a6a04 commit e93e0cc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cmd/crawl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e93e0cc

Please sign in to comment.