You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pc...@apache.org on 2024/04/24 07:55:50 UTC

(camel-k) 01/04: feat(trait): allow usage of semver for camel.runtime-version

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

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

commit 0f9ef1f5415c41ca821afae44a36b39306035d2c
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Fri Apr 5 11:22:46 2024 +0200

    feat(trait): allow usage of semver for camel.runtime-version
    
    Closes #5311
---
 pkg/trait/camel.go      |  2 +-
 pkg/trait/camel_test.go | 16 ++++++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/pkg/trait/camel.go b/pkg/trait/camel.go
index 3d2a991d8..d774cfca2 100644
--- a/pkg/trait/camel.go
+++ b/pkg/trait/camel.go
@@ -86,7 +86,7 @@ func (t *camelTrait) Apply(e *Environment) error {
 		}
 	}
 
-	e.RuntimeVersion = t.RuntimeVersion
+	e.RuntimeVersion = e.CamelCatalog.Runtime.Version
 
 	if e.Integration != nil {
 		e.Integration.Status.RuntimeVersion = e.CamelCatalog.Runtime.Version
diff --git a/pkg/trait/camel_test.go b/pkg/trait/camel_test.go
index a3fc3688d..5d5a13a4f 100644
--- a/pkg/trait/camel_test.go
+++ b/pkg/trait/camel_test.go
@@ -230,3 +230,19 @@ func TestCamelMatches(t *testing.T) {
 	t2.RuntimeVersion = "3.2.1"
 	assert.False(t, t1.Matches(&t2))
 }
+
+func TestCamelCatalogSemver(t *testing.T) {
+	trait, environment := createNominalCamelTest(true)
+	trait.RuntimeVersion = "2.x"
+	environment.CamelCatalog.CamelCatalogSpec.Runtime.Version = "2.16.0"
+
+	configured, condition, err := trait.Configure(environment)
+	require.NoError(t, err)
+	assert.Nil(t, condition)
+	assert.True(t, configured)
+
+	err = trait.Apply(environment)
+	require.NoError(t, err)
+	// 2.x will translate with 2.16.0 as it is already existing
+	assert.Equal(t, environment.CamelCatalog.CamelCatalogSpec.Runtime.Version, environment.RuntimeVersion)
+}