Skip to content

Commit 3464653

Browse files
committed
define rateLimitError as local variable
Signed-off-by: sivchari <shibuuuu5@gmail.com>
1 parent e8baf0e commit 3464653

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

cmd/clusterctl/client/repository/repository_github.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ var (
6161
retryableOperationTimeout = 1 * time.Minute
6262
)
6363

64-
var rateLimitError *github.RateLimitError
65-
6664
// gitHubRepository provides support for providers hosted on GitHub.
6765
//
6866
// We support GitHub repositories that use the release feature to publish artifacts and versions.
@@ -468,6 +466,7 @@ func (g *gitHubRepository) downloadFilesFromRelease(ctx context.Context, release
468466
if downloadReleaseError != nil {
469467
retryError = g.handleGithubErr(downloadReleaseError, "failed to download file %q from %q release", *release.TagName, fileName)
470468
// Return immediately if we are rate limited.
469+
var rateLimitError *github.RateLimitError
471470
if errors.As(downloadReleaseError, &rateLimitError) {
472471
return false, retryError
473472
}
@@ -501,7 +500,7 @@ func (g *gitHubRepository) downloadFilesFromRelease(ctx context.Context, release
501500

502501
// handleGithubErr wraps error messages.
503502
func (g *gitHubRepository) handleGithubErr(err error, message string, args ...interface{}) error {
504-
if errors.As(err, &rateLimitError) {
503+
if _, ok := err.(*github.RateLimitError); ok {
505504
return errors.New("rate limit for github api has been reached. Please wait one hour or get a personal API token and assign it to the GITHUB_TOKEN environment variable")
506505
}
507506

0 commit comments

Comments
 (0)