chore(trait): Migrate the Knative Service trait to structured serialization
diff --git a/pkg/trait/knative_service.go b/pkg/trait/knative_service.go
index ed84f5d..2a5b15c 100644
--- a/pkg/trait/knative_service.go
+++ b/pkg/trait/knative_service.go
@@ -51,30 +51,30 @@
// Configures the Knative autoscaling class property (e.g. to set `hpa.autoscaling.knative.dev` or `kpa.autoscaling.knative.dev` autoscaling).
//
// Refer to the Knative documentation for more information.
- Class string `property:"autoscaling-class"`
+ Class string `property:"autoscaling-class" json:"class,omitempty"`
// Configures the Knative autoscaling metric property (e.g. to set `concurrency` based or `cpu` based autoscaling).
//
// Refer to the Knative documentation for more information.
- Metric string `property:"autoscaling-metric"`
+ Metric string `property:"autoscaling-metric" json:"autoscalingMetric,omitempty"`
// Sets the allowed concurrency level or CPU percentage (depending on the autoscaling metric) for each Pod.
//
// Refer to the Knative documentation for more information.
- Target *int `property:"autoscaling-target"`
+ Target *int `property:"autoscaling-target" json:"autoscalingTarget,omitempty"`
// The minimum number of Pods that should be running at any time for the integration. It's **zero** by default, meaning that
// the integration is scaled down to zero when not used for a configured amount of time.
//
// Refer to the Knative documentation for more information.
- MinScale *int `property:"min-scale"`
+ MinScale *int `property:"min-scale" json:"minScale,omitempty"`
// An upper bound for the number of Pods that can be running in parallel for the integration.
// Knative has its own cap value that depends on the installation.
//
// Refer to the Knative documentation for more information.
- MaxScale *int `property:"max-scale"`
+ MaxScale *int `property:"max-scale" json:"maxScale,omitempty"`
// Automatically deploy the integration as Knative service when all conditions hold:
//
// * Integration is using the Knative profile
// * All routes are either starting from a HTTP based consumer or a passive consumer (e.g. `direct` is a passive consumer)
- Auto *bool `property:"auto"`
+ Auto *bool `property:"auto" json:"auto,omitempty"`
}
var _ ControllerStrategySelector = &knativeServiceTrait{}
diff --git a/pkg/trait/trait_test.go b/pkg/trait/trait_test.go
index 16e099a..d50bd91 100644
--- a/pkg/trait/trait_test.go
+++ b/pkg/trait/trait_test.go
@@ -164,22 +164,22 @@
env.Platform.Spec.Traits = make(map[string]v1.TraitSpec)
env.Platform.Spec.Traits["knative-service"] = test.TraitSpecFromMap(t, map[string]interface{}{
- "enabled": false,
- "min-scale": 1,
- "max-scale": 10,
- "autoscaling-target": 15,
+ "enabled": false,
+ "minScale": 1,
+ "maxScale": 10,
+ "autoscalingTarget": 15,
})
env.Platform.ResyncStatusFullConfig()
env.IntegrationKit.Spec.Traits = make(map[string]v1.TraitSpec)
env.IntegrationKit.Spec.Traits["knative-service"] = test.TraitSpecFromMap(t, map[string]interface{}{
- "enabled": true,
- "min-scale": 5,
+ "enabled": true,
+ "minScale": 5,
})
env.Integration.Spec.Traits = make(map[string]v1.TraitSpec)
env.Integration.Spec.Traits["knative-service"] = test.TraitSpecFromMap(t, map[string]interface{}{
- "max-scale": 20,
+ "maxScale": 20,
})
c := NewTraitTestCatalog()