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 2022/10/06 10:00:02 UTC
[camel-k] branch release-1.9.x updated: fix(#3671): Fix native mode for KameletBinding
This is an automated email from the ASF dual-hosted git repository.
pcongiusti pushed a commit to branch release-1.9.x
in repository https://gitbox.apache.org/repos/asf/camel-k.git
The following commit(s) were added to refs/heads/release-1.9.x by this push:
new c597e83b1 fix(#3671): Fix native mode for KameletBinding
c597e83b1 is described below
commit c597e83b1c72604109e8086caad917eca704db4d
Author: Christoph Deppisch <cd...@redhat.com>
AuthorDate: Tue Sep 27 19:38:42 2022 +0200
fix(#3671): Fix native mode for KameletBinding
Propagate annotation trait configuration from Integration to IntegrationKit. This makes sure that the kit matches the integration once the native build is done.
---
pkg/trait/quarkus.go | 11 +++++++++++
pkg/trait/quarkus_test.go | 21 +++++++++++++++++++++
2 files changed, 32 insertions(+)
diff --git a/pkg/trait/quarkus.go b/pkg/trait/quarkus.go
index f93de9cb0..828bd914b 100644
--- a/pkg/trait/quarkus.go
+++ b/pkg/trait/quarkus.go
@@ -21,6 +21,7 @@ import (
"encoding/json"
"fmt"
"sort"
+ "strings"
"github.com/rs/xid"
@@ -270,6 +271,16 @@ func (t *quarkusTrait) newIntegrationKit(e *Environment, packageType quarkusPack
if v, ok := integration.Annotations[v1.PlatformSelectorAnnotation]; ok {
kit.Annotations[v1.PlatformSelectorAnnotation] = v
}
+
+ if kit.GetAnnotations() == nil {
+ kit.SetAnnotations(make(map[string]string))
+ }
+ for k, v := range integration.Annotations {
+ if strings.HasPrefix(k, v1.TraitAnnotationPrefix) {
+ kit.GetAnnotations()[k] = v
+ }
+ }
+
operatorID := defaults.OperatorID()
if operatorID != "" {
kit.Annotations[v1.OperatorIDAnnotation] = operatorID
diff --git a/pkg/trait/quarkus_test.go b/pkg/trait/quarkus_test.go
index 1b54f3d93..fb4ae4cf2 100644
--- a/pkg/trait/quarkus_test.go
+++ b/pkg/trait/quarkus_test.go
@@ -69,6 +69,27 @@ func TestApplyQuarkusTraitDefaultKitLayout(t *testing.T) {
assert.Equal(t, environment.IntegrationKits[0].Labels[v1.IntegrationKitLayoutLabel], v1.IntegrationKitLayoutFastJar)
}
+func TestApplyQuarkusTraitAnnotationKitConfiguration(t *testing.T) {
+ quarkusTrait, environment := createNominalQuarkusTest()
+ environment.Integration.Status.Phase = v1.IntegrationPhaseBuildingKit
+
+ if environment.Integration.GetAnnotations() == nil {
+ environment.Integration.SetAnnotations(make(map[string]string))
+ }
+ environment.Integration.GetAnnotations()[v1.TraitAnnotationPrefix+"quarkus.foo"] = "camel-k"
+
+ configured, err := quarkusTrait.Configure(environment)
+ assert.True(t, configured)
+ assert.Nil(t, err)
+
+ err = quarkusTrait.Apply(environment)
+ assert.Nil(t, err)
+ assert.Len(t, environment.IntegrationKits, 1)
+ assert.Equal(t, v1.IntegrationKitLayoutFastJar, environment.IntegrationKits[0].Labels[v1.IntegrationKitLayoutLabel])
+ assert.Equal(t, "camel-k", environment.IntegrationKits[0].Annotations[v1.TraitAnnotationPrefix+"quarkus.foo"])
+
+}
+
func createNominalQuarkusTest() (*quarkusTrait, *Environment) {
trait, _ := newQuarkusTrait().(*quarkusTrait)
trait.Enabled = BoolP(true)