From a2caed626955f6e4ab45b6ff86d51abaa04fb7ec Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Fri, 16 Feb 2018 08:13:05 -0500 Subject: [PATCH] improvements Signed-off-by: Kenneth Reitz --- cmd/version-scraper/main.go | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/cmd/version-scraper/main.go b/cmd/version-scraper/main.go index 5de7281..9c501fb 100644 --- a/cmd/version-scraper/main.go +++ b/cmd/version-scraper/main.go @@ -114,42 +114,40 @@ func main() { rollbar.Error(rollbar.ERR, err) } + // Iterate over the results from the target executable. for _, result := range results { key := fmt.Sprintf("%s:%s:%s", bp, exe, result) value := 1 - // Store the results in Redis. + // Store the target result in Redis. result, err := Redis.Connection.Do("SETNX", key, value) if err != nil { + // Report to Rollbar if there's an issue. rollbar.Error(rollbar.ERR, err) } - // The insert was successful (e.g. it didn't exist already) + // The insert was successful (e.g. it didn't exist already). if result.(int64) != int64(0) { - // TODO: Send a notification to the buildpack owner. - // Open an issue on GitHub (work in progress). + // Open an issue on GitHub. if !newTarget { + fmt.Println("Notifying", blue(bp.Owner), "about", red(key), ".") + success := openIssue(bp, key) if !success { - // If writing out the issue was unsuccessful, delete the key from Redis. + // If opening the issue was unsuccessful, delete the key from Redis, for a re-try. _, err := Redis.Connection.Do("DEL", key) if err != nil { + // Report the error to Rollbar. rollbar.Error(rollbar.ERR, err) } } } else { + // If this is a "new" target, skip GitHub notifications. fmt.Println("New target, skipping GitHub notifications.") } - } - - if err != nil { - rollbar.Error(rollbar.ERR, err) - log.Print(err) - } - } // Log results.