chore(trait): Migrate the Owner trait to structured serialization
diff --git a/pkg/trait/owner.go b/pkg/trait/owner.go
index 84236b8..c821e02 100644
--- a/pkg/trait/owner.go
+++ b/pkg/trait/owner.go
@@ -18,13 +18,11 @@
package trait
import (
- "strings"
-
- v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
-
appsv1 "k8s.io/api/apps/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
serving "knative.dev/serving/pkg/apis/serving/v1"
+
+ v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
)
// The Owner trait ensures that all created resources belong to the integration being created
@@ -33,10 +31,10 @@
// +camel-k:trait=owner
type ownerTrait struct {
BaseTrait `property:",squash"`
- // The annotations to be transferred (A comma-separated list of label keys)
- TargetAnnotations string `property:"target-annotations"`
- // The labels to be transferred (A comma-separated list of label keys)
- TargetLabels string `property:"target-labels"`
+ // The set of annotations to be transferred
+ TargetAnnotations []string `property:"target-annotations" json:"targetAnnotations,omitempty"`
+ // The set of labels to be transferred
+ TargetLabels []string `property:"target-labels" json:"targetLabels,omitempty"`
}
func newOwnerTrait() Trait {
@@ -63,7 +61,7 @@
targetLabels := make(map[string]string)
if e.Integration.Labels != nil {
- for _, k := range strings.Split(t.TargetLabels, ",") {
+ for _, k := range t.TargetLabels {
if v, ok := e.Integration.Labels[k]; ok {
targetLabels[k] = v
}
@@ -72,7 +70,7 @@
targetAnnotations := make(map[string]string)
if e.Integration.Annotations != nil {
- for _, k := range strings.Split(t.TargetAnnotations, ",") {
+ for _, k := range t.TargetAnnotations {
if v, ok := e.Integration.Annotations[k]; ok {
targetAnnotations[k] = v
}
diff --git a/pkg/trait/owner_test.go b/pkg/trait/owner_test.go
index ef5a99d..c5f5905 100644
--- a/pkg/trait/owner_test.go
+++ b/pkg/trait/owner_test.go
@@ -44,8 +44,8 @@
env := createTestEnv(t, v1.IntegrationPlatformClusterOpenShift, "camel:core")
env.Integration.Spec.Traits = map[string]v1.TraitSpec{
"owner": test.TraitSpecFromMap(t, map[string]interface{}{
- "target-labels": "com.mycompany/mylabel1",
- "target-annotations": "com.mycompany/myannotation2",
+ "targetLabels": []string{"com.mycompany/mylabel1"},
+ "targetAnnotations": []string{"com.mycompany/myannotation2"},
}),
}