This is an automated email from the ASF dual-hosted git repository.

pcongiusti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git


The following commit(s) were added to refs/heads/main by this push:
     new 16d276983 fix(cmd): compatibility check when not a semver
16d276983 is described below

commit 16d2769832186cccb883802d8bc3395c71ec6f96
Author: Pasquale Congiusti <pasquale.congiu...@gmail.com>
AuthorDate: Thu Mar 16 15:57:47 2023 +0100

    fix(cmd): compatibility check when not a semver
---
 pkg/cmd/version.go      | 3 +++
 pkg/cmd/version_test.go | 6 ++++++
 2 files changed, 9 insertions(+)

diff --git a/pkg/cmd/version.go b/pkg/cmd/version.go
index 338da99be..0dfabbc08 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 69951c442..383fe9cf9 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))
+}

Reply via email to