Skip to content

Commit

Permalink
clusterctl: do not fail when running clusterctl with a build without …
Browse files Browse the repository at this point in the history
…GitVersion information
  • Loading branch information
chrischdi committed Nov 22, 2024
1 parent 48d23cd commit 04874b8
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 04874b8

Please sign in to comment.