diff --git a/cmd/clusterctl/cmd/version_checker.go b/cmd/clusterctl/cmd/version_checker.go index a48f4a131fd0..340c770d652f 100644 --- a/cmd/clusterctl/cmd/version_checker.go +++ b/cmd/clusterctl/cmd/version_checker.go @@ -55,14 +55,14 @@ type versionChecker struct { // newVersionChecker returns a versionChecker. Its behavior has been inspired // by https://github.com/cli/cli. func newVersionChecker(ctx context.Context, vc config.VariablesClient) (*versionChecker, error) { - var client *github.Client + var githubClient *github.Client token, err := vc.Get("GITHUB_TOKEN") if err == nil { ts := oauth2.StaticTokenSource( &oauth2.Token{AccessToken: token}, ) tc := oauth2.NewClient(ctx, ts) - client = github.NewClient(tc) + githubClient = github.NewClient(tc) } else { githubClient = github.NewClient(nil) } @@ -146,7 +146,7 @@ New clusterctl version available: v%s -> v%s return "", nil } -func (v *versionChecker) getLatestRelease(ctx context.Context) (*ReleaseInfo, error) { +func (v *versionChecker) getLatestRelease(_ context.Context) (*ReleaseInfo, error) { log := logf.Log // Try to get latest clusterctl version number from the local state file. @@ -161,7 +161,10 @@ func (v *versionChecker) getLatestRelease(ctx context.Context) (*ReleaseInfo, er // Try to get latest clusterctl version number from go modules. latest, err := v.goproxyGetLatest() - if err == nil && latest != nil { + if err != nil { + log.V(5).Info("error using Goproxy client to get latest versions for clusterctl, falling back to github client") + } + if latest != nil { vs = &VersionState{ LastCheck: time.Now(), LatestRelease: *latest, @@ -199,7 +202,7 @@ func (v *versionChecker) goproxyGetLatest() (*ReleaseInfo, error) { return nil, nil } - gomodulePath := path.Join("github.com", "kubernetes-sigs", "cluster-api") + gomodulePath := path.Join("sigs.k8s.io", "cluster-api") versions, err := v.goproxyClient.GetVersions(context.TODO(), gomodulePath) if err != nil { return nil, err