Skip to content

Commit

Permalink
Gracefully handle github api overload (#128)
Browse files Browse the repository at this point in the history
* Gracefully handle github api overload

* revert unrelated change

---------

Co-authored-by: Avdhoot Dendge <avdhooth@gmail.com>
Co-authored-by: Kunal Gohire <37223681+kunalp-gohire@users.noreply.github.com>
  • Loading branch information
3 people committed Jul 13, 2023
1 parent 2306857 commit a057bc5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ func isLatestVersion() bool {
body, _ := io.ReadAll(resp.Body)
resp.Body.Close()

if resp.StatusCode == 403 {
pterm.Warning.Printf("Unable to check latest version (version check API unavailable). Continuing.\n")
return true
}

var data versionInfo
var retry bool
err = json.Unmarshal(body, &data)
Expand All @@ -131,7 +136,7 @@ func isLatestVersion() bool {
}

if version != data.TagName {
pterm.Warning.Printf("You are running older version of ridectl %s\n", version)
pterm.Warning.Printf("You are running an older version of ridectl: %s. Latest: %s\n.", version, data.TagName)
return false
}

Expand Down

0 comments on commit a057bc5

Please sign in to comment.