diff --git a/pkg/cmd/version.go b/pkg/cmd/version.go index 338da99be5..0dfabbc08a 100644 --- a/pkg/cmd/version.go +++ b/pkg/cmd/version.go @@ -183,6 +183,9 @@ func operatorVersion(ctx context.Context, c client.Client, namespace string) (st } func compatibleVersions(aVersion, bVersion string, cmd *cobra.Command) bool { + if aVersion == bVersion { + return true + } a, err := semver.NewVersion(aVersion) if err != nil { fmt.Fprintln(cmd.ErrOrStderr(), "Could not parse '"+aVersion+"' (error:", err.Error()+")") diff --git a/pkg/cmd/version_test.go b/pkg/cmd/version_test.go index 69951c442d..383fe9cf93 100644 --- a/pkg/cmd/version_test.go +++ b/pkg/cmd/version_test.go @@ -86,3 +86,9 @@ func TestCompatibleVersions(t *testing.T) { assert.Equal(t, false, compatibleVersions("1.3.0", "dsadsa", rootCmd)) assert.Equal(t, false, compatibleVersions("dsadsa", "1.3.4", rootCmd)) } + +func TestCompatibleVersionsNonSemver(t *testing.T) { + _, rootCmd, _ := initializeVersionCmdOptions(t) + assert.Equal(t, true, compatibleVersions("1.3.0.special-version", "1.3.0.special-version", rootCmd)) + assert.Equal(t, false, compatibleVersions("1.3.1.special-version", "1.3.0.special-version", rootCmd)) +}