Skip to content

Commit c800c18

Browse files
authored
Merge pull request #11468 from chrischdi/pr-clusterctl-go-build-not-fail
🌱 clusterctl: do not fail when running clusterctl with a build without GitVersion information
2 parents ff3afcb + 04874b8 commit c800c18

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

cmd/clusterctl/cmd/version_checker.go

+9-5
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,13 @@ type VersionState struct {
105105
// version is the same or greater it returns nothing.
106106
func (v *versionChecker) Check(ctx context.Context) (string, error) {
107107
log := logf.Log
108-
cliVer, err := semver.ParseTolerant(v.cliVersion().GitVersion)
109-
if err != nil {
110-
return "", errors.Wrap(err, "unable to semver parse clusterctl GitVersion")
108+
var cliVer semver.Version
109+
var err error
110+
if v.cliVersion().GitVersion != "" {
111+
cliVer, err = semver.ParseTolerant(v.cliVersion().GitVersion)
112+
if err != nil {
113+
return "", errors.Wrap(err, "unable to semver parse clusterctl GitVersion")
114+
}
111115
}
112116

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

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

0 commit comments

Comments
 (0)