Skip to content

Commit

Permalink
fix(#3671): Fix native mode for KameletBinding
Browse files Browse the repository at this point in the history
Propagate annotation trait configuration from Integration to IntegrationKit. This makes sure that the kit matches the integration once the native build is done.
  • Loading branch information
christophd authored and squakez committed Oct 6, 2022
1 parent 8779a0a commit 9a0b28c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/trait/quarkus.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package trait
import (
"fmt"
"sort"
"strings"

"github.com/rs/xid"

Expand Down Expand Up @@ -197,6 +198,13 @@ func (t *quarkusTrait) newIntegrationKit(e *Environment, packageType traitv1.Qua
if v, ok := integration.Annotations[v1.PlatformSelectorAnnotation]; ok {
v1.SetAnnotation(&kit.ObjectMeta, v1.PlatformSelectorAnnotation, v)
}

for k, v := range integration.Annotations {
if strings.HasPrefix(k, v1.TraitAnnotationPrefix) {
v1.SetAnnotation(&kit.ObjectMeta, k, v)
}
}

operatorID := defaults.OperatorID()
if operatorID != "" {
kit.SetOperatorID(operatorID)
Expand Down
18 changes: 18 additions & 0 deletions pkg/trait/quarkus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,24 @@ 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

v1.SetAnnotation(&environment.Integration.ObjectMeta, 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 = pointer.Bool(true)
Expand Down

0 comments on commit 9a0b28c

Please sign in to comment.