Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌱 clusterctl: do not fail when running clusterctl with a build without GitVersion information #11468

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions cmd/clusterctl/cmd/version_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,13 @@ type VersionState struct {
// version is the same or greater it returns nothing.
func (v *versionChecker) Check(ctx context.Context) (string, error) {
log := logf.Log
cliVer, err := semver.ParseTolerant(v.cliVersion().GitVersion)
if err != nil {
return "", errors.Wrap(err, "unable to semver parse clusterctl GitVersion")
var cliVer semver.Version
var err error
if v.cliVersion().GitVersion != "" {
cliVer, err = semver.ParseTolerant(v.cliVersion().GitVersion)
if err != nil {
return "", errors.Wrap(err, "unable to semver parse clusterctl GitVersion")
}
}

release, err := v.getLatestRelease(ctx)
Expand All @@ -122,8 +126,8 @@ func (v *versionChecker) Check(ctx context.Context) (string, error) {
return "", errors.Wrap(err, "unable to semver parse latest release version")
}

// if we are using a dirty dev build, just log it out
if strings.HasSuffix(cliVer.String(), "-dirty") {
// if we are using a dirty dev build or go build, just log it out
if v.cliVersion().GitVersion == "" || strings.HasSuffix(cliVer.String(), "-dirty") {
log.V(1).Info("⚠️ Using a development build of clusterctl.", "cliVersion", cliVer.String(), "latestGithubRelease", release.Version)
return "", nil
}
Expand Down