Skip to content

Commit

Permalink
Merge pull request #11468 from chrischdi/pr-clusterctl-go-build-not-fail
Browse files Browse the repository at this point in the history
🌱 clusterctl: do not fail when running clusterctl with a build without GitVersion information
  • Loading branch information
k8s-ci-robot authored Nov 22, 2024
2 parents ff3afcb + 04874b8 commit c800c18
Showing 1 changed file with 9 additions and 5 deletions.
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

0 comments on commit c800c18

Please sign in to comment.