From 0c47c3d54fa2b2852e2ad1246643053c809b1cc7 Mon Sep 17 00:00:00 2001 From: Pasquale Congiusti Date: Fri, 5 Apr 2024 11:22:46 +0200 Subject: [PATCH] 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 3d2a991d8d..d774cfca2b 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 a3fc3688d6..5d5a13a4f5 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) +}