Skip to content

Commit

Permalink
fix rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriziopandini committed Aug 21, 2023
1 parent 4781590 commit 357078e
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions cmd/clusterctl/cmd/version_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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.
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 357078e

Please sign in to comment.