You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ts...@apache.org on 2022/07/08 06:11:56 UTC
[camel-k] 01/14: feat(api): strongly-typed traits configuration API
This is an automated email from the ASF dual-hosted git repository.
tsato pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit a92aaa405cf8a38a722c476251d04b99221f9682
Author: Tadayoshi Sato <sa...@gmail.com>
AuthorDate: Thu Jun 30 14:17:40 2022 +0900
feat(api): strongly-typed traits configuration API
---
e2e/global/common/traits/toleration_test.go | 4 +-
e2e/support/test_support.go | 2 +-
pkg/apis/camel/v1/common_types.go | 80 +-
pkg/apis/camel/v1/integration_types.go | 2 +-
pkg/apis/camel/v1/integrationkit_types.go | 12 +-
pkg/apis/camel/v1/integrationplatform_types.go | 2 +-
pkg/apis/camel/v1/trait_affinity.go | 40 +
.../test/trait.go => apis/camel/v1/trait_base.go} | 41 +-
.../trait.go => apis/camel/v1/trait_builder.go} | 49 +-
.../test/trait.go => apis/camel/v1/trait_camel.go} | 48 +-
pkg/apis/camel/v1/trait_container.go | 102 ++
pkg/apis/camel/v1/trait_cron.go | 71 ++
.../camel/v1/trait_dependencies.go} | 45 +-
pkg/apis/camel/v1/trait_deployer.go | 31 +
.../trait.go => apis/camel/v1/trait_deployment.go} | 48 +-
pkg/apis/camel/v1/trait_environment.go | 34 +
.../camel/v1/trait_error_handler.go} | 46 +-
.../test/trait.go => apis/camel/v1/trait_gc.go} | 50 +-
pkg/apis/camel/v1/trait_health.go | 57 +
.../trait.go => apis/camel/v1/trait_ingress.go} | 51 +-
.../test/trait.go => apis/camel/v1/trait_istio.go} | 49 +-
pkg/apis/camel/v1/trait_jolokia.go | 58 +
pkg/apis/camel/v1/trait_jvm.go | 37 +
.../trait.go => apis/camel/v1/trait_kamelets.go} | 48 +-
pkg/apis/camel/v1/trait_knative.go | 60 +
pkg/apis/camel/v1/trait_knative_service.go | 60 +
pkg/apis/camel/v1/trait_logging.go | 36 +
pkg/apis/camel/v1/trait_mount.go | 38 +
.../trait.go => apis/camel/v1/trait_openapi.go} | 46 +-
.../test/trait.go => apis/camel/v1/trait_owner.go} | 49 +-
pkg/apis/camel/v1/trait_pdb.go | 33 +
pkg/apis/camel/v1/trait_platform.go | 35 +
.../test/trait.go => apis/camel/v1/trait_pod.go} | 49 +-
pkg/apis/camel/v1/trait_prometheus.go | 38 +
pkg/apis/camel/v1/trait_pull_secret.go | 40 +
pkg/apis/camel/v1/trait_quarkus.go | 47 +
.../trait.go => apis/camel/v1/trait_registry.go} | 45 +-
pkg/apis/camel/v1/trait_route.go | 80 ++
.../trait.go => apis/camel/v1/trait_service.go} | 51 +-
.../camel/v1/trait_service_binding.go} | 48 +-
.../camel/v1/trait_toleration.go} | 50 +-
pkg/apis/camel/v1/zz_generated.deepcopy.go | 1161 +++++++++++++++++++-
pkg/cmd/bind.go | 5 +-
pkg/cmd/bind_test.go | 10 +-
pkg/cmd/debug.go | 30 +-
pkg/cmd/describe.go | 27 +-
pkg/cmd/kit_create.go | 12 +-
pkg/cmd/run.go | 4 +-
pkg/cmd/run_test.go | 69 +-
pkg/cmd/trait_support.go | 49 +-
pkg/controller/integration/kits.go | 175 +--
.../{build_kit_test.go => kits_test.go} | 72 +-
pkg/controller/kameletbinding/integration.go | 7 +-
pkg/trait/affinity.go | 29 +-
pkg/trait/builder.go | 11 +-
pkg/trait/camel.go | 10 +-
pkg/trait/camel_test.go | 2 +-
pkg/trait/container.go | 99 +-
pkg/trait/container_probes_test.go | 58 +-
pkg/trait/container_test.go | 40 +-
pkg/trait/cron.go | 52 +-
pkg/trait/cron_test.go | 28 +-
pkg/trait/dependencies.go | 7 +-
pkg/trait/deployer.go | 13 +-
pkg/trait/deployment.go | 10 +-
pkg/trait/deployment_test.go | 2 +-
pkg/trait/environment.go | 22 +-
pkg/trait/environment_test.go | 26 +-
pkg/trait/error_handler.go | 8 +-
pkg/trait/gc.go | 44 +-
pkg/trait/gc_test.go | 20 +-
pkg/trait/health.go | 46 +-
pkg/trait/ingress.go | 17 +-
pkg/trait/init.go | 3 +-
pkg/trait/istio.go | 16 +-
pkg/trait/istio_test.go | 24 +-
pkg/trait/jolokia.go | 43 +-
pkg/trait/jvm.go | 26 +-
pkg/trait/kamelets.go | 10 +-
pkg/trait/knative.go | 41 +-
pkg/trait/knative_service.go | 41 +-
pkg/trait/knative_service_test.go | 47 +-
pkg/trait/knative_test.go | 45 +-
pkg/trait/logging.go | 22 +-
pkg/trait/logging_test.go | 18 +-
pkg/trait/mount.go | 19 +-
pkg/trait/mount_test.go | 14 +-
pkg/trait/openapi.go | 8 +-
pkg/trait/owner.go | 11 +-
pkg/trait/owner_test.go | 11 +-
pkg/trait/pdb.go | 14 +-
pkg/trait/platform.go | 16 +-
pkg/trait/pod.go | 11 +-
pkg/trait/prometheus.go | 25 +-
pkg/trait/pull_secret.go | 22 +-
pkg/trait/quarkus.go | 91 +-
pkg/trait/registry.go | 7 +-
pkg/trait/route.go | 64 +-
pkg/trait/route_test.go | 145 +--
pkg/trait/service.go | 13 +-
pkg/trait/service_binding.go | 9 +-
pkg/trait/service_test.go | 80 +-
pkg/trait/toleration.go | 20 +-
pkg/trait/trait_configure.go | 35 +-
pkg/trait/trait_configure_test.go | 45 +-
pkg/trait/trait_register.go | 2 +-
pkg/trait/trait_test.go | 65 +-
pkg/trait/trait_types.go | 4 +-
pkg/trait/util.go | 36 +
pkg/util/bindings/api.go | 2 +-
pkg/util/bindings/bindings_test.go | 44 +-
pkg/util/bindings/knative_uri.go | 19 +-
pkg/util/digest/digest.go | 39 +-
113 files changed, 3021 insertions(+), 2163 deletions(-)
diff --git a/e2e/global/common/traits/toleration_test.go b/e2e/global/common/traits/toleration_test.go
index 8c71c52c7..f834deac6 100644
--- a/e2e/global/common/traits/toleration_test.go
+++ b/e2e/global/common/traits/toleration_test.go
@@ -69,7 +69,7 @@ func TestTolerationTrait(t *testing.T) {
Key: "camel.apache.org/master",
Operator: corev1.TolerationOpExists,
Effect: corev1.TaintEffectNoExecute,
- TolerationSeconds: pointer.Int64Ptr(300),
+ TolerationSeconds: pointer.Int64(300),
}))
})
@@ -91,7 +91,7 @@ func TestTolerationTrait(t *testing.T) {
Key: "camel.apache.org/master",
Operator: corev1.TolerationOpEqual,
Value: "test", Effect: corev1.TaintEffectNoExecute,
- TolerationSeconds: pointer.Int64Ptr(300),
+ TolerationSeconds: pointer.Int64(300),
}))
})
diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go
index b98be7ef7..cec5e580b 100644
--- a/e2e/support/test_support.go
+++ b/e2e/support/test_support.go
@@ -347,7 +347,7 @@ func IntegrationLogs(ns, name string) func() string {
}
options := corev1.PodLogOptions{
- TailLines: pointer.Int64Ptr(100),
+ TailLines: pointer.Int64(100),
}
if len(pod.Spec.Containers) > 1 {
diff --git a/pkg/apis/camel/v1/common_types.go b/pkg/apis/camel/v1/common_types.go
index 1d9be8ceb..34553daa7 100644
--- a/pkg/apis/camel/v1/common_types.go
+++ b/pkg/apis/camel/v1/common_types.go
@@ -101,16 +101,76 @@ type FailureRecovery struct {
AttemptTime metav1.Time `json:"attemptTime"`
}
-// A TraitSpec contains the configuration of a trait
-type TraitSpec struct {
- // TraitConfiguration parameters configuration
- Configuration TraitConfiguration `json:"configuration"`
-}
-
-// TraitConfiguration represents the expected configuration for a given trait parameter
-type TraitConfiguration struct {
- // generic raw message, tipically a map containing the keys (trait parameters) and the values (either single text or array)
- RawMessage `json:",inline"`
+// Traits represents the collection of trait configurations
+type Traits struct {
+ // The configuration of Affinity trait
+ Affinity *AffinityTrait `property:"affinity" json:"affinity,omitempty"`
+ // The configuration of Builder trait
+ Builder *BuilderTrait `property:"builder" json:"builder,omitempty"`
+ // The configuration of Camel trait
+ Camel *CamelTrait `property:"camel" json:"camel,omitempty"`
+ // The configuration of Container trait
+ Container *ContainerTrait `property:"container" json:"container,omitempty"`
+ // The configuration of Cron trait
+ Cron *CronTrait `property:"cron" json:"cron,omitempty"`
+ // DependenciesTrait is the configuration of Dependencies trait
+ Dependencies *DependenciesTrait `property:"dependencies" json:"dependencies,omitempty"`
+ // The configuration of Deployer trait
+ Deployer *DeployerTrait `property:"deployer" json:"deployer,omitempty"`
+ // The configuration of Deployment trait
+ Deployment *DeploymentTrait `property:"deployment" json:"deployment,omitempty"`
+ // The configuration of Environment trait
+ Environment *EnvironmentTrait `property:"environment" json:"environment,omitempty"`
+ // The configuration of Error Handler trait
+ ErrorHandler *ErrorHandlerTrait `property:"error-handler" json:"error-handler,omitempty"`
+ // The configuration of GC trait
+ GC *GCTrait `property:"gc" json:"gc,omitempty"`
+ // The configuration of Health trait
+ Health *HealthTrait `property:"health" json:"health,omitempty"`
+ // The configuration of Ingress trait
+ Ingress *IngressTrait `property:"ingress" json:"ingress,omitempty"`
+ // The configuration of Istio trait
+ Istio *IstioTrait `property:"istio" json:"istio,omitempty"`
+ // The configuration of Jolokia trait
+ Jolokia *JolokiaTrait `property:"jolokia" json:"jolokia,omitempty"`
+ // The configuration of JVM trait
+ JVM *JVMTrait `property:"jvm" json:"jvm,omitempty"`
+ // The configuration of Kamelets trait
+ Kamelets *KameletsTrait `property:"kamelets" json:"kamelets,omitempty"`
+ // The configuration of Knative trait
+ Knative *KnativeTrait `property:"knative" json:"knative,omitempty"`
+ // The configuration of Knative Service trait
+ KnativeService *KnativeServiceTrait `property:"knative-service" json:"knative-service,omitempty"`
+ // The configuration of Logging trait
+ Logging *LoggingTrait `property:"logging" json:"logging,omitempty"`
+ // The configuration of Mount trait
+ Mount *MountTrait `property:"mount" json:"mount,omitempty"`
+ // The configuration of OpenAPI trait
+ OpenAPI *OpenAPITrait `property:"openapi" json:"openapi,omitempty"`
+ // The configuration of Owner trait
+ Owner *OwnerTrait `property:"owner" json:"owner,omitempty"`
+ // The configuration of PDB trait
+ PDB *PDBTrait `property:"pdb" json:"pdb,omitempty"`
+ // The configuration of Platform trait
+ Platform *PlatformTrait `property:"platform" json:"platform,omitempty"`
+ // The configuration of Pod trait
+ Pod *PodTrait `property:"pod" json:"pod,omitempty"`
+ // The configuration of Prometheus trait
+ Prometheus *PrometheusTrait `property:"prometheus" json:"prometheus,omitempty"`
+ // The configuration of Pull Secret trait
+ PullSecret *PullSecretTrait `property:"pull-secret" json:"pull-secret,omitempty"`
+ // The configuration of Quarkus trait
+ Quarkus *QuarkusTrait `property:"quarkus" json:"quarkus,omitempty"`
+ // The configuration of Registry trait
+ Registry *RegistryTrait `property:"registry" json:"registry,omitempty"`
+ // The configuration of Route trait
+ Route *RouteTrait `property:"route" json:"route,omitempty"`
+ // The configuration of Service trait
+ Service *ServiceTrait `property:"service" json:"service,omitempty"`
+ // The configuration of Service Binding trait
+ ServiceBinding *ServiceBindingTrait `property:"service-binding" json:"service-binding,omitempty"`
+ // The configuration of Toleration trait
+ Toleration *TolerationTrait `property:"toleration" json:"toleration,omitempty"`
}
// +kubebuilder:validation:Type=object
diff --git a/pkg/apis/camel/v1/integration_types.go b/pkg/apis/camel/v1/integration_types.go
index 9cafb294f..ad99904af 100644
--- a/pkg/apis/camel/v1/integration_types.go
+++ b/pkg/apis/camel/v1/integration_types.go
@@ -68,7 +68,7 @@ type IntegrationSpec struct {
// the profile needed to run this Integration
Profile TraitProfile `json:"profile,omitempty"`
// the traits needed to run this Integration
- Traits map[string]TraitSpec `json:"traits,omitempty"`
+ Traits Traits `json:"traits,omitempty"`
// Pod template customization
PodTemplate *PodSpecTemplate `json:"template,omitempty"`
// Deprecated:
diff --git a/pkg/apis/camel/v1/integrationkit_types.go b/pkg/apis/camel/v1/integrationkit_types.go
index 0c8a9f5e9..b3865ff57 100644
--- a/pkg/apis/camel/v1/integrationkit_types.go
+++ b/pkg/apis/camel/v1/integrationkit_types.go
@@ -48,16 +48,16 @@ type IntegrationKit struct {
Status IntegrationKitStatus `json:"status,omitempty"`
}
-// IntegrationKitSpec defines a container image and additional configurations required to kick off an `Integration` which certain features
+// IntegrationKitSpec defines a container image and additional configurations required to kick off an `Integration` with certain features
type IntegrationKitSpec struct {
- // the container image as identify in the container registry
+ // the container image as identified in the container registry
Image string `json:"image,omitempty"`
// a list of Camel dependecies used by this kit
Dependencies []string `json:"dependencies,omitempty"`
// the profile which is expected by this kit
Profile TraitProfile `json:"profile,omitempty"`
// traits that the kit will execute
- Traits map[string]TraitSpec `json:"traits,omitempty"`
+ Traits IntegrationKitTraits `json:"traits,omitempty"`
// configuration used by the kit
// TODO: we should deprecate in future releases in favour of mount, openapi or camel traits
Configuration []ConfigurationSpec `json:"configuration,omitempty"`
@@ -65,6 +65,12 @@ type IntegrationKitSpec struct {
Repositories []string `json:"repositories,omitempty"`
}
+// IntegrationKitTraits defines traits assigned to an `IntegrationKit`
+type IntegrationKitTraits struct {
+ Builder *BuilderTrait `property:"builder" json:"builder,omitempty"`
+ Quarkus *QuarkusTrait `property:"quarkus" json:"quarkus,omitempty"`
+}
+
// IntegrationKitStatus defines the observed state of IntegrationKit
type IntegrationKitStatus struct {
// ObservedGeneration is the most recent generation observed for this IntegrationKit.
diff --git a/pkg/apis/camel/v1/integrationplatform_types.go b/pkg/apis/camel/v1/integrationplatform_types.go
index 8a71a21dd..b2265c0ce 100644
--- a/pkg/apis/camel/v1/integrationplatform_types.go
+++ b/pkg/apis/camel/v1/integrationplatform_types.go
@@ -37,7 +37,7 @@ type IntegrationPlatformSpec struct {
// Deprecated: not used
Resources IntegrationPlatformResourcesSpec `json:"resources,omitempty"`
// list of traits to be executed for all the Integration/IntegrationKits built from this IntegrationPlatform
- Traits map[string]TraitSpec `json:"traits,omitempty"`
+ Traits Traits `json:"traits,omitempty"`
// list of configuration properties to be attached to all the Integration/IntegrationKits built from this IntegrationPlatform
Configuration []ConfigurationSpec `json:"configuration,omitempty"`
// configuration to be executed to all Kamelets controlled by this IntegrationPlatform
diff --git a/pkg/apis/camel/v1/trait_affinity.go b/pkg/apis/camel/v1/trait_affinity.go
new file mode 100644
index 000000000..c710c86cf
--- /dev/null
+++ b/pkg/apis/camel/v1/trait_affinity.go
@@ -0,0 +1,40 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package v1
+
+// Allows constraining which nodes the integration pod(s) are eligible to be scheduled on, based on labels on the node,
+// or with inter-pod affinity and anti-affinity, based on labels on pods that are already running on the nodes.
+//
+// It's disabled by default.
+//
+// +camel-k:trait=affinity.
+type AffinityTrait struct {
+ Trait `property:",squash" json:",inline"`
+ // Always co-locates multiple replicas of the integration in the same node (default *false*).
+ PodAffinity *bool `property:"pod-affinity" json:"podAffinity,omitempty"`
+ // Never co-locates multiple replicas of the integration in the same node (default *false*).
+ PodAntiAffinity *bool `property:"pod-anti-affinity" json:"podAntiAffinity,omitempty"`
+ // Defines a set of nodes the integration pod(s) are eligible to be scheduled on, based on labels on the node.
+ NodeAffinityLabels []string `property:"node-affinity-labels" json:"nodeAffinityLabels,omitempty"`
+ // Defines a set of pods (namely those matching the label selector, relative to the given namespace) that the
+ // integration pod(s) should be co-located with.
+ PodAffinityLabels []string `property:"pod-affinity-labels" json:"podAffinityLabels,omitempty"`
+ // Defines a set of pods (namely those matching the label selector, relative to the given namespace) that the
+ // integration pod(s) should not be co-located with.
+ PodAntiAffinityLabels []string `property:"pod-anti-affinity-labels" json:"podAntiAffinityLabels,omitempty"`
+}
diff --git a/pkg/util/test/trait.go b/pkg/apis/camel/v1/trait_base.go
similarity index 53%
copy from pkg/util/test/trait.go
copy to pkg/apis/camel/v1/trait_base.go
index 653194972..8cb984830 100644
--- a/pkg/util/test/trait.go
+++ b/pkg/apis/camel/v1/trait_base.go
@@ -15,41 +15,10 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-package test
+package v1
-import (
- "encoding/json"
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
-)
-
-func TraitSpecFromMap(t *testing.T, spec map[string]interface{}) v1.TraitSpec {
- t.Helper()
-
- var trait v1.TraitSpec
-
- data, err := json.Marshal(spec)
- assert.Nil(t, err)
-
- err = json.Unmarshal(data, &trait.Configuration)
- assert.Nil(t, err)
-
- return trait
-}
-
-func TraitSpecToMap(t *testing.T, spec v1.TraitSpec) map[string]string {
- t.Helper()
-
- trait := make(map[string]string)
-
- data, err := json.Marshal(spec.Configuration)
- assert.Nil(t, err)
-
- err = json.Unmarshal(data, &trait)
- assert.Nil(t, err)
-
- return trait
+// Base type for all traits.
+type Trait struct {
+ // Can be used to enable or disable a trait. All traits share this common property.
+ Enabled *bool `property:"enabled" json:"enabled,omitempty"`
}
diff --git a/pkg/util/test/trait.go b/pkg/apis/camel/v1/trait_builder.go
similarity index 53%
copy from pkg/util/test/trait.go
copy to pkg/apis/camel/v1/trait_builder.go
index 653194972..c619284b2 100644
--- a/pkg/util/test/trait.go
+++ b/pkg/apis/camel/v1/trait_builder.go
@@ -15,41 +15,16 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-package test
-
-import (
- "encoding/json"
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
-)
-
-func TraitSpecFromMap(t *testing.T, spec map[string]interface{}) v1.TraitSpec {
- t.Helper()
-
- var trait v1.TraitSpec
-
- data, err := json.Marshal(spec)
- assert.Nil(t, err)
-
- err = json.Unmarshal(data, &trait.Configuration)
- assert.Nil(t, err)
-
- return trait
-}
-
-func TraitSpecToMap(t *testing.T, spec v1.TraitSpec) map[string]string {
- t.Helper()
-
- trait := make(map[string]string)
-
- data, err := json.Marshal(spec.Configuration)
- assert.Nil(t, err)
-
- err = json.Unmarshal(data, &trait)
- assert.Nil(t, err)
-
- return trait
+package v1
+
+// The builder trait is internally used to determine the best strategy to
+// build and configure IntegrationKits.
+//
+// +camel-k:trait=builder.
+type BuilderTrait struct {
+ Trait `property:",squash" json:",inline"`
+ // Enable verbose logging on build components that support it (e.g. Kaniko build pod).
+ Verbose *bool `property:"verbose" json:"verbose,omitempty"`
+ // A list of properties to be provided to the build task
+ Properties []string `property:"properties" json:"properties,omitempty"`
}
diff --git a/pkg/util/test/trait.go b/pkg/apis/camel/v1/trait_camel.go
similarity index 53%
copy from pkg/util/test/trait.go
copy to pkg/apis/camel/v1/trait_camel.go
index 653194972..55a63f665 100644
--- a/pkg/util/test/trait.go
+++ b/pkg/apis/camel/v1/trait_camel.go
@@ -15,41 +15,15 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-package test
-
-import (
- "encoding/json"
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
-)
-
-func TraitSpecFromMap(t *testing.T, spec map[string]interface{}) v1.TraitSpec {
- t.Helper()
-
- var trait v1.TraitSpec
-
- data, err := json.Marshal(spec)
- assert.Nil(t, err)
-
- err = json.Unmarshal(data, &trait.Configuration)
- assert.Nil(t, err)
-
- return trait
-}
-
-func TraitSpecToMap(t *testing.T, spec v1.TraitSpec) map[string]string {
- t.Helper()
-
- trait := make(map[string]string)
-
- data, err := json.Marshal(spec.Configuration)
- assert.Nil(t, err)
-
- err = json.Unmarshal(data, &trait)
- assert.Nil(t, err)
-
- return trait
+package v1
+
+// The Camel trait can be used to configure versions of Apache Camel K runtime and related libraries, it cannot be disabled.
+//
+// +camel-k:trait=camel.
+type CamelTrait struct {
+ Trait `property:",squash" json:",inline"`
+ // The camel-k-runtime version to use for the integration. It overrides the default version set in the Integration Platform.
+ RuntimeVersion string `property:"runtime-version" json:"runtimeVersion,omitempty"`
+ // A list of properties to be provided to the Integration runtime
+ Properties []string `property:"properties" json:"properties,omitempty"`
}
diff --git a/pkg/apis/camel/v1/trait_container.go b/pkg/apis/camel/v1/trait_container.go
new file mode 100644
index 000000000..c88b2be34
--- /dev/null
+++ b/pkg/apis/camel/v1/trait_container.go
@@ -0,0 +1,102 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package v1
+
+import corev1 "k8s.io/api/core/v1"
+
+// The Container trait can be used to configure properties of the container where the integration will run.
+//
+// It also provides configuration for Services associated to the container.
+//
+// +camel-k:trait=container
+// nolint: tagliatelle
+type ContainerTrait struct {
+ Trait `property:",squash" json:",inline"`
+
+ Auto *bool `property:"auto" json:"auto,omitempty"`
+
+ // The minimum amount of CPU required.
+ RequestCPU string `property:"request-cpu" json:"requestCPU,omitempty"`
+ // The minimum amount of memory required.
+ RequestMemory string `property:"request-memory" json:"requestMemory,omitempty"`
+ // The maximum amount of CPU required.
+ LimitCPU string `property:"limit-cpu" json:"limitCPU,omitempty"`
+ // The maximum amount of memory required.
+ LimitMemory string `property:"limit-memory" json:"limitMemory,omitempty"`
+
+ // Can be used to enable/disable exposure via kubernetes Service.
+ Expose *bool `property:"expose" json:"expose,omitempty"`
+ // To configure a different port exposed by the container (default `8080`).
+ Port int `property:"port" json:"port,omitempty"`
+ // To configure a different port name for the port exposed by the container. It defaults to `http` only when the `expose` parameter is true.
+ PortName string `property:"port-name" json:"portName,omitempty"`
+ // To configure under which service port the container port is to be exposed (default `80`).
+ ServicePort int `property:"service-port" json:"servicePort,omitempty"`
+ // To configure under which service port name the container port is to be exposed (default `http`).
+ ServicePortName string `property:"service-port-name" json:"servicePortName,omitempty"`
+ // The main container name. It's named `integration` by default.
+ Name string `property:"name" json:"name,omitempty"`
+ // The main container image
+ Image string `property:"image" json:"image,omitempty"`
+ // The pull policy: Always|Never|IfNotPresent
+ ImagePullPolicy corev1.PullPolicy `property:"image-pull-policy" json:"imagePullPolicy,omitempty"`
+
+ // DeprecatedProbesEnabled enable/disable probes on the container (default `false`)
+ // Deprecated: replaced by the health trait.
+ DeprecatedProbesEnabled *bool `property:"probes-enabled" json:"probesEnabled,omitempty"`
+ // Scheme to use when connecting. Defaults to HTTP. Applies to the liveness probe.
+ // Deprecated: replaced by the health trait.
+ DeprecatedLivenessScheme string `property:"liveness-scheme" json:"livenessScheme,omitempty"`
+ // Number of seconds after the container has started before liveness probes are initiated.
+ // Deprecated: replaced by the health trait.
+ DeprecatedLivenessInitialDelay int32 `property:"liveness-initial-delay" json:"livenessInitialDelay,omitempty"`
+ // Number of seconds after which the probe times out. Applies to the liveness probe.
+ // Deprecated: replaced by the health trait.
+ DeprecatedLivenessTimeout int32 `property:"liveness-timeout" json:"livenessTimeout,omitempty"`
+ // How often to perform the probe. Applies to the liveness probe.
+ // Deprecated: replaced by the health trait.
+ DeprecatedLivenessPeriod int32 `property:"liveness-period" json:"livenessPeriod,omitempty"`
+ // Minimum consecutive successes for the probe to be considered successful after having failed.
+ // Applies to the liveness probe.
+ // Deprecated: replaced by the health trait.
+ DeprecatedLivenessSuccessThreshold int32 `property:"liveness-success-threshold" json:"livenessSuccessThreshold,omitempty"`
+ // Minimum consecutive failures for the probe to be considered failed after having succeeded.
+ // Applies to the liveness probe.
+ // Deprecated: replaced by the health trait.
+ DeprecatedLivenessFailureThreshold int32 `property:"liveness-failure-threshold" json:"livenessFailureThreshold,omitempty"`
+ // Scheme to use when connecting. Defaults to HTTP. Applies to the readiness probe.
+ // Deprecated: replaced by the health trait.
+ DeprecatedReadinessScheme string `property:"readiness-scheme" json:"readinessScheme,omitempty"`
+ // Number of seconds after the container has started before readiness probes are initiated.
+ // Deprecated: replaced by the health trait.
+ DeprecatedReadinessInitialDelay int32 `property:"readiness-initial-delay" json:"readinessInitialDelay,omitempty"`
+ // Number of seconds after which the probe times out. Applies to the readiness probe.
+ // Deprecated: replaced by the health trait.
+ DeprecatedReadinessTimeout int32 `property:"readiness-timeout" json:"readinessTimeout,omitempty"`
+ // How often to perform the probe. Applies to the readiness probe.
+ // Deprecated: replaced by the health trait.
+ DeprecatedReadinessPeriod int32 `property:"readiness-period" json:"readinessPeriod,omitempty"`
+ // Minimum consecutive successes for the probe to be considered successful after having failed.
+ // Applies to the readiness probe.
+ // Deprecated: replaced by the health trait.
+ DeprecatedReadinessSuccessThreshold int32 `property:"readiness-success-threshold" json:"readinessSuccessThreshold,omitempty"`
+ // Minimum consecutive failures for the probe to be considered failed after having succeeded.
+ // Applies to the readiness probe.
+ // Deprecated: replaced by the health trait.
+ DeprecatedReadinessFailureThreshold int32 `property:"readiness-failure-threshold" json:"readinessFailureThreshold,omitempty"`
+}
diff --git a/pkg/apis/camel/v1/trait_cron.go b/pkg/apis/camel/v1/trait_cron.go
new file mode 100644
index 000000000..3f0578c71
--- /dev/null
+++ b/pkg/apis/camel/v1/trait_cron.go
@@ -0,0 +1,71 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package v1
+
+// The Cron trait can be used to customize the behaviour of periodic timer/cron based integrations.
+//
+// While normally an integration requires a pod to be always up and running, some periodic tasks, such as batch jobs,
+// require to be activated at specific hours of the day or with a periodic delay of minutes.
+// For such tasks, the cron trait can materialize the integration as a Kubernetes CronJob instead of a standard deployment,
+// in order to save resources when the integration does not need to be executed.
+//
+// Integrations that start from the following components are evaluated by the cron trait: `timer`, `cron`, `quartz`.
+//
+// The rules for using a Kubernetes CronJob are the following:
+// - `timer`: when periods can be written as cron expressions. E.g. `timer:tick?period=60000`.
+// - `cron`, `quartz`: when the cron expression does not contain seconds (or the "seconds" part is set to 0). E.g.
+// `cron:tab?schedule=0/2${plus}*{plus}*{plus}*{plus}?` or `quartz:trigger?cron=0{plus}0/2{plus}*{plus}*{plus}*{plus}?`.
+//
+// +camel-k:trait=cron.
+type CronTrait struct {
+ Trait `property:",squash" json:",inline"`
+ // The CronJob schedule for the whole integration. If multiple routes are declared, they must have the same schedule for this
+ // mechanism to work correctly.
+ Schedule string `property:"schedule" json:"schedule,omitempty"`
+ // A comma separated list of the Camel components that need to be customized in order for them to work when the schedule is triggered externally by Kubernetes.
+ // A specific customizer is activated for each specified component. E.g. for the `timer` component, the `cron-timer` customizer is
+ // activated (it's present in the `org.apache.camel.k:camel-k-cron` library).
+ //
+ // Supported components are currently: `cron`, `timer` and `quartz`.
+ Components string `property:"components" json:"components,omitempty"`
+ // Use the default Camel implementation of the `cron` endpoint (`quartz`) instead of trying to materialize the integration
+ // as Kubernetes CronJob.
+ Fallback *bool `property:"fallback" json:"fallback,omitempty"`
+ // Specifies how to treat concurrent executions of a Job.
+ // Valid values are:
+ // - "Allow": allows CronJobs to run concurrently;
+ // - "Forbid" (default): forbids concurrent runs, skipping next run if previous run hasn't finished yet;
+ // - "Replace": cancels currently running job and replaces it with a new one
+ ConcurrencyPolicy string `property:"concurrency-policy" json:"concurrencyPolicy,omitempty"`
+ // Automatically deploy the integration as CronJob when all routes are
+ // either starting from a periodic consumer (only `cron`, `timer` and `quartz` are supported) or a passive consumer (e.g. `direct` is a passive consumer).
+ //
+ // It's required that all periodic consumers have the same period and it can be expressed as cron schedule (e.g. `1m` can be expressed as `0/1 * * * *`,
+ // while `35m` or `50s` cannot).
+ Auto *bool `property:"auto" json:"auto,omitempty"`
+ // Optional deadline in seconds for starting the job if it misses scheduled
+ // time for any reason. Missed jobs executions will be counted as failed ones.
+ StartingDeadlineSeconds *int64 `property:"starting-deadline-seconds" json:"startingDeadlineSeconds,omitempty"`
+ // Specifies the duration in seconds, relative to the start time, that the job
+ // may be continuously active before it is considered to be failed.
+ // It defaults to 60s.
+ ActiveDeadlineSeconds *int64 `property:"active-deadline-seconds" json:"activeDeadlineSeconds,omitempty"`
+ // Specifies the number of retries before marking the job failed.
+ // It defaults to 2.
+ BackoffLimit *int32 `property:"backoff-limit" json:"backoffLimit,omitempty"`
+}
diff --git a/pkg/util/test/trait.go b/pkg/apis/camel/v1/trait_dependencies.go
similarity index 53%
copy from pkg/util/test/trait.go
copy to pkg/apis/camel/v1/trait_dependencies.go
index 653194972..07a639ae8 100644
--- a/pkg/util/test/trait.go
+++ b/pkg/apis/camel/v1/trait_dependencies.go
@@ -15,41 +15,12 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-package test
-
-import (
- "encoding/json"
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
-)
-
-func TraitSpecFromMap(t *testing.T, spec map[string]interface{}) v1.TraitSpec {
- t.Helper()
-
- var trait v1.TraitSpec
-
- data, err := json.Marshal(spec)
- assert.Nil(t, err)
-
- err = json.Unmarshal(data, &trait.Configuration)
- assert.Nil(t, err)
-
- return trait
-}
-
-func TraitSpecToMap(t *testing.T, spec v1.TraitSpec) map[string]string {
- t.Helper()
-
- trait := make(map[string]string)
-
- data, err := json.Marshal(spec.Configuration)
- assert.Nil(t, err)
-
- err = json.Unmarshal(data, &trait)
- assert.Nil(t, err)
-
- return trait
+package v1
+
+// The Dependencies trait is internally used to automatically add runtime dependencies based on the
+// integration that the user wants to run.
+//
+// +camel-k:trait=dependencies.
+type DependenciesTrait struct {
+ Trait `property:",squash" json:",inline"`
}
diff --git a/pkg/apis/camel/v1/trait_deployer.go b/pkg/apis/camel/v1/trait_deployer.go
new file mode 100644
index 000000000..a651d5ead
--- /dev/null
+++ b/pkg/apis/camel/v1/trait_deployer.go
@@ -0,0 +1,31 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package v1
+
+// The deployer trait is responsible for deploying the resources owned by the integration, and can be used
+// to explicitly select the underlying controller that will manage the integration pods.
+//
+// +camel-k:trait=deployer.
+type DeployerTrait struct {
+ Trait `property:",squash" json:",inline"`
+ // Allows to explicitly select the desired deployment kind between `deployment`, `cron-job` or `knative-service` when creating the resources for running the integration.
+ Kind string `property:"kind" json:"kind,omitempty"`
+ // Use server-side apply to update the owned resources (default `true`).
+ // Note that it automatically falls back to client-side patching, if SSA is not available, e.g., on old Kubernetes clusters.
+ UseSSA *bool `property:"use-ssa" json:"useSSA,omitempty"`
+}
diff --git a/pkg/util/test/trait.go b/pkg/apis/camel/v1/trait_deployment.go
similarity index 53%
copy from pkg/util/test/trait.go
copy to pkg/apis/camel/v1/trait_deployment.go
index 653194972..e1df04b16 100644
--- a/pkg/util/test/trait.go
+++ b/pkg/apis/camel/v1/trait_deployment.go
@@ -15,41 +15,15 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-package test
-
-import (
- "encoding/json"
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
-)
-
-func TraitSpecFromMap(t *testing.T, spec map[string]interface{}) v1.TraitSpec {
- t.Helper()
-
- var trait v1.TraitSpec
-
- data, err := json.Marshal(spec)
- assert.Nil(t, err)
-
- err = json.Unmarshal(data, &trait.Configuration)
- assert.Nil(t, err)
-
- return trait
-}
-
-func TraitSpecToMap(t *testing.T, spec v1.TraitSpec) map[string]string {
- t.Helper()
-
- trait := make(map[string]string)
-
- data, err := json.Marshal(spec.Configuration)
- assert.Nil(t, err)
-
- err = json.Unmarshal(data, &trait)
- assert.Nil(t, err)
-
- return trait
+package v1
+
+// The Deployment trait is responsible for generating the Kubernetes deployment that will make sure
+// the integration will run in the cluster.
+//
+// +camel-k:trait=deployment.
+type DeploymentTrait struct {
+ Trait `property:",squash" json:",inline"`
+ // The maximum time in seconds for the deployment to make progress before it
+ // is considered to be failed. It defaults to 60s.
+ ProgressDeadlineSeconds *int32 `property:"progress-deadline-seconds" json:"progressDeadlineSeconds,omitempty"`
}
diff --git a/pkg/apis/camel/v1/trait_environment.go b/pkg/apis/camel/v1/trait_environment.go
new file mode 100644
index 000000000..e7d7c8055
--- /dev/null
+++ b/pkg/apis/camel/v1/trait_environment.go
@@ -0,0 +1,34 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package v1
+
+// The environment trait is used internally to inject standard environment variables in the integration container,
+// such as `NAMESPACE`, `POD_NAME` and others.
+//
+// +camel-k:trait=environment.
+type EnvironmentTrait struct {
+ Trait `property:",squash" json:",inline"`
+ // Enables injection of `NAMESPACE` and `POD_NAME` environment variables (default `true`)
+ ContainerMeta *bool `property:"container-meta" json:"containerMeta,omitempty"`
+ // Propagates the `HTTP_PROXY`, `HTTPS_PROXY` and `NO_PROXY` environment variables (default `true`)
+ HTTPProxy *bool `property:"http-proxy" json:"httpProxy,omitempty"`
+ // A list of environment variables to be added to the integration container.
+ // The syntax is KEY=VALUE, e.g., `MY_VAR="my value"`.
+ // These take precedence over the previously defined environment variables.
+ Vars []string `property:"vars" json:"vars,omitempty"`
+}
diff --git a/pkg/util/test/trait.go b/pkg/apis/camel/v1/trait_error_handler.go
similarity index 53%
copy from pkg/util/test/trait.go
copy to pkg/apis/camel/v1/trait_error_handler.go
index 653194972..1638a1b9f 100644
--- a/pkg/util/test/trait.go
+++ b/pkg/apis/camel/v1/trait_error_handler.go
@@ -15,41 +15,13 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-package test
-
-import (
- "encoding/json"
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
-)
-
-func TraitSpecFromMap(t *testing.T, spec map[string]interface{}) v1.TraitSpec {
- t.Helper()
-
- var trait v1.TraitSpec
-
- data, err := json.Marshal(spec)
- assert.Nil(t, err)
-
- err = json.Unmarshal(data, &trait.Configuration)
- assert.Nil(t, err)
-
- return trait
-}
-
-func TraitSpecToMap(t *testing.T, spec v1.TraitSpec) map[string]string {
- t.Helper()
-
- trait := make(map[string]string)
-
- data, err := json.Marshal(spec.Configuration)
- assert.Nil(t, err)
-
- err = json.Unmarshal(data, &trait)
- assert.Nil(t, err)
-
- return trait
+package v1
+
+// The error-handler is a platform trait used to inject Error Handler source into the integration runtime.
+//
+// +camel-k:trait=error-handler.
+type ErrorHandlerTrait struct {
+ Trait `property:",squash" json:",inline"`
+ // The error handler ref name provided or found in application properties
+ ErrorHandlerRef string `property:"ref" json:"ref,omitempty"`
}
diff --git a/pkg/util/test/trait.go b/pkg/apis/camel/v1/trait_gc.go
similarity index 53%
copy from pkg/util/test/trait.go
copy to pkg/apis/camel/v1/trait_gc.go
index 653194972..c371952fe 100644
--- a/pkg/util/test/trait.go
+++ b/pkg/apis/camel/v1/trait_gc.go
@@ -15,41 +15,21 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-package test
-
-import (
- "encoding/json"
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
-)
-
-func TraitSpecFromMap(t *testing.T, spec map[string]interface{}) v1.TraitSpec {
- t.Helper()
-
- var trait v1.TraitSpec
-
- data, err := json.Marshal(spec)
- assert.Nil(t, err)
-
- err = json.Unmarshal(data, &trait.Configuration)
- assert.Nil(t, err)
-
- return trait
+package v1
+
+// The GC Trait garbage-collects all resources that are no longer necessary upon integration updates.
+//
+// +camel-k:trait=gc.
+type GCTrait struct {
+ Trait `property:",squash" json:",inline"`
+ // Discovery client cache to be used, either `disabled`, `disk` or `memory` (default `memory`)
+ DiscoveryCache *DiscoveryCacheType `property:"discovery-cache" json:"discoveryCache,omitempty"`
}
-func TraitSpecToMap(t *testing.T, spec v1.TraitSpec) map[string]string {
- t.Helper()
-
- trait := make(map[string]string)
-
- data, err := json.Marshal(spec.Configuration)
- assert.Nil(t, err)
+type DiscoveryCacheType string
- err = json.Unmarshal(data, &trait)
- assert.Nil(t, err)
-
- return trait
-}
+const (
+ DisabledDiscoveryCache DiscoveryCacheType = "disabled"
+ DiskDiscoveryCache DiscoveryCacheType = "disk"
+ MemoryDiscoveryCache DiscoveryCacheType = "memory"
+)
diff --git a/pkg/apis/camel/v1/trait_health.go b/pkg/apis/camel/v1/trait_health.go
new file mode 100644
index 000000000..be7ae169d
--- /dev/null
+++ b/pkg/apis/camel/v1/trait_health.go
@@ -0,0 +1,57 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package v1
+
+// The health trait is responsible for configuring the health probes on the integration container.
+//
+// It's disabled by default.
+//
+// +camel-k:trait=health.
+type HealthTrait struct {
+ Trait `property:",squash" json:",inline"`
+
+ // Configures the liveness probe for the integration container (default `false`).
+ LivenessProbeEnabled *bool `property:"liveness-probe-enabled" json:"livenessProbeEnabled,omitempty"`
+ // Scheme to use when connecting to the liveness probe (default `HTTP`).
+ LivenessScheme string `property:"liveness-scheme" json:"livenessScheme,omitempty"`
+ // Number of seconds after the container has started before the liveness probe is initiated.
+ LivenessInitialDelay int32 `property:"liveness-initial-delay" json:"livenessInitialDelay,omitempty"`
+ // Number of seconds after which the liveness probe times out.
+ LivenessTimeout int32 `property:"liveness-timeout" json:"livenessTimeout,omitempty"`
+ // How often to perform the liveness probe.
+ LivenessPeriod int32 `property:"liveness-period" json:"livenessPeriod,omitempty"`
+ // Minimum consecutive successes for the liveness probe to be considered successful after having failed.
+ LivenessSuccessThreshold int32 `property:"liveness-success-threshold" json:"livenessSuccessThreshold,omitempty"`
+ // Minimum consecutive failures for the liveness probe to be considered failed after having succeeded.
+ LivenessFailureThreshold int32 `property:"liveness-failure-threshold" json:"livenessFailureThreshold,omitempty"`
+
+ // Configures the readiness probe for the integration container (default `true`).
+ ReadinessProbeEnabled *bool `property:"readiness-probe-enabled" json:"readinessProbeEnabled,omitempty"`
+ // Scheme to use when connecting to the readiness probe (default `HTTP`).
+ ReadinessScheme string `property:"readiness-scheme" json:"readinessScheme,omitempty"`
+ // Number of seconds after the container has started before the readiness probe is initiated.
+ ReadinessInitialDelay int32 `property:"readiness-initial-delay" json:"readinessInitialDelay,omitempty"`
+ // Number of seconds after which the readiness probe times out.
+ ReadinessTimeout int32 `property:"readiness-timeout" json:"readinessTimeout,omitempty"`
+ // How often to perform the readiness probe.
+ ReadinessPeriod int32 `property:"readiness-period" json:"readinessPeriod,omitempty"`
+ // Minimum consecutive successes for the readiness probe to be considered successful after having failed.
+ ReadinessSuccessThreshold int32 `property:"readiness-success-threshold" json:"readinessSuccessThreshold,omitempty"`
+ // Minimum consecutive failures for the readiness probe to be considered failed after having succeeded.
+ ReadinessFailureThreshold int32 `property:"readiness-failure-threshold" json:"readinessFailureThreshold,omitempty"`
+}
diff --git a/pkg/util/test/trait.go b/pkg/apis/camel/v1/trait_ingress.go
similarity index 53%
copy from pkg/util/test/trait.go
copy to pkg/apis/camel/v1/trait_ingress.go
index 653194972..db841d929 100644
--- a/pkg/util/test/trait.go
+++ b/pkg/apis/camel/v1/trait_ingress.go
@@ -15,41 +15,18 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-package test
-
-import (
- "encoding/json"
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
-)
-
-func TraitSpecFromMap(t *testing.T, spec map[string]interface{}) v1.TraitSpec {
- t.Helper()
-
- var trait v1.TraitSpec
-
- data, err := json.Marshal(spec)
- assert.Nil(t, err)
-
- err = json.Unmarshal(data, &trait.Configuration)
- assert.Nil(t, err)
-
- return trait
-}
-
-func TraitSpecToMap(t *testing.T, spec v1.TraitSpec) map[string]string {
- t.Helper()
-
- trait := make(map[string]string)
-
- data, err := json.Marshal(spec.Configuration)
- assert.Nil(t, err)
-
- err = json.Unmarshal(data, &trait)
- assert.Nil(t, err)
-
- return trait
+package v1
+
+// The Ingress trait can be used to expose the service associated with the integration
+// to the outside world with a Kubernetes Ingress.
+//
+// It's enabled by default whenever a Service is added to the integration (through the `service` trait).
+//
+// +camel-k:trait=ingress.
+type IngressTrait struct {
+ Trait `property:",squash" json:",inline"`
+ // **Required**. To configure the host exposed by the ingress.
+ Host string `property:"host" json:"host,omitempty"`
+ // To automatically add an ingress whenever the integration uses a HTTP endpoint consumer.
+ Auto *bool `property:"auto" json:"auto,omitempty"`
}
diff --git a/pkg/util/test/trait.go b/pkg/apis/camel/v1/trait_istio.go
similarity index 53%
copy from pkg/util/test/trait.go
copy to pkg/apis/camel/v1/trait_istio.go
index 653194972..6c19af1f8 100644
--- a/pkg/util/test/trait.go
+++ b/pkg/apis/camel/v1/trait_istio.go
@@ -15,41 +15,16 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-package test
-
-import (
- "encoding/json"
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
-)
-
-func TraitSpecFromMap(t *testing.T, spec map[string]interface{}) v1.TraitSpec {
- t.Helper()
-
- var trait v1.TraitSpec
-
- data, err := json.Marshal(spec)
- assert.Nil(t, err)
-
- err = json.Unmarshal(data, &trait.Configuration)
- assert.Nil(t, err)
-
- return trait
-}
-
-func TraitSpecToMap(t *testing.T, spec v1.TraitSpec) map[string]string {
- t.Helper()
-
- trait := make(map[string]string)
-
- data, err := json.Marshal(spec.Configuration)
- assert.Nil(t, err)
-
- err = json.Unmarshal(data, &trait)
- assert.Nil(t, err)
-
- return trait
+package v1
+
+// The Istio trait allows configuring properties related to the Istio service mesh,
+// such as sidecar injection and outbound IP ranges.
+//
+// +camel-k:trait=istio.
+type IstioTrait struct {
+ Trait `property:",squash" json:",inline"`
+ // Configures a (comma-separated) list of CIDR subnets that should not be intercepted by the Istio proxy (`10.0.0.0/8,172.16.0.0/12,192.168.0.0/16` by default).
+ Allow string `property:"allow" json:"allow,omitempty"`
+ // Forces the value for labels `sidecar.istio.io/inject`. By default the label is set to `true` on deployment and not set on Knative Service.
+ Inject *bool `property:"inject" json:"inject,omitempty"`
}
diff --git a/pkg/apis/camel/v1/trait_jolokia.go b/pkg/apis/camel/v1/trait_jolokia.go
new file mode 100644
index 000000000..62f0b4b29
--- /dev/null
+++ b/pkg/apis/camel/v1/trait_jolokia.go
@@ -0,0 +1,58 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package v1
+
+// The Jolokia trait activates and configures the Jolokia Java agent.
+//
+// See https://jolokia.org/reference/html/agents.html
+//
+// +camel-k:trait=jolokia
+// nolint: tagliatelle
+type JolokiaTrait struct {
+ Trait `property:",squash" json:",inline"`
+ // The PEM encoded CA certification file path, used to verify client certificates,
+ // applicable when `protocol` is `https` and `use-ssl-client-authentication` is `true`
+ // (default `/var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt` for OpenShift).
+ CaCert *string `property:"ca-cert" json:"CACert,omitempty"`
+ // The principal(s) which must be given in a client certificate to allow access to the Jolokia endpoint,
+ // applicable when `protocol` is `https` and `use-ssl-client-authentication` is `true`
+ // (default `clientPrincipal=cn=system:master-proxy`, `cn=hawtio-online.hawtio.svc` and `cn=fuse-console.fuse.svc` for OpenShift).
+ ClientPrincipal []string `property:"client-principal" json:"clientPrincipal,omitempty"`
+ // Listen for multicast requests (default `false`)
+ DiscoveryEnabled *bool `property:"discovery-enabled" json:"discoveryEnabled,omitempty"`
+ // Mandate the client certificate contains a client flag in the extended key usage section,
+ // applicable when `protocol` is `https` and `use-ssl-client-authentication` is `true`
+ // (default `true` for OpenShift).
+ ExtendedClientCheck *bool `property:"extended-client-check" json:"extendedClientCheck,omitempty"`
+ // The Host address to which the Jolokia agent should bind to. If `"\*"` or `"0.0.0.0"` is given,
+ // the servers binds to every network interface (default `"*"`).
+ Host *string `property:"host" json:"host,omitempty"`
+ // The password used for authentication, applicable when the `user` option is set.
+ Password *string `property:"password" json:"password,omitempty"`
+ // The Jolokia endpoint port (default `8778`).
+ Port int `property:"port" json:"port,omitempty"`
+ // The protocol to use, either `http` or `https` (default `https` for OpenShift)
+ Protocol *string `property:"protocol" json:"protocol,omitempty"`
+ // The user to be used for authentication
+ User *string `property:"user" json:"user,omitempty"`
+ // Whether client certificates should be used for authentication (default `true` for OpenShift).
+ UseSslClientAuthentication *bool `property:"use-ssl-client-authentication" json:"useSSLClientAuthentication,omitempty"`
+ // A list of additional Jolokia options as defined
+ // in https://jolokia.org/reference/html/agents.html#agent-jvm-config[JVM agent configuration options]
+ Options []string `property:"options" json:"options,omitempty"`
+}
diff --git a/pkg/apis/camel/v1/trait_jvm.go b/pkg/apis/camel/v1/trait_jvm.go
new file mode 100644
index 000000000..16d304033
--- /dev/null
+++ b/pkg/apis/camel/v1/trait_jvm.go
@@ -0,0 +1,37 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package v1
+
+// The JVM trait is used to configure the JVM that runs the integration.
+//
+// +camel-k:trait=jvm.
+type JVMTrait struct {
+ Trait `property:",squash" json:",inline"`
+ // Activates remote debugging, so that a debugger can be attached to the JVM, e.g., using port-forwarding
+ Debug *bool `property:"debug" json:"debug,omitempty"`
+ // Suspends the target JVM immediately before the main class is loaded
+ DebugSuspend *bool `property:"debug-suspend" json:"debugSuspend,omitempty"`
+ // Prints the command used the start the JVM in the container logs (default `true`)
+ PrintCommand *bool `property:"print-command" json:"printCommand,omitempty"`
+ // Transport address at which to listen for the newly launched JVM (default `*:5005`)
+ DebugAddress string `property:"debug-address" json:"debugAddress,omitempty"`
+ // A list of JVM options
+ Options []string `property:"options" json:"options,omitempty"`
+ // Additional JVM classpath (use `Linux` classpath separator)
+ Classpath string `property:"classpath" json:"classpath,omitempty"`
+}
diff --git a/pkg/util/test/trait.go b/pkg/apis/camel/v1/trait_kamelets.go
similarity index 53%
copy from pkg/util/test/trait.go
copy to pkg/apis/camel/v1/trait_kamelets.go
index 653194972..80d8e0b5e 100644
--- a/pkg/util/test/trait.go
+++ b/pkg/apis/camel/v1/trait_kamelets.go
@@ -15,41 +15,15 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-package test
-
-import (
- "encoding/json"
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
-)
-
-func TraitSpecFromMap(t *testing.T, spec map[string]interface{}) v1.TraitSpec {
- t.Helper()
-
- var trait v1.TraitSpec
-
- data, err := json.Marshal(spec)
- assert.Nil(t, err)
-
- err = json.Unmarshal(data, &trait.Configuration)
- assert.Nil(t, err)
-
- return trait
-}
-
-func TraitSpecToMap(t *testing.T, spec v1.TraitSpec) map[string]string {
- t.Helper()
-
- trait := make(map[string]string)
-
- data, err := json.Marshal(spec.Configuration)
- assert.Nil(t, err)
-
- err = json.Unmarshal(data, &trait)
- assert.Nil(t, err)
-
- return trait
+package v1
+
+// The kamelets trait is a platform trait used to inject Kamelets into the integration runtime.
+//
+// +camel-k:trait=kamelets.
+type KameletsTrait struct {
+ Trait `property:",squash" json:",inline"`
+ // Automatically inject all referenced Kamelets and their default configuration (enabled by default)
+ Auto *bool `property:"auto" json:"auto,omitempty"`
+ // Comma separated list of Kamelet names to load into the current integration
+ List string `property:"list" json:"list,omitempty"`
}
diff --git a/pkg/apis/camel/v1/trait_knative.go b/pkg/apis/camel/v1/trait_knative.go
new file mode 100644
index 000000000..00ac879e0
--- /dev/null
+++ b/pkg/apis/camel/v1/trait_knative.go
@@ -0,0 +1,60 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package v1
+
+// The Knative trait automatically discovers addresses of Knative resources and inject them into the
+// running integration.
+//
+// The full Knative configuration is injected in the CAMEL_KNATIVE_CONFIGURATION in JSON format.
+// The Camel Knative component will then use the full configuration to configure the routes.
+//
+// The trait is enabled by default when the Knative profile is active.
+//
+// +camel-k:trait=knative.
+type KnativeTrait struct {
+ Trait `property:",squash" json:",inline"`
+ // Can be used to inject a Knative complete configuration in JSON format.
+ Configuration string `property:"configuration" json:"configuration,omitempty"`
+ // List of channels used as source of integration routes.
+ // Can contain simple channel names or full Camel URIs.
+ ChannelSources []string `property:"channel-sources" json:"channelSources,omitempty"`
+ // List of channels used as destination of integration routes.
+ // Can contain simple channel names or full Camel URIs.
+ ChannelSinks []string `property:"channel-sinks" json:"channelSinks,omitempty"`
+ // List of channels used as source of integration routes.
+ EndpointSources []string `property:"endpoint-sources" json:"endpointSources,omitempty"`
+ // List of endpoints used as destination of integration routes.
+ // Can contain simple endpoint names or full Camel URIs.
+ EndpointSinks []string `property:"endpoint-sinks" json:"endpointSinks,omitempty"`
+ // List of event types that the integration will be subscribed to.
+ // Can contain simple event types or full Camel URIs (to use a specific broker different from "default").
+ EventSources []string `property:"event-sources" json:"eventSources,omitempty"`
+ // List of event types that the integration will produce.
+ // Can contain simple event types or full Camel URIs (to use a specific broker).
+ EventSinks []string `property:"event-sinks" json:"eventSinks,omitempty"`
+ // Enables filtering on events based on the header "ce-knativehistory". Since this header has been removed in newer versions of
+ // Knative, filtering is disabled by default.
+ FilterSourceChannels *bool `property:"filter-source-channels" json:"filterSourceChannels,omitempty"`
+ // Allows binding the integration to a sink via a Knative SinkBinding resource.
+ // This can be used when the integration targets a single sink.
+ // It's enabled by default when the integration targets a single sink
+ // (except when the integration is owned by a Knative source).
+ SinkBinding *bool `property:"sink-binding" json:"sinkBinding,omitempty"`
+ // Enable automatic discovery of all trait properties.
+ Auto *bool `property:"auto" json:"auto,omitempty"`
+}
diff --git a/pkg/apis/camel/v1/trait_knative_service.go b/pkg/apis/camel/v1/trait_knative_service.go
new file mode 100644
index 000000000..1bf07343d
--- /dev/null
+++ b/pkg/apis/camel/v1/trait_knative_service.go
@@ -0,0 +1,60 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package v1
+
+// The Knative Service trait allows configuring options when running the Integration as a Knative service, instead of
+// a standard Kubernetes Deployment.
+//
+// Running an Integration as a Knative Service enables auto-scaling (and scaling-to-zero), but those features
+// are only relevant when the Camel route(s) use(s) an HTTP endpoint consumer.
+//
+// +camel-k:trait=knative-service.
+type KnativeServiceTrait struct {
+ Trait `property:",squash" json:",inline"`
+ // 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" 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" 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" 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" 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" json:"maxScale,omitempty"`
+ // Enables to gradually shift traffic to the latest Revision and sets the rollout duration.
+ // It's disabled by default and must be expressed as a Golang `time.Duration` string representation,
+ // rounded to a second precision.
+ RolloutDuration string `property:"rollout-duration" json:"rolloutDuration,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" json:"auto,omitempty"`
+}
diff --git a/pkg/apis/camel/v1/trait_logging.go b/pkg/apis/camel/v1/trait_logging.go
new file mode 100644
index 000000000..1f8946e27
--- /dev/null
+++ b/pkg/apis/camel/v1/trait_logging.go
@@ -0,0 +1,36 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package v1
+
+// The Logging trait is used to configure Integration runtime logging options (such as color and format).
+// The logging backend is provided by Quarkus, whose configuration is documented at https://quarkus.io/guides/logging.
+//
+// +camel-k:trait=logging.
+type LoggingTrait struct {
+ Trait `property:",squash" json:",inline"`
+ // Colorize the log output
+ Color *bool `property:"color" json:"color,omitempty"`
+ // Logs message format
+ Format string `property:"format" json:"format,omitempty"`
+ // Adjust the logging level (defaults to INFO)
+ Level string `property:"level" json:"level,omitempty"`
+ // Output the logs in JSON
+ JSON *bool `property:"json" json:"json,omitempty"`
+ // Enable "pretty printing" of the JSON logs
+ JSONPrettyPrint *bool `property:"json-pretty-print" json:"jsonPrettyPrint,omitempty"`
+}
diff --git a/pkg/apis/camel/v1/trait_mount.go b/pkg/apis/camel/v1/trait_mount.go
new file mode 100644
index 000000000..1a498e406
--- /dev/null
+++ b/pkg/apis/camel/v1/trait_mount.go
@@ -0,0 +1,38 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package v1
+
+// The Mount trait can be used to configure volumes mounted on the Integration Pods.
+//
+// +camel-k:trait=mount
+// nolint: tagliatelle
+type MountTrait struct {
+ Trait `property:",squash" json:",inline"`
+ // A list of configuration pointing to configmap/secret.
+ // The configuration are expected to be UTF-8 resources as they are processed by runtime Camel Context and tried to be parsed as property files.
+ // They are also made available on the classpath in order to ease their usage directly from the Route.
+ // Syntax: [configmap|secret]:name[/key], where name represents the resource name and key optionally represents the resource key to be filtered
+ Configs []string `property:"configs" json:"configs,omitempty"`
+ // A list of resources (text or binary content) pointing to configmap/secret.
+ // The resources are expected to be any resource type (text or binary content).
+ // The destination path can be either a default location or any path specified by the user.
+ // Syntax: [configmap|secret]:name[/key][@path], where name represents the resource name, key optionally represents the resource key to be filtered and path represents the destination path
+ Resources []string `property:"resources" json:"resources,omitempty"`
+ // A list of Persistent Volume Claims to be mounted. Syntax: [pvcname:/container/path]
+ Volumes []string `property:"volumes" json:"volumes,omitempty"`
+}
diff --git a/pkg/util/test/trait.go b/pkg/apis/camel/v1/trait_openapi.go
similarity index 53%
copy from pkg/util/test/trait.go
copy to pkg/apis/camel/v1/trait_openapi.go
index 653194972..e9bbf1fa7 100644
--- a/pkg/util/test/trait.go
+++ b/pkg/apis/camel/v1/trait_openapi.go
@@ -15,41 +15,13 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-package test
-
-import (
- "encoding/json"
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
-)
-
-func TraitSpecFromMap(t *testing.T, spec map[string]interface{}) v1.TraitSpec {
- t.Helper()
-
- var trait v1.TraitSpec
-
- data, err := json.Marshal(spec)
- assert.Nil(t, err)
-
- err = json.Unmarshal(data, &trait.Configuration)
- assert.Nil(t, err)
-
- return trait
-}
-
-func TraitSpecToMap(t *testing.T, spec v1.TraitSpec) map[string]string {
- t.Helper()
-
- trait := make(map[string]string)
-
- data, err := json.Marshal(spec.Configuration)
- assert.Nil(t, err)
-
- err = json.Unmarshal(data, &trait)
- assert.Nil(t, err)
-
- return trait
+package v1
+
+// The OpenAPI DSL trait is internally used to allow creating integrations from a OpenAPI specs.
+//
+// +camel-k:trait=openapi.
+type OpenAPITrait struct {
+ Trait `property:",squash" json:",inline"`
+ // The configmaps holding the spec of the OpenAPI
+ Configmaps []string `property:"configmaps" json:"configmaps,omitempty"`
}
diff --git a/pkg/util/test/trait.go b/pkg/apis/camel/v1/trait_owner.go
similarity index 53%
copy from pkg/util/test/trait.go
copy to pkg/apis/camel/v1/trait_owner.go
index 653194972..7791aec31 100644
--- a/pkg/util/test/trait.go
+++ b/pkg/apis/camel/v1/trait_owner.go
@@ -15,41 +15,16 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-package test
-
-import (
- "encoding/json"
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
-)
-
-func TraitSpecFromMap(t *testing.T, spec map[string]interface{}) v1.TraitSpec {
- t.Helper()
-
- var trait v1.TraitSpec
-
- data, err := json.Marshal(spec)
- assert.Nil(t, err)
-
- err = json.Unmarshal(data, &trait.Configuration)
- assert.Nil(t, err)
-
- return trait
-}
-
-func TraitSpecToMap(t *testing.T, spec v1.TraitSpec) map[string]string {
- t.Helper()
-
- trait := make(map[string]string)
-
- data, err := json.Marshal(spec.Configuration)
- assert.Nil(t, err)
-
- err = json.Unmarshal(data, &trait)
- assert.Nil(t, err)
-
- return trait
+package v1
+
+// The Owner trait ensures that all created resources belong to the integration being created
+// and transfers annotations and labels on the integration onto these owned resources.
+//
+// +camel-k:trait=owner.
+type OwnerTrait struct {
+ Trait `property:",squash" json:",inline"`
+ // 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"`
}
diff --git a/pkg/apis/camel/v1/trait_pdb.go b/pkg/apis/camel/v1/trait_pdb.go
new file mode 100644
index 000000000..d99bd23b0
--- /dev/null
+++ b/pkg/apis/camel/v1/trait_pdb.go
@@ -0,0 +1,33 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package v1
+
+// The PDB trait allows to configure the PodDisruptionBudget resource for the Integration pods.
+//
+// +camel-k:trait=pdb.
+type PDBTrait struct {
+ Trait `property:",squash" json:",inline"`
+ // The number of pods for the Integration that must still be available after an eviction.
+ // It can be either an absolute number or a percentage.
+ // Only one of `min-available` and `max-unavailable` can be specified.
+ MinAvailable string `property:"min-available" json:"minAvailable,omitempty"`
+ // The number of pods for the Integration that can be unavailable after an eviction.
+ // It can be either an absolute number or a percentage (default `1` if `min-available` is also not set).
+ // Only one of `max-unavailable` and `min-available` can be specified.
+ MaxUnavailable string `property:"max-unavailable" json:"maxUnavailable,omitempty"`
+}
diff --git a/pkg/apis/camel/v1/trait_platform.go b/pkg/apis/camel/v1/trait_platform.go
new file mode 100644
index 000000000..b16199478
--- /dev/null
+++ b/pkg/apis/camel/v1/trait_platform.go
@@ -0,0 +1,35 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package v1
+
+// The platform trait is a base trait that is used to assign an integration platform to an integration.
+//
+// In case the platform is missing, the trait is allowed to create a default platform.
+// This feature is especially useful in contexts where there's no need to provide a custom configuration for the platform
+// (e.g. on OpenShift the default settings work, since there's an embedded container image registry).
+//
+// +camel-k:trait=platform.
+type PlatformTrait struct {
+ Trait `property:",squash" json:",inline"`
+ // To create a default (empty) platform when the platform is missing.
+ CreateDefault *bool `property:"create-default" json:"createDefault,omitempty"`
+ // Indicates if the platform should be created globally in the case of global operator (default true).
+ Global *bool `property:"global" json:"global,omitempty"`
+ // To automatically detect from the environment if a default platform can be created (it will be created on OpenShift only).
+ Auto *bool `property:"auto" json:"auto,omitempty"`
+}
diff --git a/pkg/util/test/trait.go b/pkg/apis/camel/v1/trait_pod.go
similarity index 53%
copy from pkg/util/test/trait.go
copy to pkg/apis/camel/v1/trait_pod.go
index 653194972..fe41bc552 100644
--- a/pkg/util/test/trait.go
+++ b/pkg/apis/camel/v1/trait_pod.go
@@ -15,41 +15,16 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-package test
-
-import (
- "encoding/json"
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
-)
-
-func TraitSpecFromMap(t *testing.T, spec map[string]interface{}) v1.TraitSpec {
- t.Helper()
-
- var trait v1.TraitSpec
-
- data, err := json.Marshal(spec)
- assert.Nil(t, err)
-
- err = json.Unmarshal(data, &trait.Configuration)
- assert.Nil(t, err)
-
- return trait
-}
-
-func TraitSpecToMap(t *testing.T, spec v1.TraitSpec) map[string]string {
- t.Helper()
-
- trait := make(map[string]string)
-
- data, err := json.Marshal(spec.Configuration)
- assert.Nil(t, err)
-
- err = json.Unmarshal(data, &trait)
- assert.Nil(t, err)
-
- return trait
+package v1
+
+// The pod trait allows the customization of the Integration pods.
+// It applies the `PodSpecTemplate` struct contained in the Integration `.spec.podTemplate` field,
+// into the Integration deployment Pods template, using strategic merge patch.
+//
+// This can be used to customize the container where Camel routes execute,
+// by using the `integration` container name.
+//
+// +camel-k:trait=pod.
+type PodTrait struct {
+ Trait `property:",squash" json:",inline"`
}
diff --git a/pkg/apis/camel/v1/trait_prometheus.go b/pkg/apis/camel/v1/trait_prometheus.go
new file mode 100644
index 000000000..75054c5d1
--- /dev/null
+++ b/pkg/apis/camel/v1/trait_prometheus.go
@@ -0,0 +1,38 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package v1
+
+// The Prometheus trait configures a Prometheus-compatible endpoint. It also creates a `PodMonitor` resource,
+// so that the endpoint can be scraped automatically, when using the Prometheus operator.
+//
+// The metrics are exposed using MicroProfile Metrics.
+//
+// WARNING: The creation of the `PodMonitor` resource requires the https://github.com/coreos/prometheus-operator[Prometheus Operator]
+// custom resource definition to be installed.
+// You can set `pod-monitor` to `false` for the Prometheus trait to work without the Prometheus Operator.
+//
+// The Prometheus trait is disabled by default.
+//
+// +camel-k:trait=prometheus.
+type PrometheusTrait struct {
+ Trait `property:",squash" json:",inline"`
+ // Whether a `PodMonitor` resource is created (default `true`).
+ PodMonitor *bool `property:"pod-monitor" json:"podMonitor,omitempty"`
+ // The `PodMonitor` resource labels, applicable when `pod-monitor` is `true`.
+ PodMonitorLabels []string `property:"pod-monitor-labels" json:"podMonitorLabels,omitempty"`
+}
diff --git a/pkg/apis/camel/v1/trait_pull_secret.go b/pkg/apis/camel/v1/trait_pull_secret.go
new file mode 100644
index 000000000..e80d8adf7
--- /dev/null
+++ b/pkg/apis/camel/v1/trait_pull_secret.go
@@ -0,0 +1,40 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package v1
+
+// The Pull Secret trait sets a pull secret on the pod,
+// to allow Kubernetes to retrieve the container image from an external registry.
+//
+// The pull secret can be specified manually or, in case you've configured authentication for an external container registry
+// on the `IntegrationPlatform`, the same secret is used to pull images.
+//
+// It's enabled by default whenever you configure authentication for an external container registry,
+// so it assumes that external registries are private.
+//
+// If your registry does not need authentication for pulling images, you can disable this trait.
+//
+// +camel-k:trait=pull-secret.
+type PullSecretTrait struct {
+ Trait `property:",squash" json:",inline"`
+ // The pull secret name to set on the Pod. If left empty this is automatically taken from the `IntegrationPlatform` registry configuration.
+ SecretName string `property:"secret-name" json:"secretName,omitempty"`
+ // When using a global operator with a shared platform, this enables delegation of the `system:image-puller` cluster role on the operator namespace to the integration service account.
+ ImagePullerDelegation *bool `property:"image-puller-delegation" json:"imagePullerDelegation,omitempty"`
+ // Automatically configures the platform registry secret on the pod if it is of type `kubernetes.io/dockerconfigjson`.
+ Auto *bool `property:"auto" json:"auto,omitempty"`
+}
diff --git a/pkg/apis/camel/v1/trait_quarkus.go b/pkg/apis/camel/v1/trait_quarkus.go
new file mode 100644
index 000000000..6e2560278
--- /dev/null
+++ b/pkg/apis/camel/v1/trait_quarkus.go
@@ -0,0 +1,47 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package v1
+
+// The Quarkus trait configures the Quarkus runtime.
+//
+// It's enabled by default.
+//
+// NOTE: Compiling to a native executable, i.e. when using `package-type=native`, is only supported
+// for kamelets, as well as YAML and XML integrations.
+// It also requires at least 4GiB of memory, so the Pod running the native build, that is either
+// the operator Pod, or the build Pod (depending on the build strategy configured for the platform),
+// must have enough memory available.
+//
+// +camel-k:trait=quarkus.
+type QuarkusTrait struct {
+ Trait `property:",squash" json:",inline"`
+ // The Quarkus package types, either `fast-jar` or `native` (default `fast-jar`).
+ // In case both `fast-jar` and `native` are specified, two `IntegrationKit` resources are created,
+ // with the `native` kit having precedence over the `fast-jar` one once ready.
+ // The order influences the resolution of the current kit for the integration.
+ // The kit corresponding to the first package type will be assigned to the
+ // integration in case no existing kit that matches the integration exists.
+ PackageTypes []QuarkusPackageType `property:"package-type" json:"packageTypes,omitempty"`
+}
+
+type QuarkusPackageType string
+
+const (
+ FastJarPackageType QuarkusPackageType = "fast-jar"
+ NativePackageType QuarkusPackageType = "native"
+)
diff --git a/pkg/util/test/trait.go b/pkg/apis/camel/v1/trait_registry.go
similarity index 53%
copy from pkg/util/test/trait.go
copy to pkg/apis/camel/v1/trait_registry.go
index 653194972..939cf01c7 100644
--- a/pkg/util/test/trait.go
+++ b/pkg/apis/camel/v1/trait_registry.go
@@ -15,41 +15,12 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-package test
-
-import (
- "encoding/json"
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
-)
-
-func TraitSpecFromMap(t *testing.T, spec map[string]interface{}) v1.TraitSpec {
- t.Helper()
-
- var trait v1.TraitSpec
-
- data, err := json.Marshal(spec)
- assert.Nil(t, err)
-
- err = json.Unmarshal(data, &trait.Configuration)
- assert.Nil(t, err)
-
- return trait
-}
-
-func TraitSpecToMap(t *testing.T, spec v1.TraitSpec) map[string]string {
- t.Helper()
-
- trait := make(map[string]string)
-
- data, err := json.Marshal(spec.Configuration)
- assert.Nil(t, err)
-
- err = json.Unmarshal(data, &trait)
- assert.Nil(t, err)
-
- return trait
+package v1
+
+// The Registry trait sets up Maven to use the Image registry
+// as a Maven repository.
+//
+// +camel-k:trait=registry.
+type RegistryTrait struct {
+ Trait `property:",squash" json:",inline"`
}
diff --git a/pkg/apis/camel/v1/trait_route.go b/pkg/apis/camel/v1/trait_route.go
new file mode 100644
index 000000000..4276a39c3
--- /dev/null
+++ b/pkg/apis/camel/v1/trait_route.go
@@ -0,0 +1,80 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package v1
+
+// The Route trait can be used to configure the creation of OpenShift routes for the integration.
+//
+// The certificate and key contents may be sourced either from the local filesystem or in a Openshift `secret` object.
+// The user may use the parameters ending in `-secret` (example: `tls-certificate-secret`) to reference a certificate stored in a `secret`.
+// Parameters ending in `-secret` have higher priorities and in case the same route parameter is set, for example: `tls-key-secret` and `tls-key`,
+// then `tls-key-secret` is used.
+// The recommended approach to set the key and certificates is to use `secrets` to store their contents and use the
+// following parameters to reference them: `tls-certificate-secret`, `tls-key-secret`, `tls-ca-certificate-secret`, `tls-destination-ca-certificate-secret`
+// See the examples section at the end of this page to see the setup options.
+//
+// +camel-k:trait=route
+// nolint: tagliatelle
+type RouteTrait struct {
+ Trait `property:",squash" json:",inline"`
+ // To configure the host exposed by the route.
+ Host string `property:"host" json:"host,omitempty"`
+ // The TLS termination type, like `edge`, `passthrough` or `reencrypt`.
+ //
+ // Refer to the OpenShift route documentation for additional information.
+ TLSTermination string `property:"tls-termination" json:"tlsTermination,omitempty"`
+ // The TLS certificate contents.
+ //
+ // Refer to the OpenShift route documentation for additional information.
+ TLSCertificate string `property:"tls-certificate" json:"tlsCertificate,omitempty"`
+ // The secret name and key reference to the TLS certificate. The format is "secret-name[/key-name]", the value represents the secret name, if there is only one key in the secret it will be read, otherwise you can set a key name separated with a "/".
+ //
+ // Refer to the OpenShift route documentation for additional information.
+ TLSCertificateSecret string `property:"tls-certificate-secret" json:"tlsCertificateSecret,omitempty"`
+ // The TLS certificate key contents.
+ //
+ // Refer to the OpenShift route documentation for additional information.
+ TLSKey string `property:"tls-key" json:"tlsKey,omitempty"`
+ // The secret name and key reference to the TLS certificate key. The format is "secret-name[/key-name]", the value represents the secret name, if there is only one key in the secret it will be read, otherwise you can set a key name separated with a "/".
+ //
+ // Refer to the OpenShift route documentation for additional information.
+ TLSKeySecret string `property:"tls-key-secret" json:"tlsKeySecret,omitempty"`
+ // The TLS CA certificate contents.
+ //
+ // Refer to the OpenShift route documentation for additional information.
+ TLSCACertificate string `property:"tls-ca-certificate" json:"tlsCACertificate,omitempty"`
+ // The secret name and key reference to the TLS CA certificate. The format is "secret-name[/key-name]", the value represents the secret name, if there is only one key in the secret it will be read, otherwise you can set a key name separated with a "/".
+ //
+ // Refer to the OpenShift route documentation for additional information.
+ TLSCACertificateSecret string `property:"tls-ca-certificate-secret" json:"tlsCACertificateSecret,omitempty"`
+ // The destination CA certificate provides the contents of the ca certificate of the final destination. When using reencrypt
+ // termination this file should be provided in order to have routers use it for health checks on the secure connection.
+ // If this field is not specified, the router may provide its own destination CA and perform hostname validation using
+ // the short service name (service.namespace.svc), which allows infrastructure generated certificates to automatically
+ // verify.
+ //
+ // Refer to the OpenShift route documentation for additional information.
+ TLSDestinationCACertificate string `property:"tls-destination-ca-certificate" json:"tlsDestinationCACertificate,omitempty"`
+ // The secret name and key reference to the destination CA certificate. The format is "secret-name[/key-name]", the value represents the secret name, if there is only one key in the secret it will be read, otherwise you can set a key name separated with a "/".
+ //
+ // Refer to the OpenShift route documentation for additional information.
+ TLSDestinationCACertificateSecret string `property:"tls-destination-ca-certificate-secret" json:"tlsDestinationCACertificateSecret,omitempty"`
+ // To configure how to deal with insecure traffic, e.g. `Allow`, `Disable` or `Redirect` traffic.
+ //
+ // Refer to the OpenShift route documentation for additional information.
+ TLSInsecureEdgeTerminationPolicy string `property:"tls-insecure-edge-termination-policy" json:"tlsInsecureEdgeTerminationPolicy,omitempty"`
+}
diff --git a/pkg/util/test/trait.go b/pkg/apis/camel/v1/trait_service.go
similarity index 53%
copy from pkg/util/test/trait.go
copy to pkg/apis/camel/v1/trait_service.go
index 653194972..19e9951e1 100644
--- a/pkg/util/test/trait.go
+++ b/pkg/apis/camel/v1/trait_service.go
@@ -15,41 +15,18 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-package test
-
-import (
- "encoding/json"
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
-)
-
-func TraitSpecFromMap(t *testing.T, spec map[string]interface{}) v1.TraitSpec {
- t.Helper()
-
- var trait v1.TraitSpec
-
- data, err := json.Marshal(spec)
- assert.Nil(t, err)
-
- err = json.Unmarshal(data, &trait.Configuration)
- assert.Nil(t, err)
-
- return trait
-}
-
-func TraitSpecToMap(t *testing.T, spec v1.TraitSpec) map[string]string {
- t.Helper()
-
- trait := make(map[string]string)
-
- data, err := json.Marshal(spec.Configuration)
- assert.Nil(t, err)
-
- err = json.Unmarshal(data, &trait)
- assert.Nil(t, err)
-
- return trait
+package v1
+
+// The Service trait exposes the integration with a Service resource so that it can be accessed by other applications
+// (or integrations) in the same namespace.
+//
+// It's enabled by default if the integration depends on a Camel component that can expose a HTTP endpoint.
+//
+// +camel-k:trait=service.
+type ServiceTrait struct {
+ Trait `property:",squash" json:",inline"`
+ // To automatically detect from the code if a Service needs to be created.
+ Auto *bool `property:"auto" json:"auto,omitempty"`
+ // Enable Service to be exposed as NodePort (default `false`).
+ NodePort *bool `property:"node-port" json:"nodePort,omitempty"`
}
diff --git a/pkg/util/test/trait.go b/pkg/apis/camel/v1/trait_service_binding.go
similarity index 53%
rename from pkg/util/test/trait.go
rename to pkg/apis/camel/v1/trait_service_binding.go
index 653194972..55d533735 100644
--- a/pkg/util/test/trait.go
+++ b/pkg/apis/camel/v1/trait_service_binding.go
@@ -15,41 +15,15 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-package test
-
-import (
- "encoding/json"
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
-)
-
-func TraitSpecFromMap(t *testing.T, spec map[string]interface{}) v1.TraitSpec {
- t.Helper()
-
- var trait v1.TraitSpec
-
- data, err := json.Marshal(spec)
- assert.Nil(t, err)
-
- err = json.Unmarshal(data, &trait.Configuration)
- assert.Nil(t, err)
-
- return trait
-}
-
-func TraitSpecToMap(t *testing.T, spec v1.TraitSpec) map[string]string {
- t.Helper()
-
- trait := make(map[string]string)
-
- data, err := json.Marshal(spec.Configuration)
- assert.Nil(t, err)
-
- err = json.Unmarshal(data, &trait)
- assert.Nil(t, err)
-
- return trait
+package v1
+
+// The Service Binding trait allows users to connect to Services in Kubernetes:
+// https://github.com/k8s-service-bindings/spec#service-binding
+// As the specification is still evolving this is subject to change.
+//
+// +camel-k:trait=service-binding.
+type ServiceBindingTrait struct {
+ Trait `property:",squash" json:",inline"`
+ // List of Services in the form [[apigroup/]version:]kind:[namespace/]name
+ Services []string `property:"services" json:"services,omitempty"`
}
diff --git a/pkg/trait/toleration.go b/pkg/apis/camel/v1/trait_toleration.go
similarity index 59%
copy from pkg/trait/toleration.go
copy to pkg/apis/camel/v1/trait_toleration.go
index 925d53d78..839ee2755 100644
--- a/pkg/trait/toleration.go
+++ b/pkg/apis/camel/v1/trait_toleration.go
@@ -15,16 +15,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-package trait
-
-import (
- "fmt"
-
- corev1 "k8s.io/api/core/v1"
- "k8s.io/utils/pointer"
-
- "github.com/apache/camel-k/pkg/util/kubernetes"
-)
+package v1
// This trait sets Tolerations over Integration pods. Tolerations allow (but do not require) the pods to schedule onto nodes with matching taints.
// See https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/ for more details.
@@ -40,43 +31,8 @@ import (
// It's disabled by default.
//
// +camel-k:trait=toleration.
-type tolerationTrait struct {
- BaseTrait `property:",squash"`
+type TolerationTrait struct {
+ Trait `property:",squash" json:",inline"`
// The list of taints to tolerate, in the form `Key[=Value]:Effect[:Seconds]`
Taints []string `property:"taints" json:"taints,omitempty"`
}
-
-func newTolerationTrait() Trait {
- return &tolerationTrait{
- BaseTrait: NewBaseTrait("toleration", 1200),
- }
-}
-
-func (t *tolerationTrait) Configure(e *Environment) (bool, error) {
- if !pointer.BoolDeref(t.Enabled, false) {
- return false, nil
- }
-
- if len(t.Taints) == 0 {
- return false, fmt.Errorf("no taint was provided")
- }
-
- return e.IntegrationInRunningPhases(), nil
-}
-
-func (t *tolerationTrait) Apply(e *Environment) (err error) {
- tolerations, err := kubernetes.NewTolerations(t.Taints)
- if err != nil {
- return err
- }
- podSpec := e.GetIntegrationPodSpec()
-
- if podSpec == nil {
- return fmt.Errorf("could not find any integration deployment for %v", e.Integration.Name)
- }
- if podSpec.Tolerations == nil {
- podSpec.Tolerations = make([]corev1.Toleration, 0)
- }
- podSpec.Tolerations = append(podSpec.Tolerations, tolerations...)
- return nil
-}
diff --git a/pkg/apis/camel/v1/zz_generated.deepcopy.go b/pkg/apis/camel/v1/zz_generated.deepcopy.go
index 521ba3cce..683a3c02b 100644
--- a/pkg/apis/camel/v1/zz_generated.deepcopy.go
+++ b/pkg/apis/camel/v1/zz_generated.deepcopy.go
@@ -11,6 +11,47 @@ import (
"k8s.io/apimachinery/pkg/runtime"
)
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *AffinityTrait) DeepCopyInto(out *AffinityTrait) {
+ *out = *in
+ in.Trait.DeepCopyInto(&out.Trait)
+ if in.PodAffinity != nil {
+ in, out := &in.PodAffinity, &out.PodAffinity
+ *out = new(bool)
+ **out = **in
+ }
+ if in.PodAntiAffinity != nil {
+ in, out := &in.PodAntiAffinity, &out.PodAntiAffinity
+ *out = new(bool)
+ **out = **in
+ }
+ if in.NodeAffinityLabels != nil {
+ in, out := &in.NodeAffinityLabels, &out.NodeAffinityLabels
+ *out = make([]string, len(*in))
+ copy(*out, *in)
+ }
+ if in.PodAffinityLabels != nil {
+ in, out := &in.PodAffinityLabels, &out.PodAffinityLabels
+ *out = make([]string, len(*in))
+ copy(*out, *in)
+ }
+ if in.PodAntiAffinityLabels != nil {
+ in, out := &in.PodAntiAffinityLabels, &out.PodAntiAffinityLabels
+ *out = make([]string, len(*in))
+ copy(*out, *in)
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AffinityTrait.
+func (in *AffinityTrait) DeepCopy() *AffinityTrait {
+ if in == nil {
+ return nil
+ }
+ out := new(AffinityTrait)
+ in.DeepCopyInto(out)
+ return out
+}
+
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Artifact) DeepCopyInto(out *Artifact) {
*out = *in
@@ -240,6 +281,32 @@ func (in *BuilderTask) DeepCopy() *BuilderTask {
return out
}
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *BuilderTrait) DeepCopyInto(out *BuilderTrait) {
+ *out = *in
+ in.Trait.DeepCopyInto(&out.Trait)
+ if in.Verbose != nil {
+ in, out := &in.Verbose, &out.Verbose
+ *out = new(bool)
+ **out = **in
+ }
+ if in.Properties != nil {
+ in, out := &in.Properties, &out.Properties
+ *out = make([]string, len(*in))
+ copy(*out, *in)
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BuilderTrait.
+func (in *BuilderTrait) DeepCopy() *BuilderTrait {
+ if in == nil {
+ return nil
+ }
+ out := new(BuilderTrait)
+ in.DeepCopyInto(out)
+ return out
+}
+
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *CamelArtifact) DeepCopyInto(out *CamelArtifact) {
*out = *in
@@ -497,6 +564,27 @@ func (in *CamelSchemeScope) DeepCopy() *CamelSchemeScope {
return out
}
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *CamelTrait) DeepCopyInto(out *CamelTrait) {
+ *out = *in
+ in.Trait.DeepCopyInto(&out.Trait)
+ if in.Properties != nil {
+ in, out := &in.Properties, &out.Properties
+ *out = make([]string, len(*in))
+ copy(*out, *in)
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CamelTrait.
+func (in *CamelTrait) DeepCopy() *CamelTrait {
+ if in == nil {
+ return nil
+ }
+ out := new(CamelTrait)
+ in.DeepCopyInto(out)
+ return out
+}
+
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Capability) DeepCopyInto(out *Capability) {
*out = *in
@@ -539,6 +627,78 @@ func (in *ConfigurationSpec) DeepCopy() *ConfigurationSpec {
return out
}
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *ContainerTrait) DeepCopyInto(out *ContainerTrait) {
+ *out = *in
+ in.Trait.DeepCopyInto(&out.Trait)
+ if in.Auto != nil {
+ in, out := &in.Auto, &out.Auto
+ *out = new(bool)
+ **out = **in
+ }
+ if in.Expose != nil {
+ in, out := &in.Expose, &out.Expose
+ *out = new(bool)
+ **out = **in
+ }
+ if in.DeprecatedProbesEnabled != nil {
+ in, out := &in.DeprecatedProbesEnabled, &out.DeprecatedProbesEnabled
+ *out = new(bool)
+ **out = **in
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ContainerTrait.
+func (in *ContainerTrait) DeepCopy() *ContainerTrait {
+ if in == nil {
+ return nil
+ }
+ out := new(ContainerTrait)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *CronTrait) DeepCopyInto(out *CronTrait) {
+ *out = *in
+ in.Trait.DeepCopyInto(&out.Trait)
+ if in.Fallback != nil {
+ in, out := &in.Fallback, &out.Fallback
+ *out = new(bool)
+ **out = **in
+ }
+ if in.Auto != nil {
+ in, out := &in.Auto, &out.Auto
+ *out = new(bool)
+ **out = **in
+ }
+ if in.StartingDeadlineSeconds != nil {
+ in, out := &in.StartingDeadlineSeconds, &out.StartingDeadlineSeconds
+ *out = new(int64)
+ **out = **in
+ }
+ if in.ActiveDeadlineSeconds != nil {
+ in, out := &in.ActiveDeadlineSeconds, &out.ActiveDeadlineSeconds
+ *out = new(int64)
+ **out = **in
+ }
+ if in.BackoffLimit != nil {
+ in, out := &in.BackoffLimit, &out.BackoffLimit
+ *out = new(int32)
+ **out = **in
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CronTrait.
+func (in *CronTrait) DeepCopy() *CronTrait {
+ if in == nil {
+ return nil
+ }
+ out := new(CronTrait)
+ in.DeepCopyInto(out)
+ return out
+}
+
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *DataSpec) DeepCopyInto(out *DataSpec) {
*out = *in
@@ -559,6 +719,106 @@ func (in *DataSpec) DeepCopy() *DataSpec {
return out
}
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *DependenciesTrait) DeepCopyInto(out *DependenciesTrait) {
+ *out = *in
+ in.Trait.DeepCopyInto(&out.Trait)
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DependenciesTrait.
+func (in *DependenciesTrait) DeepCopy() *DependenciesTrait {
+ if in == nil {
+ return nil
+ }
+ out := new(DependenciesTrait)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *DeployerTrait) DeepCopyInto(out *DeployerTrait) {
+ *out = *in
+ in.Trait.DeepCopyInto(&out.Trait)
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeployerTrait.
+func (in *DeployerTrait) DeepCopy() *DeployerTrait {
+ if in == nil {
+ return nil
+ }
+ out := new(DeployerTrait)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *DeploymentTrait) DeepCopyInto(out *DeploymentTrait) {
+ *out = *in
+ in.Trait.DeepCopyInto(&out.Trait)
+ if in.ProgressDeadlineSeconds != nil {
+ in, out := &in.ProgressDeadlineSeconds, &out.ProgressDeadlineSeconds
+ *out = new(int32)
+ **out = **in
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeploymentTrait.
+func (in *DeploymentTrait) DeepCopy() *DeploymentTrait {
+ if in == nil {
+ return nil
+ }
+ out := new(DeploymentTrait)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *EnvironmentTrait) DeepCopyInto(out *EnvironmentTrait) {
+ *out = *in
+ in.Trait.DeepCopyInto(&out.Trait)
+ if in.ContainerMeta != nil {
+ in, out := &in.ContainerMeta, &out.ContainerMeta
+ *out = new(bool)
+ **out = **in
+ }
+ if in.HTTPProxy != nil {
+ in, out := &in.HTTPProxy, &out.HTTPProxy
+ *out = new(bool)
+ **out = **in
+ }
+ if in.Vars != nil {
+ in, out := &in.Vars, &out.Vars
+ *out = make([]string, len(*in))
+ copy(*out, *in)
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EnvironmentTrait.
+func (in *EnvironmentTrait) DeepCopy() *EnvironmentTrait {
+ if in == nil {
+ return nil
+ }
+ out := new(EnvironmentTrait)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *ErrorHandlerTrait) DeepCopyInto(out *ErrorHandlerTrait) {
+ *out = *in
+ in.Trait.DeepCopyInto(&out.Trait)
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ErrorHandlerTrait.
+func (in *ErrorHandlerTrait) DeepCopy() *ErrorHandlerTrait {
+ if in == nil {
+ return nil
+ }
+ out := new(ErrorHandlerTrait)
+ in.DeepCopyInto(out)
+ return out
+}
+
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Failure) DeepCopyInto(out *Failure) {
*out = *in
@@ -612,6 +872,74 @@ func (in *Flow) DeepCopy() *Flow {
return out
}
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *GCTrait) DeepCopyInto(out *GCTrait) {
+ *out = *in
+ in.Trait.DeepCopyInto(&out.Trait)
+ if in.DiscoveryCache != nil {
+ in, out := &in.DiscoveryCache, &out.DiscoveryCache
+ *out = new(DiscoveryCacheType)
+ **out = **in
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GCTrait.
+func (in *GCTrait) DeepCopy() *GCTrait {
+ if in == nil {
+ return nil
+ }
+ out := new(GCTrait)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *HealthTrait) DeepCopyInto(out *HealthTrait) {
+ *out = *in
+ in.Trait.DeepCopyInto(&out.Trait)
+ if in.LivenessProbeEnabled != nil {
+ in, out := &in.LivenessProbeEnabled, &out.LivenessProbeEnabled
+ *out = new(bool)
+ **out = **in
+ }
+ if in.ReadinessProbeEnabled != nil {
+ in, out := &in.ReadinessProbeEnabled, &out.ReadinessProbeEnabled
+ *out = new(bool)
+ **out = **in
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HealthTrait.
+func (in *HealthTrait) DeepCopy() *HealthTrait {
+ if in == nil {
+ return nil
+ }
+ out := new(HealthTrait)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *IngressTrait) DeepCopyInto(out *IngressTrait) {
+ *out = *in
+ in.Trait.DeepCopyInto(&out.Trait)
+ if in.Auto != nil {
+ in, out := &in.Auto, &out.Auto
+ *out = new(bool)
+ **out = **in
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IngressTrait.
+func (in *IngressTrait) DeepCopy() *IngressTrait {
+ if in == nil {
+ return nil
+ }
+ out := new(IngressTrait)
+ in.DeepCopyInto(out)
+ return out
+}
+
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Integration) DeepCopyInto(out *Integration) {
*out = *in
@@ -744,13 +1072,7 @@ func (in *IntegrationKitSpec) DeepCopyInto(out *IntegrationKitSpec) {
*out = make([]string, len(*in))
copy(*out, *in)
}
- if in.Traits != nil {
- in, out := &in.Traits, &out.Traits
- *out = make(map[string]TraitSpec, len(*in))
- for key, val := range *in {
- (*out)[key] = *val.DeepCopy()
- }
- }
+ in.Traits.DeepCopyInto(&out.Traits)
if in.Configuration != nil {
in, out := &in.Configuration, &out.Configuration
*out = make([]ConfigurationSpec, len(*in))
@@ -805,6 +1127,31 @@ func (in *IntegrationKitStatus) DeepCopy() *IntegrationKitStatus {
return out
}
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *IntegrationKitTraits) DeepCopyInto(out *IntegrationKitTraits) {
+ *out = *in
+ if in.Builder != nil {
+ in, out := &in.Builder, &out.Builder
+ *out = new(BuilderTrait)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.Quarkus != nil {
+ in, out := &in.Quarkus, &out.Quarkus
+ *out = new(QuarkusTrait)
+ (*in).DeepCopyInto(*out)
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IntegrationKitTraits.
+func (in *IntegrationKitTraits) DeepCopy() *IntegrationKitTraits {
+ if in == nil {
+ return nil
+ }
+ out := new(IntegrationKitTraits)
+ in.DeepCopyInto(out)
+ return out
+}
+
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *IntegrationList) DeepCopyInto(out *IntegrationList) {
*out = *in
@@ -1002,13 +1349,7 @@ func (in *IntegrationPlatformSpec) DeepCopyInto(out *IntegrationPlatformSpec) {
*out = *in
in.Build.DeepCopyInto(&out.Build)
out.Resources = in.Resources
- if in.Traits != nil {
- in, out := &in.Traits, &out.Traits
- *out = make(map[string]TraitSpec, len(*in))
- for key, val := range *in {
- (*out)[key] = *val.DeepCopy()
- }
- }
+ in.Traits.DeepCopyInto(&out.Traits)
if in.Configuration != nil {
in, out := &in.Configuration, &out.Configuration
*out = make([]ConfigurationSpec, len(*in))
@@ -1096,13 +1437,7 @@ func (in *IntegrationSpec) DeepCopyInto(out *IntegrationSpec) {
*out = make([]string, len(*in))
copy(*out, *in)
}
- if in.Traits != nil {
- in, out := &in.Traits, &out.Traits
- *out = make(map[string]TraitSpec, len(*in))
- for key, val := range *in {
- (*out)[key] = *val.DeepCopy()
- }
- }
+ in.Traits.DeepCopyInto(&out.Traits)
if in.PodTemplate != nil {
in, out := &in.PodTemplate, &out.PodTemplate
*out = new(PodSpecTemplate)
@@ -1196,12 +1531,156 @@ func (in *IntegrationStatus) DeepCopy() *IntegrationStatus {
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *KanikoTask) DeepCopyInto(out *KanikoTask) {
+func (in *IstioTrait) DeepCopyInto(out *IstioTrait) {
*out = *in
- out.BaseTask = in.BaseTask
- out.PublishTask = in.PublishTask
- if in.Verbose != nil {
- in, out := &in.Verbose, &out.Verbose
+ in.Trait.DeepCopyInto(&out.Trait)
+ if in.Inject != nil {
+ in, out := &in.Inject, &out.Inject
+ *out = new(bool)
+ **out = **in
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IstioTrait.
+func (in *IstioTrait) DeepCopy() *IstioTrait {
+ if in == nil {
+ return nil
+ }
+ out := new(IstioTrait)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *JVMTrait) DeepCopyInto(out *JVMTrait) {
+ *out = *in
+ in.Trait.DeepCopyInto(&out.Trait)
+ if in.Debug != nil {
+ in, out := &in.Debug, &out.Debug
+ *out = new(bool)
+ **out = **in
+ }
+ if in.DebugSuspend != nil {
+ in, out := &in.DebugSuspend, &out.DebugSuspend
+ *out = new(bool)
+ **out = **in
+ }
+ if in.PrintCommand != nil {
+ in, out := &in.PrintCommand, &out.PrintCommand
+ *out = new(bool)
+ **out = **in
+ }
+ if in.Options != nil {
+ in, out := &in.Options, &out.Options
+ *out = make([]string, len(*in))
+ copy(*out, *in)
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JVMTrait.
+func (in *JVMTrait) DeepCopy() *JVMTrait {
+ if in == nil {
+ return nil
+ }
+ out := new(JVMTrait)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *JolokiaTrait) DeepCopyInto(out *JolokiaTrait) {
+ *out = *in
+ in.Trait.DeepCopyInto(&out.Trait)
+ if in.CaCert != nil {
+ in, out := &in.CaCert, &out.CaCert
+ *out = new(string)
+ **out = **in
+ }
+ if in.ClientPrincipal != nil {
+ in, out := &in.ClientPrincipal, &out.ClientPrincipal
+ *out = make([]string, len(*in))
+ copy(*out, *in)
+ }
+ if in.DiscoveryEnabled != nil {
+ in, out := &in.DiscoveryEnabled, &out.DiscoveryEnabled
+ *out = new(bool)
+ **out = **in
+ }
+ if in.ExtendedClientCheck != nil {
+ in, out := &in.ExtendedClientCheck, &out.ExtendedClientCheck
+ *out = new(bool)
+ **out = **in
+ }
+ if in.Host != nil {
+ in, out := &in.Host, &out.Host
+ *out = new(string)
+ **out = **in
+ }
+ if in.Password != nil {
+ in, out := &in.Password, &out.Password
+ *out = new(string)
+ **out = **in
+ }
+ if in.Protocol != nil {
+ in, out := &in.Protocol, &out.Protocol
+ *out = new(string)
+ **out = **in
+ }
+ if in.User != nil {
+ in, out := &in.User, &out.User
+ *out = new(string)
+ **out = **in
+ }
+ if in.UseSslClientAuthentication != nil {
+ in, out := &in.UseSslClientAuthentication, &out.UseSslClientAuthentication
+ *out = new(bool)
+ **out = **in
+ }
+ if in.Options != nil {
+ in, out := &in.Options, &out.Options
+ *out = make([]string, len(*in))
+ copy(*out, *in)
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JolokiaTrait.
+func (in *JolokiaTrait) DeepCopy() *JolokiaTrait {
+ if in == nil {
+ return nil
+ }
+ out := new(JolokiaTrait)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *KameletsTrait) DeepCopyInto(out *KameletsTrait) {
+ *out = *in
+ in.Trait.DeepCopyInto(&out.Trait)
+ if in.Auto != nil {
+ in, out := &in.Auto, &out.Auto
+ *out = new(bool)
+ **out = **in
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KameletsTrait.
+func (in *KameletsTrait) DeepCopy() *KameletsTrait {
+ if in == nil {
+ return nil
+ }
+ out := new(KameletsTrait)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *KanikoTask) DeepCopyInto(out *KanikoTask) {
+ *out = *in
+ out.BaseTask = in.BaseTask
+ out.PublishTask = in.PublishTask
+ if in.Verbose != nil {
+ in, out := &in.Verbose, &out.Verbose
*out = new(bool)
**out = **in
}
@@ -1238,6 +1717,134 @@ func (in *KanikoTaskCache) DeepCopy() *KanikoTaskCache {
return out
}
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *KnativeServiceTrait) DeepCopyInto(out *KnativeServiceTrait) {
+ *out = *in
+ in.Trait.DeepCopyInto(&out.Trait)
+ if in.Target != nil {
+ in, out := &in.Target, &out.Target
+ *out = new(int)
+ **out = **in
+ }
+ if in.MinScale != nil {
+ in, out := &in.MinScale, &out.MinScale
+ *out = new(int)
+ **out = **in
+ }
+ if in.MaxScale != nil {
+ in, out := &in.MaxScale, &out.MaxScale
+ *out = new(int)
+ **out = **in
+ }
+ if in.Auto != nil {
+ in, out := &in.Auto, &out.Auto
+ *out = new(bool)
+ **out = **in
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KnativeServiceTrait.
+func (in *KnativeServiceTrait) DeepCopy() *KnativeServiceTrait {
+ if in == nil {
+ return nil
+ }
+ out := new(KnativeServiceTrait)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *KnativeTrait) DeepCopyInto(out *KnativeTrait) {
+ *out = *in
+ in.Trait.DeepCopyInto(&out.Trait)
+ if in.ChannelSources != nil {
+ in, out := &in.ChannelSources, &out.ChannelSources
+ *out = make([]string, len(*in))
+ copy(*out, *in)
+ }
+ if in.ChannelSinks != nil {
+ in, out := &in.ChannelSinks, &out.ChannelSinks
+ *out = make([]string, len(*in))
+ copy(*out, *in)
+ }
+ if in.EndpointSources != nil {
+ in, out := &in.EndpointSources, &out.EndpointSources
+ *out = make([]string, len(*in))
+ copy(*out, *in)
+ }
+ if in.EndpointSinks != nil {
+ in, out := &in.EndpointSinks, &out.EndpointSinks
+ *out = make([]string, len(*in))
+ copy(*out, *in)
+ }
+ if in.EventSources != nil {
+ in, out := &in.EventSources, &out.EventSources
+ *out = make([]string, len(*in))
+ copy(*out, *in)
+ }
+ if in.EventSinks != nil {
+ in, out := &in.EventSinks, &out.EventSinks
+ *out = make([]string, len(*in))
+ copy(*out, *in)
+ }
+ if in.FilterSourceChannels != nil {
+ in, out := &in.FilterSourceChannels, &out.FilterSourceChannels
+ *out = new(bool)
+ **out = **in
+ }
+ if in.SinkBinding != nil {
+ in, out := &in.SinkBinding, &out.SinkBinding
+ *out = new(bool)
+ **out = **in
+ }
+ if in.Auto != nil {
+ in, out := &in.Auto, &out.Auto
+ *out = new(bool)
+ **out = **in
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KnativeTrait.
+func (in *KnativeTrait) DeepCopy() *KnativeTrait {
+ if in == nil {
+ return nil
+ }
+ out := new(KnativeTrait)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *LoggingTrait) DeepCopyInto(out *LoggingTrait) {
+ *out = *in
+ in.Trait.DeepCopyInto(&out.Trait)
+ if in.Color != nil {
+ in, out := &in.Color, &out.Color
+ *out = new(bool)
+ **out = **in
+ }
+ if in.JSON != nil {
+ in, out := &in.JSON, &out.JSON
+ *out = new(bool)
+ **out = **in
+ }
+ if in.JSONPrettyPrint != nil {
+ in, out := &in.JSONPrettyPrint, &out.JSONPrettyPrint
+ *out = new(bool)
+ **out = **in
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LoggingTrait.
+func (in *LoggingTrait) DeepCopy() *LoggingTrait {
+ if in == nil {
+ return nil
+ }
+ out := new(LoggingTrait)
+ in.DeepCopyInto(out)
+ return out
+}
+
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *MavenArtifact) DeepCopyInto(out *MavenArtifact) {
*out = *in
@@ -1327,6 +1934,131 @@ func (in *MavenSpec) DeepCopy() *MavenSpec {
return out
}
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *MountTrait) DeepCopyInto(out *MountTrait) {
+ *out = *in
+ in.Trait.DeepCopyInto(&out.Trait)
+ if in.Configs != nil {
+ in, out := &in.Configs, &out.Configs
+ *out = make([]string, len(*in))
+ copy(*out, *in)
+ }
+ if in.Resources != nil {
+ in, out := &in.Resources, &out.Resources
+ *out = make([]string, len(*in))
+ copy(*out, *in)
+ }
+ if in.Volumes != nil {
+ in, out := &in.Volumes, &out.Volumes
+ *out = make([]string, len(*in))
+ copy(*out, *in)
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MountTrait.
+func (in *MountTrait) DeepCopy() *MountTrait {
+ if in == nil {
+ return nil
+ }
+ out := new(MountTrait)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *OpenAPITrait) DeepCopyInto(out *OpenAPITrait) {
+ *out = *in
+ in.Trait.DeepCopyInto(&out.Trait)
+ if in.Configmaps != nil {
+ in, out := &in.Configmaps, &out.Configmaps
+ *out = make([]string, len(*in))
+ copy(*out, *in)
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OpenAPITrait.
+func (in *OpenAPITrait) DeepCopy() *OpenAPITrait {
+ if in == nil {
+ return nil
+ }
+ out := new(OpenAPITrait)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *OwnerTrait) DeepCopyInto(out *OwnerTrait) {
+ *out = *in
+ in.Trait.DeepCopyInto(&out.Trait)
+ if in.TargetAnnotations != nil {
+ in, out := &in.TargetAnnotations, &out.TargetAnnotations
+ *out = make([]string, len(*in))
+ copy(*out, *in)
+ }
+ if in.TargetLabels != nil {
+ in, out := &in.TargetLabels, &out.TargetLabels
+ *out = make([]string, len(*in))
+ copy(*out, *in)
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OwnerTrait.
+func (in *OwnerTrait) DeepCopy() *OwnerTrait {
+ if in == nil {
+ return nil
+ }
+ out := new(OwnerTrait)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *PDBTrait) DeepCopyInto(out *PDBTrait) {
+ *out = *in
+ in.Trait.DeepCopyInto(&out.Trait)
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PDBTrait.
+func (in *PDBTrait) DeepCopy() *PDBTrait {
+ if in == nil {
+ return nil
+ }
+ out := new(PDBTrait)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *PlatformTrait) DeepCopyInto(out *PlatformTrait) {
+ *out = *in
+ in.Trait.DeepCopyInto(&out.Trait)
+ if in.CreateDefault != nil {
+ in, out := &in.CreateDefault, &out.CreateDefault
+ *out = new(bool)
+ **out = **in
+ }
+ if in.Global != nil {
+ in, out := &in.Global, &out.Global
+ *out = new(bool)
+ **out = **in
+ }
+ if in.Auto != nil {
+ in, out := &in.Auto, &out.Auto
+ *out = new(bool)
+ **out = **in
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PlatformTrait.
+func (in *PlatformTrait) DeepCopy() *PlatformTrait {
+ if in == nil {
+ return nil
+ }
+ out := new(PlatformTrait)
+ in.DeepCopyInto(out)
+ return out
+}
+
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *PodSpec) DeepCopyInto(out *PodSpec) {
*out = *in
@@ -1411,6 +2143,48 @@ func (in *PodSpecTemplate) DeepCopy() *PodSpecTemplate {
return out
}
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *PodTrait) DeepCopyInto(out *PodTrait) {
+ *out = *in
+ in.Trait.DeepCopyInto(&out.Trait)
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodTrait.
+func (in *PodTrait) DeepCopy() *PodTrait {
+ if in == nil {
+ return nil
+ }
+ out := new(PodTrait)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *PrometheusTrait) DeepCopyInto(out *PrometheusTrait) {
+ *out = *in
+ in.Trait.DeepCopyInto(&out.Trait)
+ if in.PodMonitor != nil {
+ in, out := &in.PodMonitor, &out.PodMonitor
+ *out = new(bool)
+ **out = **in
+ }
+ if in.PodMonitorLabels != nil {
+ in, out := &in.PodMonitorLabels, &out.PodMonitorLabels
+ *out = make([]string, len(*in))
+ copy(*out, *in)
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PrometheusTrait.
+func (in *PrometheusTrait) DeepCopy() *PrometheusTrait {
+ if in == nil {
+ return nil
+ }
+ out := new(PrometheusTrait)
+ in.DeepCopyInto(out)
+ return out
+}
+
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in Properties) DeepCopyInto(out *Properties) {
{
@@ -1448,6 +2222,53 @@ func (in *PublishTask) DeepCopy() *PublishTask {
return out
}
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *PullSecretTrait) DeepCopyInto(out *PullSecretTrait) {
+ *out = *in
+ in.Trait.DeepCopyInto(&out.Trait)
+ if in.ImagePullerDelegation != nil {
+ in, out := &in.ImagePullerDelegation, &out.ImagePullerDelegation
+ *out = new(bool)
+ **out = **in
+ }
+ if in.Auto != nil {
+ in, out := &in.Auto, &out.Auto
+ *out = new(bool)
+ **out = **in
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PullSecretTrait.
+func (in *PullSecretTrait) DeepCopy() *PullSecretTrait {
+ if in == nil {
+ return nil
+ }
+ out := new(PullSecretTrait)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *QuarkusTrait) DeepCopyInto(out *QuarkusTrait) {
+ *out = *in
+ in.Trait.DeepCopyInto(&out.Trait)
+ if in.PackageTypes != nil {
+ in, out := &in.PackageTypes, &out.PackageTypes
+ *out = make([]QuarkusPackageType, len(*in))
+ copy(*out, *in)
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new QuarkusTrait.
+func (in *QuarkusTrait) DeepCopy() *QuarkusTrait {
+ if in == nil {
+ return nil
+ }
+ out := new(QuarkusTrait)
+ in.DeepCopyInto(out)
+ return out
+}
+
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in RawMessage) DeepCopyInto(out *RawMessage) {
{
@@ -1482,6 +2303,22 @@ func (in *RegistrySpec) DeepCopy() *RegistrySpec {
return out
}
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *RegistryTrait) DeepCopyInto(out *RegistryTrait) {
+ *out = *in
+ in.Trait.DeepCopyInto(&out.Trait)
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RegistryTrait.
+func (in *RegistryTrait) DeepCopy() *RegistryTrait {
+ if in == nil {
+ return nil
+ }
+ out := new(RegistryTrait)
+ in.DeepCopyInto(out)
+ return out
+}
+
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Repository) DeepCopyInto(out *Repository) {
*out = *in
@@ -1530,6 +2367,22 @@ func (in *ResourceSpec) DeepCopy() *ResourceSpec {
return out
}
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *RouteTrait) DeepCopyInto(out *RouteTrait) {
+ *out = *in
+ in.Trait.DeepCopyInto(&out.Trait)
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RouteTrait.
+func (in *RouteTrait) DeepCopy() *RouteTrait {
+ if in == nil {
+ return nil
+ }
+ out := new(RouteTrait)
+ in.DeepCopyInto(out)
+ return out
+}
+
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *RuntimeSpec) DeepCopyInto(out *RuntimeSpec) {
*out = *in
@@ -1603,6 +2456,53 @@ func (in *Server) DeepCopy() *Server {
return out
}
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *ServiceBindingTrait) DeepCopyInto(out *ServiceBindingTrait) {
+ *out = *in
+ in.Trait.DeepCopyInto(&out.Trait)
+ if in.Services != nil {
+ in, out := &in.Services, &out.Services
+ *out = make([]string, len(*in))
+ copy(*out, *in)
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceBindingTrait.
+func (in *ServiceBindingTrait) DeepCopy() *ServiceBindingTrait {
+ if in == nil {
+ return nil
+ }
+ out := new(ServiceBindingTrait)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *ServiceTrait) DeepCopyInto(out *ServiceTrait) {
+ *out = *in
+ in.Trait.DeepCopyInto(&out.Trait)
+ if in.Auto != nil {
+ in, out := &in.Auto, &out.Auto
+ *out = new(bool)
+ **out = **in
+ }
+ if in.NodePort != nil {
+ in, out := &in.NodePort, &out.NodePort
+ *out = new(bool)
+ **out = **in
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceTrait.
+func (in *ServiceTrait) DeepCopy() *ServiceTrait {
+ if in == nil {
+ return nil
+ }
+ out := new(ServiceTrait)
+ in.DeepCopyInto(out)
+ return out
+}
+
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *SourceSpec) DeepCopyInto(out *SourceSpec) {
*out = *in
@@ -1687,37 +2587,222 @@ func (in *Task) DeepCopy() *Task {
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *TraitConfiguration) DeepCopyInto(out *TraitConfiguration) {
+func (in *TolerationTrait) DeepCopyInto(out *TolerationTrait) {
*out = *in
- if in.RawMessage != nil {
- in, out := &in.RawMessage, &out.RawMessage
- *out = make(RawMessage, len(*in))
+ in.Trait.DeepCopyInto(&out.Trait)
+ if in.Taints != nil {
+ in, out := &in.Taints, &out.Taints
+ *out = make([]string, len(*in))
copy(*out, *in)
}
}
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TraitConfiguration.
-func (in *TraitConfiguration) DeepCopy() *TraitConfiguration {
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TolerationTrait.
+func (in *TolerationTrait) DeepCopy() *TolerationTrait {
if in == nil {
return nil
}
- out := new(TraitConfiguration)
+ out := new(TolerationTrait)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *TraitSpec) DeepCopyInto(out *TraitSpec) {
+func (in *Trait) DeepCopyInto(out *Trait) {
*out = *in
- in.Configuration.DeepCopyInto(&out.Configuration)
+ if in.Enabled != nil {
+ in, out := &in.Enabled, &out.Enabled
+ *out = new(bool)
+ **out = **in
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Trait.
+func (in *Trait) DeepCopy() *Trait {
+ if in == nil {
+ return nil
+ }
+ out := new(Trait)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *Traits) DeepCopyInto(out *Traits) {
+ *out = *in
+ if in.Affinity != nil {
+ in, out := &in.Affinity, &out.Affinity
+ *out = new(AffinityTrait)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.Builder != nil {
+ in, out := &in.Builder, &out.Builder
+ *out = new(BuilderTrait)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.Camel != nil {
+ in, out := &in.Camel, &out.Camel
+ *out = new(CamelTrait)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.Container != nil {
+ in, out := &in.Container, &out.Container
+ *out = new(ContainerTrait)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.Cron != nil {
+ in, out := &in.Cron, &out.Cron
+ *out = new(CronTrait)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.Dependencies != nil {
+ in, out := &in.Dependencies, &out.Dependencies
+ *out = new(DependenciesTrait)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.Deployer != nil {
+ in, out := &in.Deployer, &out.Deployer
+ *out = new(DeployerTrait)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.Deployment != nil {
+ in, out := &in.Deployment, &out.Deployment
+ *out = new(DeploymentTrait)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.Environment != nil {
+ in, out := &in.Environment, &out.Environment
+ *out = new(EnvironmentTrait)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.ErrorHandler != nil {
+ in, out := &in.ErrorHandler, &out.ErrorHandler
+ *out = new(ErrorHandlerTrait)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.GC != nil {
+ in, out := &in.GC, &out.GC
+ *out = new(GCTrait)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.Health != nil {
+ in, out := &in.Health, &out.Health
+ *out = new(HealthTrait)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.Ingress != nil {
+ in, out := &in.Ingress, &out.Ingress
+ *out = new(IngressTrait)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.Istio != nil {
+ in, out := &in.Istio, &out.Istio
+ *out = new(IstioTrait)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.Jolokia != nil {
+ in, out := &in.Jolokia, &out.Jolokia
+ *out = new(JolokiaTrait)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.JVM != nil {
+ in, out := &in.JVM, &out.JVM
+ *out = new(JVMTrait)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.Knative != nil {
+ in, out := &in.Knative, &out.Knative
+ *out = new(KnativeTrait)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.KnativeService != nil {
+ in, out := &in.KnativeService, &out.KnativeService
+ *out = new(KnativeServiceTrait)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.Logging != nil {
+ in, out := &in.Logging, &out.Logging
+ *out = new(LoggingTrait)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.Mount != nil {
+ in, out := &in.Mount, &out.Mount
+ *out = new(MountTrait)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.OpenAPI != nil {
+ in, out := &in.OpenAPI, &out.OpenAPI
+ *out = new(OpenAPITrait)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.Owner != nil {
+ in, out := &in.Owner, &out.Owner
+ *out = new(OwnerTrait)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.PDB != nil {
+ in, out := &in.PDB, &out.PDB
+ *out = new(PDBTrait)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.Platform != nil {
+ in, out := &in.Platform, &out.Platform
+ *out = new(PlatformTrait)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.Pod != nil {
+ in, out := &in.Pod, &out.Pod
+ *out = new(PodTrait)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.Prometheus != nil {
+ in, out := &in.Prometheus, &out.Prometheus
+ *out = new(PrometheusTrait)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.PullSecret != nil {
+ in, out := &in.PullSecret, &out.PullSecret
+ *out = new(PullSecretTrait)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.Quarkus != nil {
+ in, out := &in.Quarkus, &out.Quarkus
+ *out = new(QuarkusTrait)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.Registry != nil {
+ in, out := &in.Registry, &out.Registry
+ *out = new(RegistryTrait)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.Route != nil {
+ in, out := &in.Route, &out.Route
+ *out = new(RouteTrait)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.Service != nil {
+ in, out := &in.Service, &out.Service
+ *out = new(ServiceTrait)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.ServiceBinding != nil {
+ in, out := &in.ServiceBinding, &out.ServiceBinding
+ *out = new(ServiceBindingTrait)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.Toleration != nil {
+ in, out := &in.Toleration, &out.Toleration
+ *out = new(TolerationTrait)
+ (*in).DeepCopyInto(*out)
+ }
}
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TraitSpec.
-func (in *TraitSpec) DeepCopy() *TraitSpec {
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Traits.
+func (in *Traits) DeepCopy() *Traits {
if in == nil {
return nil
}
- out := new(TraitSpec)
+ out := new(Traits)
in.DeepCopyInto(out)
return out
}
diff --git a/pkg/cmd/bind.go b/pkg/cmd/bind.go
index 6a3073861..a5eac817e 100644
--- a/pkg/cmd/bind.go
+++ b/pkg/cmd/bind.go
@@ -158,7 +158,6 @@ func (o *bindCmdOptions) run(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
- catalog := trait.NewCatalog(client)
source, err := o.decode(args[0], sourceKey)
if err != nil {
@@ -210,11 +209,9 @@ func (o *bindCmdOptions) run(cmd *cobra.Command, args []string) error {
if binding.Spec.Integration == nil {
binding.Spec.Integration = &v1.IntegrationSpec{}
}
- traits, err := configureTraits(o.Traits, catalog)
- if err != nil {
+ if err := configureTraits(o.Traits, &binding.Spec.Integration.Traits); err != nil {
return err
}
- binding.Spec.Integration.Traits = traits
}
if o.OutputFormat != "" {
diff --git a/pkg/cmd/bind_test.go b/pkg/cmd/bind_test.go
index 72600ab6b..aa5778a5c 100644
--- a/pkg/cmd/bind_test.go
+++ b/pkg/cmd/bind_test.go
@@ -174,13 +174,11 @@ spec:
integration:
traits:
mount:
- configuration:
- configs:
- - configmap:my-cm
+ configs:
+ - configmap:my-cm
service-binding:
- configuration:
- services:
- - my-service-binding
+ services:
+ - my-service-binding
sink:
uri: my:dst
source:
diff --git a/pkg/cmd/debug.go b/pkg/cmd/debug.go
index 209927241..35f6c16f3 100644
--- a/pkg/cmd/debug.go
+++ b/pkg/cmd/debug.go
@@ -18,7 +18,6 @@ limitations under the License.
package cmd
import (
- "encoding/json"
"fmt"
"os"
"os/signal"
@@ -32,6 +31,7 @@ import (
"github.com/spf13/cobra"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+ "k8s.io/utils/pointer"
)
func newCmdDebug(rootCmdOptions *RootCmdOptions) (*cobra.Command, *debugCmdOptions) {
@@ -133,30 +133,18 @@ func (o *debugCmdOptions) run(cmd *cobra.Command, args []string) error {
// nolint: unparam
func (o *debugCmdOptions) toggleDebug(c camelv1.IntegrationsGetter, it *v1.Integration, active bool) (*v1.Integration, error) {
- if it.Spec.Traits == nil {
- it.Spec.Traits = make(map[string]v1.TraitSpec)
- }
- traitSpec := it.Spec.Traits["jvm"]
- jvmConfig := make(map[string]interface{})
- if len(traitSpec.Configuration.RawMessage) > 0 {
- if err := json.Unmarshal(traitSpec.Configuration.RawMessage, &jvmConfig); err != nil {
- return it, err
- }
+ if it.Spec.Traits.JVM == nil {
+ it.Spec.Traits.JVM = &v1.JVMTrait{}
}
+ jvmTrait := it.Spec.Traits.JVM
+
if active {
- jvmConfig["debug"] = true
- jvmConfig["debugSuspend"] = o.Suspend
+ jvmTrait.Debug = pointer.Bool(true)
+ jvmTrait.DebugSuspend = pointer.Bool(o.Suspend)
} else {
- delete(jvmConfig, "debug")
- delete(jvmConfig, "debugSuspend")
- }
-
- jvmConfigBytes, err := json.Marshal(jvmConfig)
- if err != nil {
- return it, err
+ jvmTrait.Debug = nil
+ jvmTrait.DebugSuspend = nil
}
- traitSpec.Configuration.RawMessage = jvmConfigBytes
- it.Spec.Traits["jvm"] = traitSpec
return c.Integrations(it.Namespace).Update(o.Context, it, metav1.UpdateOptions{})
}
diff --git a/pkg/cmd/describe.go b/pkg/cmd/describe.go
index 5471c091c..44e119f8e 100644
--- a/pkg/cmd/describe.go
+++ b/pkg/cmd/describe.go
@@ -18,7 +18,6 @@ limitations under the License.
package cmd
import (
- "encoding/json"
"strings"
"time"
@@ -26,7 +25,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
- v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
+ "github.com/apache/camel-k/pkg/trait"
"github.com/apache/camel-k/pkg/util/indentedwriter"
)
@@ -51,23 +50,19 @@ func describeObjectMeta(w *indentedwriter.Writer, om metav1.ObjectMeta) {
w.Writef(0, "Creation Timestamp:\t%s\n", om.CreationTimestamp.Format(time.RFC1123Z))
}
-func describeTraits(w *indentedwriter.Writer, traits map[string]v1.TraitSpec) error {
- if len(traits) > 0 {
+func describeTraits(w *indentedwriter.Writer, traits interface{}) error {
+ traitsMap, err := trait.ToMap(traits)
+ if err != nil {
+ return err
+ }
+
+ if len(traitsMap) > 0 {
w.Writef(0, "Traits:\n")
- for trait := range traits {
- w.Writef(1, "%s:\n", strings.Title(trait))
+ for id, trait := range traitsMap {
+ w.Writef(1, "%s:\n", strings.Title(id))
// TODO: print the whole TraitSpec as Yaml
- data, err := json.Marshal(traits[trait])
- if err != nil {
- return err
- }
- config := make(map[string]interface{})
- err = json.Unmarshal(data, &config)
- if err != nil {
- return err
- }
- for k, v := range config {
+ for k, v := range trait {
w.Writef(2, "%s:\t%v\n", strings.Title(k), v)
}
}
diff --git a/pkg/cmd/kit_create.go b/pkg/cmd/kit_create.go
index 512c17dc4..0979cf18e 100644
--- a/pkg/cmd/kit_create.go
+++ b/pkg/cmd/kit_create.go
@@ -157,7 +157,7 @@ func (command *kitCreateCommandOptions) run(cmd *cobra.Command, args []string) e
if err := command.parseAndConvertToTrait(command.Secrets, "mount.config"); err != nil {
return err
}
- if err := command.configureTraits(kit, command.Traits, catalog); err != nil {
+ if err := configureTraits(command.Traits, &kit.Spec.Traits); err != nil {
return err
}
existed := false
@@ -188,16 +188,6 @@ func (command *kitCreateCommandOptions) run(cmd *cobra.Command, args []string) e
return nil
}
-func (*kitCreateCommandOptions) configureTraits(kit *v1.IntegrationKit, options []string, catalog trait.Finder) error {
- traits, err := configureTraits(options, catalog)
- if err != nil {
- return err
- }
-
- kit.Spec.Traits = traits
-
- return nil
-}
func (command *kitCreateCommandOptions) parseAndConvertToTrait(params []string, traitParam string) error {
for _, param := range params {
command.Traits = append(command.Traits, convertToTrait(param, traitParam))
diff --git a/pkg/cmd/run.go b/pkg/cmd/run.go
index ae9e3384c..e78f484ab 100644
--- a/pkg/cmd/run.go
+++ b/pkg/cmd/run.go
@@ -669,11 +669,9 @@ func (o *runCmdOptions) createOrUpdateIntegration(cmd *cobra.Command, c client.C
o.Traits = append(o.Traits, fmt.Sprintf("service-binding.services=%s", item))
}
if len(o.Traits) > 0 {
- traits, err := configureTraits(o.Traits, catalog)
- if err != nil {
+ if err := configureTraits(o.Traits, &integration.Spec.Traits); err != nil {
return nil, err
}
- integration.Spec.Traits = traits
}
if o.OutputFormat != "" {
diff --git a/pkg/cmd/run_test.go b/pkg/cmd/run_test.go
index 5e386c62e..f5c1dd350 100644
--- a/pkg/cmd/run_test.go
+++ b/pkg/cmd/run_test.go
@@ -360,21 +360,26 @@ func TestConfigureTraits(t *testing.T) {
if err != nil {
t.Error(err)
}
- client, err := runCmdOptions.GetCmdClient()
- if err != nil {
- t.Error(err)
- }
- catalog := trait.NewCatalog(client)
- traits, err := configureTraits(runCmdOptions.Traits, catalog)
+ traits := v1.Traits{}
+ err = configureTraits(runCmdOptions.Traits, &traits)
assert.Nil(t, err)
- assert.Len(t, traits, 5)
- assertTraitConfiguration(t, traits, "affinity", `{"podAffinity":false}`)
- assertTraitConfiguration(t, traits, "container", `{"probesEnabled":false}`)
- assertTraitConfiguration(t, traits, "environment", `{"containerMeta":false}`)
- assertTraitConfiguration(t, traits, "jvm", `{"printCommand":false}`)
- assertTraitConfiguration(t, traits, "prometheus", `{"podMonitor":false}`)
+ traitsMap, err := trait.ToMap(traits)
+ assert.Nil(t, err)
+ assert.Len(t, traitsMap, 5)
+ assertTraitConfiguration(t, traits.Affinity, &v1.AffinityTrait{PodAffinity: pointer.Bool(false)})
+ assertTraitConfiguration(t, traits.Container, &v1.ContainerTrait{DeprecatedProbesEnabled: pointer.Bool(false)})
+ assertTraitConfiguration(t, traits.Environment, &v1.EnvironmentTrait{ContainerMeta: pointer.Bool(false)})
+ assertTraitConfiguration(t, traits.JVM, &v1.JVMTrait{PrintCommand: pointer.Bool(false)})
+ assertTraitConfiguration(t, traits.Prometheus, &v1.PrometheusTrait{PodMonitor: pointer.Bool(false)})
+}
+
+func assertTraitConfiguration(t *testing.T, trait interface{}, expected interface{}) {
+ t.Helper()
+
+ assert.NotNil(t, trait)
+ assert.Equal(t, expected, trait)
}
type customTrait struct {
@@ -404,35 +409,6 @@ func (finder customTraitFinder) GetTrait(id string) trait.Trait {
return nil
}
-func TestTraitsNestedConfig(t *testing.T) {
- runCmdOptions, rootCmd, _ := initializeRunCmdOptions(t)
- _, err := test.ExecuteCommand(rootCmd, "run",
- "--trait", "custom.simple-map.a=b",
- "--trait", "custom.simple-map.y=z",
- "--trait", "custom.double-map.m.n=q",
- "--trait", "custom.double-map.m.o=w",
- "--trait", "custom.slice-of-map[0].f=g",
- "--trait", "custom.slice-of-map[3].f=h",
- "--trait", "custom.slice-of-map[2].f=i",
- "example.js")
- // We will have an error because those traits are not existing
- // however we want to test how those properties are mapped in the configuration
- assert.NotNil(t, err)
- catalog := &customTraitFinder{}
- traits, err := configureTraits(runCmdOptions.Traits, catalog)
-
- assert.Nil(t, err)
- assert.Len(t, traits, 1)
- assertTraitConfiguration(t, traits, "custom", `{"simpleMap":{"a":"b","y":"z"},"doubleMap":{"m":{"n":"q","o":"w"}},"sliceOfMap":[{"f":"g"},null,{"f":"i"},{"f":"h"}]}`)
-}
-
-func assertTraitConfiguration(t *testing.T, traits map[string]v1.TraitSpec, trait string, expected string) {
- t.Helper()
-
- assert.Contains(t, traits, trait)
- assert.Equal(t, expected, string(traits[trait].Configuration.RawMessage))
-}
-
func TestRunUseFlowsFlag(t *testing.T) {
runCmdOptions, rootCmd, _ := initializeRunCmdOptions(t)
_, err := test.ExecuteCommand(rootCmd, cmdRun, "--use-flows=false", integrationSource)
@@ -617,6 +593,7 @@ spec:
extends RouteBuilder {\n @Override\n public void configure() throws Exception
{\n\t from(\"timer:tick\")\n .log(\"Hello Camel K!\");\n }\n}\n"
name: %s
+ traits: {}
status: {}
`, fileName, fileName), output)
}
@@ -650,13 +627,11 @@ spec:
name: %s
traits:
mount:
- configuration:
- configs:
- - configmap:my-cm
+ configs:
+ - configmap:my-cm
service-binding:
- configuration:
- services:
- - my-service-binding
+ services:
+ - my-service-binding
status: {}
`, fileName, fileName), output)
}
diff --git a/pkg/cmd/trait_support.go b/pkg/cmd/trait_support.go
index 63fa23b9c..4d134a3a5 100644
--- a/pkg/cmd/trait_support.go
+++ b/pkg/cmd/trait_support.go
@@ -18,13 +18,10 @@ limitations under the License.
package cmd
import (
- "encoding/json"
"errors"
"fmt"
- "reflect"
"strings"
- v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
"github.com/apache/camel-k/pkg/trait"
"github.com/apache/camel-k/pkg/util"
"github.com/mitchellh/mapstructure"
@@ -46,32 +43,32 @@ func validateTraits(catalog *trait.Catalog, traits []string) error {
return nil
}
-func configureTraits(options []string, catalog trait.Finder) (map[string]v1.TraitSpec, error) {
- traits := make(map[string]map[string]interface{})
+func configureTraits(options []string, traits interface{}) error {
+ config := make(map[string]map[string]interface{})
for _, option := range options {
parts := traitConfigRegexp.FindStringSubmatch(option)
if len(parts) < 4 {
- return nil, errors.New("unrecognized config format (expected \"<trait>.<prop>=<value>\"): " + option)
+ return errors.New("unrecognized config format (expected \"<trait>.<prop>=<value>\"): " + option)
}
id := parts[1]
fullProp := parts[2][1:]
value := parts[3]
- if _, ok := traits[id]; !ok {
- traits[id] = make(map[string]interface{})
+ if _, ok := config[id]; !ok {
+ config[id] = make(map[string]interface{})
}
propParts := util.ConfigTreePropertySplit(fullProp)
- var current = traits[id]
+ var current = config[id]
if len(propParts) > 1 {
c, err := util.NavigateConfigTree(current, propParts[0:len(propParts)-1])
if err != nil {
- return nil, err
+ return err
}
if cc, ok := c.(map[string]interface{}); ok {
current = cc
} else {
- return nil, errors.New("trait configuration cannot end with a slice")
+ return errors.New("trait configuration cannot end with a slice")
}
}
@@ -91,41 +88,13 @@ func configureTraits(options []string, catalog trait.Finder) (map[string]v1.Trai
}
}
- specs := make(map[string]v1.TraitSpec)
- for id, config := range traits {
- t := catalog.GetTrait(id)
- if t != nil {
- // let's take a clone to prevent default values set at runtime from being serialized
- zero := reflect.New(reflect.TypeOf(t)).Interface()
- err := configureTrait(config, zero)
- if err != nil {
- return nil, err
- }
- data, err := json.Marshal(zero)
- if err != nil {
- return nil, err
- }
- var spec v1.TraitSpec
- err = json.Unmarshal(data, &spec.Configuration)
- if err != nil {
- return nil, err
- }
- specs[id] = spec
- }
- }
-
- return specs, nil
-}
-
-func configureTrait(config map[string]interface{}, trait interface{}) error {
md := mapstructure.Metadata{}
-
decoder, err := mapstructure.NewDecoder(
&mapstructure.DecoderConfig{
Metadata: &md,
WeaklyTypedInput: true,
TagName: "property",
- Result: &trait,
+ Result: &traits,
},
)
if err != nil {
diff --git a/pkg/controller/integration/kits.go b/pkg/controller/integration/kits.go
index 283104065..5e8c97f4a 100644
--- a/pkg/controller/integration/kits.go
+++ b/pkg/controller/integration/kits.go
@@ -19,7 +19,6 @@ package integration
import (
"context"
- "encoding/json"
"reflect"
"k8s.io/apimachinery/pkg/api/errors"
@@ -87,26 +86,10 @@ func integrationMatches(integration *v1.Integration, kit *v1.IntegrationKit) (bo
ilog := log.ForIntegration(integration)
ilog.Debug("Matching integration", "integration", integration.Name, "integration-kit", kit.Name, "namespace", integration.Namespace)
- if kit.Status.Phase == v1.IntegrationKitPhaseError {
- ilog.Debug("Integration kit has a phase of Error", "integration-kit", kit.Name, "namespace", integration.Namespace)
- return false, nil
- }
- if kit.Status.Version != integration.Status.Version {
- ilog.Debug("Integration and integration-kit versions do not match", "integration", integration.Name, "integration-kit", kit.Name, "namespace", integration.Namespace)
- return false, nil
- }
- if kit.Status.RuntimeProvider != integration.Status.RuntimeProvider {
- ilog.Debug("Integration and integration-kit runtime providers do not match", "integration", integration.Name, "integration-kit", kit.Name, "namespace", integration.Namespace)
- return false, nil
- }
- if kit.Status.RuntimeVersion != integration.Status.RuntimeVersion {
- ilog.Debug("Integration and integration-kit runtime versions do not match", "integration", integration.Name, "integration-kit", kit.Name, "namespace", integration.Namespace)
- return false, nil
- }
- if len(integration.Status.Dependencies) != len(kit.Spec.Dependencies) {
- ilog.Debug("Integration and integration-kit have different number of dependencies", "integration", integration.Name, "integration-kit", kit.Name, "namespace", integration.Namespace)
+ if !statusMatches(integration, kit, &ilog) {
return false, nil
}
+
// When a platform kit is created it inherits the traits from the integrations and as
// some traits may influence the build thus the artifacts present on the container image,
// we need to take traits into account when looking up for compatible kits.
@@ -130,6 +113,30 @@ func integrationMatches(integration *v1.Integration, kit *v1.IntegrationKit) (bo
return true, nil
}
+func statusMatches(integration *v1.Integration, kit *v1.IntegrationKit, ilog *log.Logger) bool {
+ if kit.Status.Phase == v1.IntegrationKitPhaseError {
+ ilog.Debug("Integration kit has a phase of Error", "integration-kit", kit.Name, "namespace", integration.Namespace)
+ return false
+ }
+ if kit.Status.Version != integration.Status.Version {
+ ilog.Debug("Integration and integration-kit versions do not match", "integration", integration.Name, "integration-kit", kit.Name, "namespace", integration.Namespace)
+ return false
+ }
+ if kit.Status.RuntimeProvider != integration.Status.RuntimeProvider {
+ ilog.Debug("Integration and integration-kit runtime providers do not match", "integration", integration.Name, "integration-kit", kit.Name, "namespace", integration.Namespace)
+ return false
+ }
+ if kit.Status.RuntimeVersion != integration.Status.RuntimeVersion {
+ ilog.Debug("Integration and integration-kit runtime versions do not match", "integration", integration.Name, "integration-kit", kit.Name, "namespace", integration.Namespace)
+ return false
+ }
+ if len(integration.Status.Dependencies) != len(kit.Spec.Dependencies) {
+ ilog.Debug("Integration and integration-kit have different number of dependencies", "integration", integration.Name, "integration-kit", kit.Name, "namespace", integration.Namespace)
+ }
+
+ return true
+}
+
// kitMatches returns whether the two v1.IntegrationKit match.
func kitMatches(kit1 *v1.IntegrationKit, kit2 *v1.IntegrationKit) (bool, error) {
version := kit1.Status.Version
@@ -149,132 +156,66 @@ func kitMatches(kit1 *v1.IntegrationKit, kit2 *v1.IntegrationKit) (bool, error)
if !util.StringSliceContains(kit1.Spec.Dependencies, kit2.Spec.Dependencies) {
return false, nil
}
+
return true, nil
}
-func hasMatchingTraits(traits1 map[string]v1.TraitSpec, traits2 map[string]v1.TraitSpec) (bool, error) {
+func hasMatchingTraits(traits interface{}, kitTraits interface{}) (bool, error) {
+ traitsMap, err := trait.ToMap(traits)
+ if err != nil {
+ return false, err
+ }
+ kitTraitsMap, err := trait.ToMap(kitTraits)
+ if err != nil {
+ return false, err
+ }
catalog := trait.NewCatalog(nil)
+
for _, t := range catalog.AllTraits() {
- if t != nil && !t.InfluencesKit() {
+ if t == nil || !t.InfluencesKit() {
// We don't store the trait configuration if the trait cannot influence the kit behavior
continue
}
id := string(t.ID())
- t1, ok1 := traits1[id]
- t2, ok2 := traits2[id]
+ it, ok1 := traitsMap[id]
+ kt, ok2 := kitTraitsMap[id]
if !ok1 && !ok2 {
continue
}
+ if !ok1 || !ok2 {
+ return false, nil
+ }
if ct, ok := t.(trait.ComparableTrait); ok {
- if comparable, err := hasComparableTrait(ct, &t1, &t2); err != nil {
+ // if it's match trait use its matches method to determine the match
+ if match, err := matchesComparableTrait(ct, it, kt); !match || err != nil {
return false, err
- } else if comparable {
- continue
}
- } else if ok1 && ok2 {
- if match, err := hasMatchingTrait(&t1, &t2); err != nil {
- return false, err
- } else if match {
- continue
+ } else {
+ if !matchesTrait(it, kt) {
+ return false, nil
}
}
- return false, nil
}
return true, nil
}
-func hasComparableTrait(t trait.ComparableTrait, ts1 *v1.TraitSpec, ts2 *v1.TraitSpec) (bool, error) {
- t1 := reflect.New(reflect.TypeOf(t).Elem()).Interface()
- if ts1.Configuration.RawMessage != nil {
- data, err := json.Marshal(ts1.Configuration)
- if err != nil {
- return false, err
- }
- err = json.Unmarshal(data, &t1)
- if err != nil {
- return false, err
- }
- }
-
- t2 := reflect.New(reflect.TypeOf(t).Elem()).Interface()
- if ts2.Configuration.RawMessage != nil {
- data, err := json.Marshal(ts2.Configuration)
- if err != nil {
- return false, err
- }
- err = json.Unmarshal(data, &t2)
- if err != nil {
- return false, err
- }
- }
-
- return t2.(trait.ComparableTrait).Matches(t1.(trait.Trait)), nil
-}
-
-func hasMatchingTrait(ts1 *v1.TraitSpec, ts2 *v1.TraitSpec) (bool, error) {
- data, err := json.Marshal(ts1.Configuration)
- if err != nil {
- return false, err
- }
- t1 := make(map[string]interface{})
- err = json.Unmarshal(data, &t1)
- if err != nil {
+func matchesComparableTrait(ct trait.ComparableTrait, it map[string]interface{}, kt map[string]interface{}) (bool, error) {
+ t1 := reflect.New(reflect.TypeOf(ct).Elem()).Interface()
+ if err := trait.ToTrait(it, &t1); err != nil {
return false, err
}
- data, err = json.Marshal(ts2.Configuration)
- if err != nil {
- return false, err
- }
- t2 := make(map[string]interface{})
- err = json.Unmarshal(data, &t2)
- if err != nil {
- return false, err
- }
- for ck, cv := range t2 {
- iv, ok := t1[ck]
- if !ok {
- // skip it because trait configured on kit has a value that is not defined
- // in integration trait
- return false, nil
- }
- if !equal(iv, cv) {
- // skip it because trait configured on kit has a value that differs from
- // the one configured on integration
- return false, nil
- }
- }
- return true, nil
-}
-
-// We need to try to perform a slice equality in order to prevent a runtime panic.
-func equal(a, b interface{}) bool {
- aSlice, aOk := a.([]interface{})
- bSlice, bOk := b.([]interface{})
-
- if aOk && bOk {
- // Both are slices
- return sliceEqual(aSlice, bSlice)
- }
- if aOk || bOk {
- // One of the 2 is a slice
- return false
+ t2 := reflect.New(reflect.TypeOf(ct).Elem()).Interface()
+ if err := trait.ToTrait(kt, &t2); err != nil {
+ return false, err
}
- // None is a slice
- return a == b
+ return t2.(trait.ComparableTrait).Matches(t1.(trait.Trait)), nil
}
-func sliceEqual(a, b []interface{}) bool {
- if len(a) != len(b) {
- return false
- }
- for i, v := range a {
- if v != b[i] {
- return false
- }
- }
- return true
+func matchesTrait(it map[string]interface{}, kt map[string]interface{}) bool {
+ // perform exact match on the two trait maps
+ return reflect.DeepEqual(it, kt)
}
diff --git a/pkg/controller/integration/build_kit_test.go b/pkg/controller/integration/kits_test.go
similarity index 87%
rename from pkg/controller/integration/build_kit_test.go
rename to pkg/controller/integration/kits_test.go
index 8c9f7491d..86ed58de4 100644
--- a/pkg/controller/integration/build_kit_test.go
+++ b/pkg/controller/integration/kits_test.go
@@ -24,6 +24,7 @@ import (
"github.com/stretchr/testify/assert"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+ "k8s.io/utils/pointer"
v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
"github.com/apache/camel-k/pkg/util/log"
@@ -151,10 +152,12 @@ func TestLookupKitForIntegration_DiscardKitsWithIncompatibleTraits(t *testing.T)
"camel-core",
"camel-irc",
},
- Traits: map[string]v1.TraitSpec{
- "builder": test.TraitSpecFromMap(t, map[string]interface{}{
- "enabled": "false",
- }),
+ Traits: v1.IntegrationKitTraits{
+ Builder: &v1.BuilderTrait{
+ Trait: v1.Trait{
+ Enabled: pointer.Bool(false),
+ },
+ },
},
},
Status: v1.IntegrationKitStatus{
@@ -180,13 +183,15 @@ func TestLookupKitForIntegration_DiscardKitsWithIncompatibleTraits(t *testing.T)
"camel-core",
"camel-irc",
},
- Traits: map[string]v1.TraitSpec{
- "builder": test.TraitSpecFromMap(t, map[string]interface{}{
- "enabled": "true",
- "properties": []string{
+ Traits: v1.IntegrationKitTraits{
+ Builder: &v1.BuilderTrait{
+ Trait: v1.Trait{
+ Enabled: pointer.Bool(true),
+ },
+ Properties: []string{
"build-key1=build-value1",
},
- }),
+ },
},
},
Status: v1.IntegrationKitStatus{
@@ -211,13 +216,15 @@ func TestLookupKitForIntegration_DiscardKitsWithIncompatibleTraits(t *testing.T)
Name: "my-integration",
},
Spec: v1.IntegrationSpec{
- Traits: map[string]v1.TraitSpec{
- "builder": test.TraitSpecFromMap(t, map[string]interface{}{
- "enabled": "true",
- "properties": []string{
+ Traits: v1.Traits{
+ Builder: &v1.BuilderTrait{
+ Trait: v1.Trait{
+ Enabled: pointer.Bool(true),
+ },
+ Properties: []string{
"build-key1=build-value1",
},
- }),
+ },
},
},
Status: v1.IntegrationStatus{
@@ -245,10 +252,12 @@ func TestHasMatchingTraits_KitNoTraitShouldNotBePicked(t *testing.T) {
Name: "my-integration",
},
Spec: v1.IntegrationSpec{
- Traits: map[string]v1.TraitSpec{
- "builder": test.TraitSpecFromMap(t, map[string]interface{}{
- "enabled": "true",
- }),
+ Traits: v1.Traits{
+ Builder: &v1.BuilderTrait{
+ Trait: v1.Trait{
+ Enabled: pointer.Bool(true),
+ },
+ },
},
},
}
@@ -262,9 +271,6 @@ func TestHasMatchingTraits_KitNoTraitShouldNotBePicked(t *testing.T) {
Namespace: "ns",
Name: "my-kit",
},
- Spec: v1.IntegrationKitSpec{
- Traits: map[string]v1.TraitSpec{},
- },
}
a := buildKitAction{}
@@ -286,13 +292,15 @@ func TestHasMatchingTraits_KitSameTraitShouldBePicked(t *testing.T) {
Name: "my-integration",
},
Spec: v1.IntegrationSpec{
- Traits: map[string]v1.TraitSpec{
- "builder": test.TraitSpecFromMap(t, map[string]interface{}{
- "enabled": "true",
- "properties": []string{
+ Traits: v1.Traits{
+ Builder: &v1.BuilderTrait{
+ Trait: v1.Trait{
+ Enabled: pointer.Bool(true),
+ },
+ Properties: []string{
"build-key1=build-value1",
},
- }),
+ },
},
},
}
@@ -307,13 +315,15 @@ func TestHasMatchingTraits_KitSameTraitShouldBePicked(t *testing.T) {
Name: "my-kit",
},
Spec: v1.IntegrationKitSpec{
- Traits: map[string]v1.TraitSpec{
- "builder": test.TraitSpecFromMap(t, map[string]interface{}{
- "enabled": "true",
- "properties": []string{
+ Traits: v1.IntegrationKitTraits{
+ Builder: &v1.BuilderTrait{
+ Trait: v1.Trait{
+ Enabled: pointer.Bool(true),
+ },
+ Properties: []string{
"build-key1=build-value1",
},
- }),
+ },
},
},
}
diff --git a/pkg/controller/kameletbinding/integration.go b/pkg/controller/kameletbinding/integration.go
index ef8b0fc7d..cde6da195 100644
--- a/pkg/controller/kameletbinding/integration.go
+++ b/pkg/controller/kameletbinding/integration.go
@@ -213,12 +213,7 @@ func configureBinding(integration *v1.Integration, bindings ...*bindings.Binding
if b == nil {
continue
}
- if integration.Spec.Traits == nil {
- integration.Spec.Traits = make(map[string]v1.TraitSpec)
- }
- for k, v := range b.Traits {
- integration.Spec.Traits[k] = v
- }
+ integration.Spec.Traits = b.Traits
for k, v := range b.ApplicationProperties {
entry, err := property.EncodePropertyFileEntry(k, v)
if err != nil {
diff --git a/pkg/trait/affinity.go b/pkg/trait/affinity.go
index 87a1b622f..6d6859425 100644
--- a/pkg/trait/affinity.go
+++ b/pkg/trait/affinity.go
@@ -30,33 +30,18 @@ import (
v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
)
-// Allows constraining which nodes the integration pod(s) are eligible to be scheduled on, based on labels on the node,
-// or with inter-pod affinity and anti-affinity, based on labels on pods that are already running on the nodes.
-//
-// It's disabled by default.
-//
-// +camel-k:trait=affinity.
type affinityTrait struct {
- BaseTrait `property:",squash"`
- // Always co-locates multiple replicas of the integration in the same node (default *false*).
- PodAffinity *bool `property:"pod-affinity" json:"podAffinity,omitempty"`
- // Never co-locates multiple replicas of the integration in the same node (default *false*).
- PodAntiAffinity *bool `property:"pod-anti-affinity" json:"podAntiAffinity,omitempty"`
- // Defines a set of nodes the integration pod(s) are eligible to be scheduled on, based on labels on the node.
- NodeAffinityLabels []string `property:"node-affinity-labels" json:"nodeAffinityLabels,omitempty"`
- // Defines a set of pods (namely those matching the label selector, relative to the given namespace) that the
- // integration pod(s) should be co-located with.
- PodAffinityLabels []string `property:"pod-affinity-labels" json:"podAffinityLabels,omitempty"`
- // Defines a set of pods (namely those matching the label selector, relative to the given namespace) that the
- // integration pod(s) should not be co-located with.
- PodAntiAffinityLabels []string `property:"pod-anti-affinity-labels" json:"podAntiAffinityLabels,omitempty"`
+ BaseTrait
+ v1.AffinityTrait `property:",squash"`
}
func newAffinityTrait() Trait {
return &affinityTrait{
- BaseTrait: NewBaseTrait("affinity", 1500),
- PodAffinity: pointer.Bool(false),
- PodAntiAffinity: pointer.Bool(false),
+ BaseTrait: NewBaseTrait("affinity", 1500),
+ AffinityTrait: v1.AffinityTrait{
+ PodAffinity: pointer.Bool(false),
+ PodAntiAffinity: pointer.Bool(false),
+ },
}
}
diff --git a/pkg/trait/builder.go b/pkg/trait/builder.go
index 97940469b..15eda75ca 100644
--- a/pkg/trait/builder.go
+++ b/pkg/trait/builder.go
@@ -30,16 +30,9 @@ import (
"github.com/apache/camel-k/pkg/util/property"
)
-// The builder trait is internally used to determine the best strategy to
-// build and configure IntegrationKits.
-//
-// +camel-k:trait=builder.
type builderTrait struct {
- BaseTrait `property:",squash"`
- // Enable verbose logging on build components that support it (e.g. Kaniko build pod).
- Verbose *bool `property:"verbose" json:"verbose,omitempty"`
- // A list of properties to be provided to the build task
- Properties []string `property:"properties" json:"properties,omitempty"`
+ BaseTrait
+ v1.BuilderTrait `property:",squash"`
}
func newBuilderTrait() Trait {
diff --git a/pkg/trait/camel.go b/pkg/trait/camel.go
index f6346fb06..e5cf98652 100644
--- a/pkg/trait/camel.go
+++ b/pkg/trait/camel.go
@@ -35,15 +35,9 @@ import (
"github.com/apache/camel-k/pkg/util/property"
)
-// The Camel trait can be used to configure versions of Apache Camel K runtime and related libraries, it cannot be disabled.
-//
-// +camel-k:trait=camel.
type camelTrait struct {
- BaseTrait `property:",squash"`
- // The camel-k-runtime version to use for the integration. It overrides the default version set in the Integration Platform.
- RuntimeVersion string `property:"runtime-version" json:"runtimeVersion,omitempty"`
- // A list of properties to be provided to the Integration runtime
- Properties []string `property:"properties" json:"properties,omitempty"`
+ BaseTrait
+ v1.CamelTrait `property:",squash"`
}
func newCamelTrait() Trait {
diff --git a/pkg/trait/camel_test.go b/pkg/trait/camel_test.go
index 58d8a4bfb..20e555975 100644
--- a/pkg/trait/camel_test.go
+++ b/pkg/trait/camel_test.go
@@ -94,7 +94,7 @@ func createNominalCamelTest() (*camelTrait, *Environment) {
Namespace: "namespace",
},
Spec: v1.IntegrationSpec{
- Traits: make(map[string]v1.TraitSpec),
+ Traits: v1.Traits{},
},
Status: v1.IntegrationStatus{
RuntimeVersion: "0.0.1",
diff --git a/pkg/trait/container.go b/pkg/trait/container.go
index 3b3ca484c..2f0011f36 100644
--- a/pkg/trait/container.go
+++ b/pkg/trait/container.go
@@ -46,98 +46,23 @@ const (
containerTraitID = "container"
)
-// The Container trait can be used to configure properties of the container where the integration will run.
-//
-// It also provides configuration for Services associated to the container.
-//
-// +camel-k:trait=container
-// nolint: tagliatelle
type containerTrait struct {
- BaseTrait `property:",squash"`
-
- Auto *bool `property:"auto" json:"auto,omitempty"`
-
- // The minimum amount of CPU required.
- RequestCPU string `property:"request-cpu" json:"requestCPU,omitempty"`
- // The minimum amount of memory required.
- RequestMemory string `property:"request-memory" json:"requestMemory,omitempty"`
- // The maximum amount of CPU required.
- LimitCPU string `property:"limit-cpu" json:"limitCPU,omitempty"`
- // The maximum amount of memory required.
- LimitMemory string `property:"limit-memory" json:"limitMemory,omitempty"`
-
- // Can be used to enable/disable exposure via kubernetes Service.
- Expose *bool `property:"expose" json:"expose,omitempty"`
- // To configure a different port exposed by the container (default `8080`).
- Port int `property:"port" json:"port,omitempty"`
- // To configure a different port name for the port exposed by the container. It defaults to `http` only when the `expose` parameter is true.
- PortName string `property:"port-name" json:"portName,omitempty"`
- // To configure under which service port the container port is to be exposed (default `80`).
- ServicePort int `property:"service-port" json:"servicePort,omitempty"`
- // To configure under which service port name the container port is to be exposed (default `http`).
- ServicePortName string `property:"service-port-name" json:"servicePortName,omitempty"`
- // The main container name. It's named `integration` by default.
- Name string `property:"name" json:"name,omitempty"`
- // The main container image
- Image string `property:"image" json:"image,omitempty"`
- // The pull policy: Always|Never|IfNotPresent
- ImagePullPolicy corev1.PullPolicy `property:"image-pull-policy" json:"imagePullPolicy,omitempty"`
-
- // DeprecatedProbesEnabled enable/disable probes on the container (default `false`)
- // Deprecated: replaced by the health trait.
- DeprecatedProbesEnabled *bool `property:"probes-enabled" json:"probesEnabled,omitempty"`
- // Scheme to use when connecting. Defaults to HTTP. Applies to the liveness probe.
- // Deprecated: replaced by the health trait.
- DeprecatedLivenessScheme string `property:"liveness-scheme" json:"livenessScheme,omitempty"`
- // Number of seconds after the container has started before liveness probes are initiated.
- // Deprecated: replaced by the health trait.
- DeprecatedLivenessInitialDelay int32 `property:"liveness-initial-delay" json:"livenessInitialDelay,omitempty"`
- // Number of seconds after which the probe times out. Applies to the liveness probe.
- // Deprecated: replaced by the health trait.
- DeprecatedLivenessTimeout int32 `property:"liveness-timeout" json:"livenessTimeout,omitempty"`
- // How often to perform the probe. Applies to the liveness probe.
- // Deprecated: replaced by the health trait.
- DeprecatedLivenessPeriod int32 `property:"liveness-period" json:"livenessPeriod,omitempty"`
- // Minimum consecutive successes for the probe to be considered successful after having failed.
- // Applies to the liveness probe.
- // Deprecated: replaced by the health trait.
- DeprecatedLivenessSuccessThreshold int32 `property:"liveness-success-threshold" json:"livenessSuccessThreshold,omitempty"`
- // Minimum consecutive failures for the probe to be considered failed after having succeeded.
- // Applies to the liveness probe.
- // Deprecated: replaced by the health trait.
- DeprecatedLivenessFailureThreshold int32 `property:"liveness-failure-threshold" json:"livenessFailureThreshold,omitempty"`
- // Scheme to use when connecting. Defaults to HTTP. Applies to the readiness probe.
- // Deprecated: replaced by the health trait.
- DeprecatedReadinessScheme string `property:"readiness-scheme" json:"readinessScheme,omitempty"`
- // Number of seconds after the container has started before readiness probes are initiated.
- // Deprecated: replaced by the health trait.
- DeprecatedReadinessInitialDelay int32 `property:"readiness-initial-delay" json:"readinessInitialDelay,omitempty"`
- // Number of seconds after which the probe times out. Applies to the readiness probe.
- // Deprecated: replaced by the health trait.
- DeprecatedReadinessTimeout int32 `property:"readiness-timeout" json:"readinessTimeout,omitempty"`
- // How often to perform the probe. Applies to the readiness probe.
- // Deprecated: replaced by the health trait.
- DeprecatedReadinessPeriod int32 `property:"readiness-period" json:"readinessPeriod,omitempty"`
- // Minimum consecutive successes for the probe to be considered successful after having failed.
- // Applies to the readiness probe.
- // Deprecated: replaced by the health trait.
- DeprecatedReadinessSuccessThreshold int32 `property:"readiness-success-threshold" json:"readinessSuccessThreshold,omitempty"`
- // Minimum consecutive failures for the probe to be considered failed after having succeeded.
- // Applies to the readiness probe.
- // Deprecated: replaced by the health trait.
- DeprecatedReadinessFailureThreshold int32 `property:"readiness-failure-threshold" json:"readinessFailureThreshold,omitempty"`
+ BaseTrait
+ v1.ContainerTrait `property:",squash"`
}
func newContainerTrait() Trait {
return &containerTrait{
- BaseTrait: NewBaseTrait(containerTraitID, 1600),
- Port: defaultContainerPort,
- ServicePort: defaultServicePort,
- ServicePortName: defaultContainerPortName,
- Name: defaultContainerName,
- DeprecatedProbesEnabled: pointer.Bool(false),
- DeprecatedLivenessScheme: string(corev1.URISchemeHTTP),
- DeprecatedReadinessScheme: string(corev1.URISchemeHTTP),
+ BaseTrait: NewBaseTrait(containerTraitID, 1600),
+ ContainerTrait: v1.ContainerTrait{
+ Port: defaultContainerPort,
+ ServicePort: defaultServicePort,
+ ServicePortName: defaultContainerPortName,
+ Name: defaultContainerName,
+ DeprecatedProbesEnabled: pointer.Bool(false),
+ DeprecatedLivenessScheme: string(corev1.URISchemeHTTP),
+ DeprecatedReadinessScheme: string(corev1.URISchemeHTTP),
+ },
}
}
diff --git a/pkg/trait/container_probes_test.go b/pkg/trait/container_probes_test.go
index 0d4ccbdab..acad3aeba 100644
--- a/pkg/trait/container_probes_test.go
+++ b/pkg/trait/container_probes_test.go
@@ -23,11 +23,11 @@ import (
"github.com/stretchr/testify/assert"
corev1 "k8s.io/api/core/v1"
+ "k8s.io/utils/pointer"
v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
"github.com/apache/camel-k/pkg/util/camel"
"github.com/apache/camel-k/pkg/util/kubernetes"
- "github.com/apache/camel-k/pkg/util/test"
)
func newTestProbesEnv(t *testing.T, integration *v1.Integration) Environment {
@@ -52,10 +52,10 @@ func newTestProbesEnv(t *testing.T, integration *v1.Integration) Environment {
func TestProbesDependencies(t *testing.T) {
integration := &v1.Integration{
Spec: v1.IntegrationSpec{
- Traits: map[string]v1.TraitSpec{
- "container": test.TraitSpecFromMap(t, map[string]interface{}{
- "probesEnabled": true,
- }),
+ Traits: v1.Traits{
+ Container: &v1.ContainerTrait{
+ DeprecatedProbesEnabled: pointer.Bool(true),
+ },
},
},
}
@@ -72,12 +72,12 @@ func TestProbesDependencies(t *testing.T) {
func TestProbesOnDeployment(t *testing.T) {
integration := &v1.Integration{
Spec: v1.IntegrationSpec{
- Traits: map[string]v1.TraitSpec{
- "container": test.TraitSpecFromMap(t, map[string]interface{}{
- "probesEnabled": true,
- "expose": true,
- "LivenessTimeout": 1234,
- }),
+ Traits: v1.Traits{
+ Container: &v1.ContainerTrait{
+ DeprecatedProbesEnabled: pointer.Bool(true),
+ Expose: pointer.Bool(true),
+ DeprecatedLivenessTimeout: 1234,
+ },
},
},
}
@@ -104,14 +104,14 @@ func TestProbesOnDeployment(t *testing.T) {
func TestProbesOnDeploymentWithCustomScheme(t *testing.T) {
integration := &v1.Integration{
Spec: v1.IntegrationSpec{
- Traits: map[string]v1.TraitSpec{
- "container": test.TraitSpecFromMap(t, map[string]interface{}{
- "probesEnabled": true,
- "expose": true,
- "livenessTimeout": 1234,
- "livenessScheme": "HTTPS",
- "readinessScheme": "HTTPS",
- }),
+ Traits: v1.Traits{
+ Container: &v1.ContainerTrait{
+ DeprecatedProbesEnabled: pointer.Bool(true),
+ Expose: pointer.Bool(true),
+ DeprecatedLivenessTimeout: 1234,
+ DeprecatedLivenessScheme: "HTTPS",
+ DeprecatedReadinessScheme: "HTTPS",
+ },
},
},
}
@@ -139,15 +139,17 @@ func TestProbesOnKnativeService(t *testing.T) {
integration := &v1.Integration{
Spec: v1.IntegrationSpec{
Profile: v1.TraitProfileKnative,
- Traits: map[string]v1.TraitSpec{
- "knative-service": test.TraitSpecFromMap(t, map[string]interface{}{
- "enabled": true,
- }),
- "container": test.TraitSpecFromMap(t, map[string]interface{}{
- "probesEnabled": true,
- "expose": true,
- "livenessTimeout": 1234,
- }),
+ Traits: v1.Traits{
+ KnativeService: &v1.KnativeServiceTrait{
+ Trait: v1.Trait{
+ Enabled: pointer.Bool(true),
+ },
+ },
+ Container: &v1.ContainerTrait{
+ DeprecatedProbesEnabled: pointer.Bool(true),
+ Expose: pointer.Bool(true),
+ DeprecatedLivenessTimeout: 1234,
+ },
},
},
}
diff --git a/pkg/trait/container_test.go b/pkg/trait/container_test.go
index 494dd5b20..07db63f3e 100644
--- a/pkg/trait/container_test.go
+++ b/pkg/trait/container_test.go
@@ -110,10 +110,10 @@ func TestContainerWithCustomName(t *testing.T) {
},
Spec: v1.IntegrationSpec{
Profile: v1.TraitProfileKubernetes,
- Traits: map[string]v1.TraitSpec{
- "container": test.TraitSpecFromMap(t, map[string]interface{}{
- "name": "my-container-name",
- }),
+ Traits: v1.Traits{
+ Container: &v1.ContainerTrait{
+ Name: "my-container-name",
+ },
},
},
},
@@ -149,8 +149,8 @@ func TestContainerWithCustomName(t *testing.T) {
assert.NotNil(t, d)
assert.Len(t, d.Spec.Template.Spec.Containers, 1)
- trait := test.TraitSpecToMap(t, environment.Integration.Spec.Traits["container"])
- assert.Equal(t, trait["name"], d.Spec.Template.Spec.Containers[0].Name)
+ trait := environment.Integration.Spec.Traits.Container
+ assert.Equal(t, trait.Name, d.Spec.Template.Spec.Containers[0].Name)
}
func TestContainerWithCustomImage(t *testing.T) {
@@ -176,10 +176,10 @@ func TestContainerWithCustomImage(t *testing.T) {
},
Spec: v1.IntegrationSpec{
Profile: v1.TraitProfileKubernetes,
- Traits: map[string]v1.TraitSpec{
- "container": test.TraitSpecFromMap(t, map[string]interface{}{
- "image": "foo/bar:1.0.0",
- }),
+ Traits: v1.Traits{
+ Container: &v1.ContainerTrait{
+ Image: "foo/bar:1.0.0",
+ },
},
},
},
@@ -220,8 +220,8 @@ func TestContainerWithCustomImage(t *testing.T) {
assert.Nil(t, err)
assert.Equal(t, environment.Integration.ObjectMeta.UID, ikt.ObjectMeta.OwnerReferences[0].UID)
- trait := test.TraitSpecToMap(t, environment.Integration.Spec.Traits["container"])
- assert.Equal(t, trait["image"], ikt.Spec.Image)
+ trait := environment.Integration.Spec.Traits.Container
+ assert.Equal(t, trait.Image, ikt.Spec.Image)
}
func TestContainerWithCustomImageAndIntegrationKit(t *testing.T) {
@@ -247,10 +247,10 @@ func TestContainerWithCustomImageAndIntegrationKit(t *testing.T) {
},
Spec: v1.IntegrationSpec{
Profile: v1.TraitProfileKubernetes,
- Traits: map[string]v1.TraitSpec{
- "container": test.TraitSpecFromMap(t, map[string]interface{}{
- "image": "foo/bar:1.0.0",
- }),
+ Traits: v1.Traits{
+ Container: &v1.ContainerTrait{
+ Image: "foo/bar:1.0.0",
+ },
},
IntegrationKit: &corev1.ObjectReference{
Name: "bad-" + ServiceTestName,
@@ -293,10 +293,10 @@ func TestContainerWithImagePullPolicy(t *testing.T) {
Integration: &v1.Integration{
Spec: v1.IntegrationSpec{
Profile: v1.TraitProfileKubernetes,
- Traits: map[string]v1.TraitSpec{
- "container": test.TraitSpecFromMap(t, map[string]interface{}{
- "imagePullPolicy": "Always",
- }),
+ Traits: v1.Traits{
+ Container: &v1.ContainerTrait{
+ ImagePullPolicy: "Always",
+ },
},
},
},
diff --git a/pkg/trait/cron.go b/pkg/trait/cron.go
index 0c078442c..f6b33b250 100644
--- a/pkg/trait/cron.go
+++ b/pkg/trait/cron.go
@@ -36,57 +36,9 @@ import (
"github.com/apache/camel-k/pkg/util/uri"
)
-// The Cron trait can be used to customize the behaviour of periodic timer/cron based integrations.
-//
-// While normally an integration requires a pod to be always up and running, some periodic tasks, such as batch jobs,
-// require to be activated at specific hours of the day or with a periodic delay of minutes.
-// For such tasks, the cron trait can materialize the integration as a Kubernetes CronJob instead of a standard deployment,
-// in order to save resources when the integration does not need to be executed.
-//
-// Integrations that start from the following components are evaluated by the cron trait: `timer`, `cron`, `quartz`.
-//
-// The rules for using a Kubernetes CronJob are the following:
-// - `timer`: when periods can be written as cron expressions. E.g. `timer:tick?period=60000`.
-// - `cron`, `quartz`: when the cron expression does not contain seconds (or the "seconds" part is set to 0). E.g.
-// `cron:tab?schedule=0/2${plus}*{plus}*{plus}*{plus}?` or `quartz:trigger?cron=0{plus}0/2{plus}*{plus}*{plus}*{plus}?`.
-//
-// +camel-k:trait=cron.
type cronTrait struct {
- BaseTrait `property:",squash"`
- // The CronJob schedule for the whole integration. If multiple routes are declared, they must have the same schedule for this
- // mechanism to work correctly.
- Schedule string `property:"schedule" json:"schedule,omitempty"`
- // A comma separated list of the Camel components that need to be customized in order for them to work when the schedule is triggered externally by Kubernetes.
- // A specific customizer is activated for each specified component. E.g. for the `timer` component, the `cron-timer` customizer is
- // activated (it's present in the `org.apache.camel.k:camel-k-cron` library).
- //
- // Supported components are currently: `cron`, `timer` and `quartz`.
- Components string `property:"components" json:"components,omitempty"`
- // Use the default Camel implementation of the `cron` endpoint (`quartz`) instead of trying to materialize the integration
- // as Kubernetes CronJob.
- Fallback *bool `property:"fallback" json:"fallback,omitempty"`
- // Specifies how to treat concurrent executions of a Job.
- // Valid values are:
- // - "Allow": allows CronJobs to run concurrently;
- // - "Forbid" (default): forbids concurrent runs, skipping next run if previous run hasn't finished yet;
- // - "Replace": cancels currently running job and replaces it with a new one
- ConcurrencyPolicy string `property:"concurrency-policy" json:"concurrencyPolicy,omitempty"`
- // Automatically deploy the integration as CronJob when all routes are
- // either starting from a periodic consumer (only `cron`, `timer` and `quartz` are supported) or a passive consumer (e.g. `direct` is a passive consumer).
- //
- // It's required that all periodic consumers have the same period and it can be expressed as cron schedule (e.g. `1m` can be expressed as `0/1 * * * *`,
- // while `35m` or `50s` cannot).
- Auto *bool `property:"auto" json:"auto,omitempty"`
- // Optional deadline in seconds for starting the job if it misses scheduled
- // time for any reason. Missed jobs executions will be counted as failed ones.
- StartingDeadlineSeconds *int64 `property:"starting-deadline-seconds" json:"startingDeadlineSeconds,omitempty"`
- // Specifies the duration in seconds, relative to the start time, that the job
- // may be continuously active before it is considered to be failed.
- // It defaults to 60s.
- ActiveDeadlineSeconds *int64 `property:"active-deadline-seconds" json:"activeDeadlineSeconds,omitempty"`
- // Specifies the number of retries before marking the job failed.
- // It defaults to 2.
- BackoffLimit *int32 `property:"backoff-limit" json:"backoffLimit,omitempty"`
+ BaseTrait
+ v1.CronTrait `property:",squash"`
}
var _ ControllerStrategySelector = &cronTrait{}
diff --git a/pkg/trait/cron_test.go b/pkg/trait/cron_test.go
index 0f2612473..2d0240f17 100644
--- a/pkg/trait/cron_test.go
+++ b/pkg/trait/cron_test.go
@@ -27,12 +27,12 @@ import (
batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+ "k8s.io/utils/pointer"
v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
"github.com/apache/camel-k/pkg/util"
"github.com/apache/camel-k/pkg/util/camel"
"github.com/apache/camel-k/pkg/util/kubernetes"
- "github.com/apache/camel-k/pkg/util/test"
)
func TestCronFromURI(t *testing.T) {
@@ -249,7 +249,7 @@ func TestCronDeps(t *testing.T) {
},
},
Resources: []v1.ResourceSpec{},
- Traits: map[string]v1.TraitSpec{},
+ Traits: v1.Traits{},
},
},
IntegrationKit: &v1.IntegrationKit{
@@ -319,10 +319,10 @@ func TestCronDepsFallback(t *testing.T) {
},
},
Resources: []v1.ResourceSpec{},
- Traits: map[string]v1.TraitSpec{
- "cron": test.TraitSpecFromMap(t, map[string]interface{}{
- "fallback": true,
- }),
+ Traits: v1.Traits{
+ Cron: &v1.CronTrait{
+ Fallback: pointer.Bool(true),
+ },
},
},
},
@@ -394,10 +394,10 @@ func TestCronWithActiveDeadline(t *testing.T) {
},
},
Resources: []v1.ResourceSpec{},
- Traits: map[string]v1.TraitSpec{
- "cron": test.TraitSpecFromMap(t, map[string]interface{}{
- "activeDeadlineSeconds": 120,
- }),
+ Traits: v1.Traits{
+ Cron: &v1.CronTrait{
+ ActiveDeadlineSeconds: pointer.Int64(120),
+ },
},
},
},
@@ -467,10 +467,10 @@ func TestCronWithBackoffLimit(t *testing.T) {
},
},
Resources: []v1.ResourceSpec{},
- Traits: map[string]v1.TraitSpec{
- "cron": test.TraitSpecFromMap(t, map[string]interface{}{
- "backoffLimit": 5,
- }),
+ Traits: v1.Traits{
+ Cron: &v1.CronTrait{
+ BackoffLimit: pointer.Int32(5),
+ },
},
},
},
diff --git a/pkg/trait/dependencies.go b/pkg/trait/dependencies.go
index b8cf3e4d4..59ed4bd22 100644
--- a/pkg/trait/dependencies.go
+++ b/pkg/trait/dependencies.go
@@ -28,12 +28,9 @@ import (
"github.com/apache/camel-k/pkg/util/kubernetes"
)
-// The Dependencies trait is internally used to automatically add runtime dependencies based on the
-// integration that the user wants to run.
-//
-// +camel-k:trait=dependencies.
type dependenciesTrait struct {
- BaseTrait `property:",squash"`
+ BaseTrait
+ v1.DependenciesTrait `property:",squash"`
}
func newDependenciesTrait() Trait {
diff --git a/pkg/trait/deployer.go b/pkg/trait/deployer.go
index ca40062d7..b46e3324a 100644
--- a/pkg/trait/deployer.go
+++ b/pkg/trait/deployer.go
@@ -31,20 +31,13 @@ import (
ctrl "sigs.k8s.io/controller-runtime/pkg/client"
+ v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
"github.com/apache/camel-k/pkg/util/patch"
)
-// The deployer trait is responsible for deploying the resources owned by the integration, and can be used
-// to explicitly select the underlying controller that will manage the integration pods.
-//
-// +camel-k:trait=deployer.
type deployerTrait struct {
- BaseTrait `property:",squash"`
- // Allows to explicitly select the desired deployment kind between `deployment`, `cron-job` or `knative-service` when creating the resources for running the integration.
- Kind string `property:"kind" json:"kind,omitempty"`
- // Use server-side apply to update the owned resources (default `true`).
- // Note that it automatically falls back to client-side patching, if SSA is not available, e.g., on old Kubernetes clusters.
- UseSSA *bool `property:"use-ssa" json:"useSSA,omitempty"`
+ BaseTrait
+ v1.DeployerTrait `property:",squash"`
}
var _ ControllerStrategySelector = &deployerTrait{}
diff --git a/pkg/trait/deployment.go b/pkg/trait/deployment.go
index d0a060921..c9fafe2e3 100644
--- a/pkg/trait/deployment.go
+++ b/pkg/trait/deployment.go
@@ -29,15 +29,9 @@ import (
"github.com/apache/camel-k/pkg/util/label"
)
-// The Deployment trait is responsible for generating the Kubernetes deployment that will make sure
-// the integration will run in the cluster.
-//
-// +camel-k:trait=deployment.
type deploymentTrait struct {
- BaseTrait `property:",squash"`
- // The maximum time in seconds for the deployment to make progress before it
- // is considered to be failed. It defaults to 60s.
- ProgressDeadlineSeconds *int32 `property:"progress-deadline-seconds" json:"progressDeadlineSeconds,omitempty"`
+ BaseTrait
+ v1.DeploymentTrait `property:",squash"`
}
var _ ControllerStrategySelector = &deploymentTrait{}
diff --git a/pkg/trait/deployment_test.go b/pkg/trait/deployment_test.go
index 6dc2dbd57..015cbf7de 100644
--- a/pkg/trait/deployment_test.go
+++ b/pkg/trait/deployment_test.go
@@ -187,7 +187,7 @@ func createNominalDeploymentTest() (*deploymentTrait, *Environment) {
},
Spec: v1.IntegrationSpec{
Replicas: &replicas,
- Traits: make(map[string]v1.TraitSpec),
+ Traits: v1.Traits{},
},
Status: v1.IntegrationStatus{
Phase: v1.IntegrationPhaseDeploying,
diff --git a/pkg/trait/environment.go b/pkg/trait/environment.go
index ba8688a32..735e9e1ea 100644
--- a/pkg/trait/environment.go
+++ b/pkg/trait/environment.go
@@ -22,26 +22,16 @@ import (
"k8s.io/utils/pointer"
+ v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
"github.com/apache/camel-k/pkg/util/camel"
"github.com/apache/camel-k/pkg/util/defaults"
"github.com/apache/camel-k/pkg/util/envvar"
"github.com/apache/camel-k/pkg/util/property"
)
-// The environment trait is used internally to inject standard environment variables in the integration container,
-// such as `NAMESPACE`, `POD_NAME` and others.
-//
-// +camel-k:trait=environment.
type environmentTrait struct {
- BaseTrait `property:",squash"`
- // Enables injection of `NAMESPACE` and `POD_NAME` environment variables (default `true`)
- ContainerMeta *bool `property:"container-meta" json:"containerMeta,omitempty"`
- // Propagates the `HTTP_PROXY`, `HTTPS_PROXY` and `NO_PROXY` environment variables (default `true`)
- HTTPProxy *bool `property:"http-proxy" json:"httpProxy,omitempty"`
- // A list of environment variables to be added to the integration container.
- // The syntax is KEY=VALUE, e.g., `MY_VAR="my value"`.
- // These take precedence over the previously defined environment variables.
- Vars []string `property:"vars" json:"vars,omitempty"`
+ BaseTrait
+ v1.EnvironmentTrait `property:",squash"`
}
const (
@@ -63,8 +53,10 @@ const (
func newEnvironmentTrait() Trait {
return &environmentTrait{
- BaseTrait: NewBaseTrait("environment", 800),
- ContainerMeta: pointer.Bool(true),
+ BaseTrait: NewBaseTrait("environment", 800),
+ EnvironmentTrait: v1.EnvironmentTrait{
+ ContainerMeta: pointer.Bool(true),
+ },
}
}
diff --git a/pkg/trait/environment_test.go b/pkg/trait/environment_test.go
index df74cbae1..9cf25059d 100644
--- a/pkg/trait/environment_test.go
+++ b/pkg/trait/environment_test.go
@@ -25,11 +25,11 @@ import (
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+ "k8s.io/utils/pointer"
v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
"github.com/apache/camel-k/pkg/util/camel"
"github.com/apache/camel-k/pkg/util/kubernetes"
- "github.com/apache/camel-k/pkg/util/test"
)
func TestDefaultEnvironment(t *testing.T) {
@@ -81,10 +81,10 @@ func TestEnabledContainerMetaDataEnvVars(t *testing.T) {
assert.Nil(t, err)
env := mockEnvironment(c)
- env.Integration.Spec.Traits = map[string]v1.TraitSpec{
- "environment": test.TraitSpecFromMap(t, map[string]interface{}{
- "containerMeta": true,
- }),
+ env.Integration.Spec.Traits = v1.Traits{
+ Environment: &v1.EnvironmentTrait{
+ ContainerMeta: pointer.Bool(true),
+ },
}
env.Platform.ResyncStatusFullConfig()
@@ -120,10 +120,10 @@ func TestDisabledContainerMetaDataEnvVars(t *testing.T) {
assert.Nil(t, err)
env := mockEnvironment(c)
- env.Integration.Spec.Traits = map[string]v1.TraitSpec{
- "environment": test.TraitSpecFromMap(t, map[string]interface{}{
- "containerMeta": false,
- }),
+ env.Integration.Spec.Traits = v1.Traits{
+ Environment: &v1.EnvironmentTrait{
+ ContainerMeta: pointer.Bool(false),
+ },
}
env.Platform.ResyncStatusFullConfig()
@@ -160,10 +160,10 @@ func TestCustomEnvVars(t *testing.T) {
assert.Nil(t, err)
env := mockEnvironment(c)
- env.Integration.Spec.Traits = map[string]v1.TraitSpec{
- "environment": test.TraitSpecFromMap(t, map[string]interface{}{
- "vars": []string{"key1=val1", "key2 = val2"},
- }),
+ env.Integration.Spec.Traits = v1.Traits{
+ Environment: &v1.EnvironmentTrait{
+ Vars: []string{"key1=val1", "key2 = val2"},
+ },
}
env.Platform.ResyncStatusFullConfig()
diff --git a/pkg/trait/error_handler.go b/pkg/trait/error_handler.go
index faa26a662..b15c052cb 100644
--- a/pkg/trait/error_handler.go
+++ b/pkg/trait/error_handler.go
@@ -30,13 +30,9 @@ import (
"github.com/apache/camel-k/pkg/util"
)
-// The error-handler is a platform trait used to inject Error Handler source into the integration runtime.
-//
-// +camel-k:trait=error-handler.
type errorHandlerTrait struct {
- BaseTrait `property:",squash"`
- // The error handler ref name provided or found in application properties
- ErrorHandlerRef string `property:"ref" json:"ref,omitempty"`
+ BaseTrait
+ v1.ErrorHandlerTrait `property:",squash"`
}
func newErrorHandlerTrait() Trait {
diff --git a/pkg/trait/gc.go b/pkg/trait/gc.go
index cd8fc1bda..bcbd3b9c6 100644
--- a/pkg/trait/gc.go
+++ b/pkg/trait/gc.go
@@ -57,43 +57,31 @@ var (
diskCachedDiscovery discovery.CachedDiscoveryInterface
)
-type discoveryCacheType string
-
-const (
- disabledDiscoveryCache discoveryCacheType = "disabled"
- diskDiscoveryCache discoveryCacheType = "disk"
- memoryDiscoveryCache discoveryCacheType = "memory"
-)
-
-// The GC Trait garbage-collects all resources that are no longer necessary upon integration updates.
-//
-// +camel-k:trait=gc.
-type garbageCollectorTrait struct {
- BaseTrait `property:",squash"`
- // Discovery client cache to be used, either `disabled`, `disk` or `memory` (default `memory`)
- DiscoveryCache *discoveryCacheType `property:"discovery-cache" json:"discoveryCache,omitempty"`
+type gcTrait struct {
+ BaseTrait
+ v1.GCTrait `property:",squash"`
}
-func newGarbageCollectorTrait() Trait {
- return &garbageCollectorTrait{
+func newGCTrait() Trait {
+ return &gcTrait{
BaseTrait: NewBaseTrait("gc", 1200),
}
}
-func (t *garbageCollectorTrait) Configure(e *Environment) (bool, error) {
+func (t *gcTrait) Configure(e *Environment) (bool, error) {
if !pointer.BoolDeref(t.Enabled, true) {
return false, nil
}
if t.DiscoveryCache == nil {
- s := memoryDiscoveryCache
+ s := v1.MemoryDiscoveryCache
t.DiscoveryCache = &s
}
return e.IntegrationInPhase(v1.IntegrationPhaseInitialization) || e.IntegrationInRunningPhases(), nil
}
-func (t *garbageCollectorTrait) Apply(e *Environment) error {
+func (t *gcTrait) Apply(e *Environment) error {
if e.IntegrationInRunningPhases() && e.Integration.GetGeneration() > 1 {
// Register a post action that deletes the existing resources that are labelled
// with the previous integration generation(s).
@@ -122,7 +110,7 @@ func (t *garbageCollectorTrait) Apply(e *Environment) error {
return nil
}
-func (t *garbageCollectorTrait) garbageCollectResources(e *Environment) error {
+func (t *gcTrait) garbageCollectResources(e *Environment) error {
deletableGVKs, err := t.getDeletableTypes(e)
if err != nil {
return errors.Wrap(err, "cannot discover GVK types")
@@ -140,7 +128,7 @@ func (t *garbageCollectorTrait) garbageCollectResources(e *Environment) error {
return t.deleteEachOf(e.Ctx, deletableGVKs, e, selector)
}
-func (t *garbageCollectorTrait) deleteEachOf(ctx context.Context, deletableGVKs map[schema.GroupVersionKind]struct{}, e *Environment, selector labels.Selector) error {
+func (t *gcTrait) deleteEachOf(ctx context.Context, deletableGVKs map[schema.GroupVersionKind]struct{}, e *Environment, selector labels.Selector) error {
for GVK := range deletableGVKs {
resources := unstructured.UnstructuredList{
Object: map[string]interface{}{
@@ -179,7 +167,7 @@ func (t *garbageCollectorTrait) deleteEachOf(ctx context.Context, deletableGVKs
return nil
}
-func (t *garbageCollectorTrait) canBeDeleted(e *Environment, u unstructured.Unstructured) bool {
+func (t *gcTrait) canBeDeleted(e *Environment, u unstructured.Unstructured) bool {
// Only delete direct children of the integration, otherwise we can affect the behavior of external controllers (i.e. Knative)
for _, o := range u.GetOwnerReferences() {
if o.Kind == v1.IntegrationKind && strings.HasPrefix(o.APIVersion, v1.SchemeGroupVersion.Group) && o.Name == e.Integration.Name {
@@ -189,7 +177,7 @@ func (t *garbageCollectorTrait) canBeDeleted(e *Environment, u unstructured.Unst
return false
}
-func (t *garbageCollectorTrait) getDeletableTypes(e *Environment) (map[schema.GroupVersionKind]struct{}, error) {
+func (t *gcTrait) getDeletableTypes(e *Environment) (map[schema.GroupVersionKind]struct{}, error) {
lock.Lock()
defer lock.Unlock()
@@ -254,9 +242,9 @@ func (t *garbageCollectorTrait) getDeletableTypes(e *Environment) (map[schema.Gr
return collectableGVKs, nil
}
-func (t *garbageCollectorTrait) discoveryClient() (discovery.DiscoveryInterface, error) {
+func (t *gcTrait) discoveryClient() (discovery.DiscoveryInterface, error) {
switch *t.DiscoveryCache {
- case diskDiscoveryCache:
+ case v1.DiskDiscoveryCache:
if diskCachedDiscovery != nil {
return diskCachedDiscovery, nil
}
@@ -267,14 +255,14 @@ func (t *garbageCollectorTrait) discoveryClient() (discovery.DiscoveryInterface,
diskCachedDiscovery, err = disk.NewCachedDiscoveryClientForConfig(config, diskCacheDir, httpCacheDir, 10*time.Minute)
return diskCachedDiscovery, err
- case memoryDiscoveryCache:
+ case v1.MemoryDiscoveryCache:
if memoryCachedDiscovery != nil {
return memoryCachedDiscovery, nil
}
memoryCachedDiscovery = memory.NewMemCacheClient(t.Client.Discovery())
return memoryCachedDiscovery, nil
- case disabledDiscoveryCache, "":
+ case v1.DisabledDiscoveryCache, "":
return t.Client.Discovery(), nil
default:
diff --git a/pkg/trait/gc_test.go b/pkg/trait/gc_test.go
index 10dd4462c..e16823a6f 100644
--- a/pkg/trait/gc_test.go
+++ b/pkg/trait/gc_test.go
@@ -27,16 +27,16 @@ import (
"k8s.io/utils/pointer"
)
-func TestConfigureGarbageCollectorTraitDoesSucceed(t *testing.T) {
- gcTrait, environment := createNominalGarbageCollectorTest()
+func TestConfigureGCTraitDoesSucceed(t *testing.T) {
+ gcTrait, environment := createNominalGCTest()
configured, err := gcTrait.Configure(environment)
assert.True(t, configured)
assert.Nil(t, err)
}
-func TestConfigureDisabledGarbageCollectorTraitDoesNotSucceed(t *testing.T) {
- gcTrait, environment := createNominalGarbageCollectorTest()
+func TestConfigureDisabledGCTraitDoesNotSucceed(t *testing.T) {
+ gcTrait, environment := createNominalGCTest()
gcTrait.Enabled = pointer.Bool(false)
configured, err := gcTrait.Configure(environment)
@@ -46,7 +46,7 @@ func TestConfigureDisabledGarbageCollectorTraitDoesNotSucceed(t *testing.T) {
}
func TestApplyGarbageCollectorTraitFirstGenerationDoesSucceed(t *testing.T) {
- gcTrait, environment := createNominalGarbageCollectorTest()
+ gcTrait, environment := createNominalGCTest()
err := gcTrait.Apply(environment)
@@ -56,7 +56,7 @@ func TestApplyGarbageCollectorTraitFirstGenerationDoesSucceed(t *testing.T) {
}
func TestApplyGarbageCollectorTraitNextGenerationDoesSucceed(t *testing.T) {
- gcTrait, environment := createNominalGarbageCollectorTest()
+ gcTrait, environment := createNominalGCTest()
environment.Integration.Generation = 2
err := gcTrait.Apply(environment)
@@ -66,8 +66,8 @@ func TestApplyGarbageCollectorTraitNextGenerationDoesSucceed(t *testing.T) {
assert.Len(t, environment.PostActions, 1)
}
-func TestApplyGarbageCollectorTraitDuringInitializationPhaseSkipPostActions(t *testing.T) {
- gcTrait, environment := createNominalGarbageCollectorTest()
+func TestApplyGCTraitDuringInitializationPhaseSkipPostActions(t *testing.T) {
+ gcTrait, environment := createNominalGCTest()
environment.Integration.Status.Phase = v1.IntegrationPhaseInitialization
err := gcTrait.Apply(environment)
@@ -77,8 +77,8 @@ func TestApplyGarbageCollectorTraitDuringInitializationPhaseSkipPostActions(t *t
assert.Len(t, environment.PostActions, 0)
}
-func createNominalGarbageCollectorTest() (*garbageCollectorTrait, *Environment) {
- trait, _ := newGarbageCollectorTrait().(*garbageCollectorTrait)
+func createNominalGCTest() (*gcTrait, *Environment) {
+ trait, _ := newGCTrait().(*gcTrait)
trait.Enabled = pointer.Bool(true)
environment := &Environment{
diff --git a/pkg/trait/health.go b/pkg/trait/health.go
index 0dd2f26fa..274defcb3 100644
--- a/pkg/trait/health.go
+++ b/pkg/trait/health.go
@@ -34,50 +34,18 @@ const (
defaultReadinessProbePath = "/q/health/ready"
)
-// The health trait is responsible for configuring the health probes on the integration container.
-//
-// It's disabled by default.
-//
-// +camel-k:trait=health.
type healthTrait struct {
- BaseTrait `property:",squash"`
-
- // Configures the liveness probe for the integration container (default `false`).
- LivenessProbeEnabled *bool `property:"liveness-probe-enabled" json:"livenessProbeEnabled,omitempty"`
- // Scheme to use when connecting to the liveness probe (default `HTTP`).
- LivenessScheme string `property:"liveness-scheme" json:"livenessScheme,omitempty"`
- // Number of seconds after the container has started before the liveness probe is initiated.
- LivenessInitialDelay int32 `property:"liveness-initial-delay" json:"livenessInitialDelay,omitempty"`
- // Number of seconds after which the liveness probe times out.
- LivenessTimeout int32 `property:"liveness-timeout" json:"livenessTimeout,omitempty"`
- // How often to perform the liveness probe.
- LivenessPeriod int32 `property:"liveness-period" json:"livenessPeriod,omitempty"`
- // Minimum consecutive successes for the liveness probe to be considered successful after having failed.
- LivenessSuccessThreshold int32 `property:"liveness-success-threshold" json:"livenessSuccessThreshold,omitempty"`
- // Minimum consecutive failures for the liveness probe to be considered failed after having succeeded.
- LivenessFailureThreshold int32 `property:"liveness-failure-threshold" json:"livenessFailureThreshold,omitempty"`
-
- // Configures the readiness probe for the integration container (default `true`).
- ReadinessProbeEnabled *bool `property:"readiness-probe-enabled" json:"readinessProbeEnabled,omitempty"`
- // Scheme to use when connecting to the readiness probe (default `HTTP`).
- ReadinessScheme string `property:"readiness-scheme" json:"readinessScheme,omitempty"`
- // Number of seconds after the container has started before the readiness probe is initiated.
- ReadinessInitialDelay int32 `property:"readiness-initial-delay" json:"readinessInitialDelay,omitempty"`
- // Number of seconds after which the readiness probe times out.
- ReadinessTimeout int32 `property:"readiness-timeout" json:"readinessTimeout,omitempty"`
- // How often to perform the readiness probe.
- ReadinessPeriod int32 `property:"readiness-period" json:"readinessPeriod,omitempty"`
- // Minimum consecutive successes for the readiness probe to be considered successful after having failed.
- ReadinessSuccessThreshold int32 `property:"readiness-success-threshold" json:"readinessSuccessThreshold,omitempty"`
- // Minimum consecutive failures for the readiness probe to be considered failed after having succeeded.
- ReadinessFailureThreshold int32 `property:"readiness-failure-threshold" json:"readinessFailureThreshold,omitempty"`
+ BaseTrait
+ v1.HealthTrait `property:",squash"`
}
func newHealthTrait() Trait {
return &healthTrait{
- BaseTrait: NewBaseTrait("health", 1700),
- LivenessScheme: string(corev1.URISchemeHTTP),
- ReadinessScheme: string(corev1.URISchemeHTTP),
+ BaseTrait: NewBaseTrait("health", 1700),
+ HealthTrait: v1.HealthTrait{
+ LivenessScheme: string(corev1.URISchemeHTTP),
+ ReadinessScheme: string(corev1.URISchemeHTTP),
+ },
}
}
diff --git a/pkg/trait/ingress.go b/pkg/trait/ingress.go
index 66dbcf802..31a0dd030 100644
--- a/pkg/trait/ingress.go
+++ b/pkg/trait/ingress.go
@@ -29,24 +29,17 @@ import (
v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
)
-// The Ingress trait can be used to expose the service associated with the integration
-// to the outside world with a Kubernetes Ingress.
-//
-// It's enabled by default whenever a Service is added to the integration (through the `service` trait).
-//
-// +camel-k:trait=ingress.
type ingressTrait struct {
- BaseTrait `property:",squash"`
- // **Required**. To configure the host exposed by the ingress.
- Host string `property:"host" json:"host,omitempty"`
- // To automatically add an ingress whenever the integration uses a HTTP endpoint consumer.
- Auto *bool `property:"auto" json:"auto,omitempty"`
+ BaseTrait
+ v1.IngressTrait `property:",squash"`
}
func newIngressTrait() Trait {
return &ingressTrait{
BaseTrait: NewBaseTrait("ingress", 2400),
- Host: "",
+ IngressTrait: v1.IngressTrait{
+ Host: "",
+ },
}
}
diff --git a/pkg/trait/init.go b/pkg/trait/init.go
index 7076c6a15..b8005da52 100644
--- a/pkg/trait/init.go
+++ b/pkg/trait/init.go
@@ -32,7 +32,8 @@ import (
const flowsInternalSourceName = "camel-k-embedded-flow.yaml"
type initTrait struct {
- BaseTrait `property:",squash"`
+ BaseTrait
+ v1.Trait
}
func NewInitTrait() Trait {
diff --git a/pkg/trait/istio.go b/pkg/trait/istio.go
index 1ad3daacb..12013a532 100644
--- a/pkg/trait/istio.go
+++ b/pkg/trait/istio.go
@@ -20,22 +20,16 @@ package trait
import (
"strconv"
+ v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
appsv1 "k8s.io/api/apps/v1"
"k8s.io/utils/pointer"
servingv1 "knative.dev/serving/pkg/apis/serving/v1"
)
-// The Istio trait allows configuring properties related to the Istio service mesh,
-// such as sidecar injection and outbound IP ranges.
-//
-// +camel-k:trait=istio.
type istioTrait struct {
- BaseTrait `property:",squash"`
- // Configures a (comma-separated) list of CIDR subnets that should not be intercepted by the Istio proxy (`10.0.0.0/8,172.16.0.0/12,192.168.0.0/16` by default).
- Allow string `property:"allow" json:"allow,omitempty"`
- // Forces the value for labels `sidecar.istio.io/inject`. By default the label is set to `true` on deployment and not set on Knative Service.
- Inject *bool `property:"inject" json:"inject,omitempty"`
+ BaseTrait
+ v1.IstioTrait `property:",squash"`
}
const (
@@ -46,7 +40,9 @@ const (
func newIstioTrait() Trait {
return &istioTrait{
BaseTrait: NewBaseTrait("istio", 2300),
- Allow: "10.0.0.0/8,172.16.0.0/12,192.168.0.0/16",
+ IstioTrait: v1.IstioTrait{
+ Allow: "10.0.0.0/8,172.16.0.0/12,192.168.0.0/16",
+ },
}
}
diff --git a/pkg/trait/istio_test.go b/pkg/trait/istio_test.go
index c322fc064..b829d6d32 100644
--- a/pkg/trait/istio_test.go
+++ b/pkg/trait/istio_test.go
@@ -25,13 +25,13 @@ import (
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+ "k8s.io/utils/pointer"
serving "knative.dev/serving/pkg/apis/serving/v1"
v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
"github.com/apache/camel-k/pkg/util/camel"
"github.com/apache/camel-k/pkg/util/kubernetes"
- "github.com/apache/camel-k/pkg/util/test"
)
func NewIstioTestEnv(t *testing.T, d *appsv1.Deployment, s *serving.Service, enabled bool) Environment {
@@ -48,7 +48,7 @@ func NewIstioTestEnv(t *testing.T, d *appsv1.Deployment, s *serving.Service, ena
Phase: v1.IntegrationPhaseDeploying,
},
Spec: v1.IntegrationSpec{
- Traits: make(map[string]v1.TraitSpec),
+ Traits: v1.Traits{},
},
},
Platform: &v1.IntegrationPlatform{
@@ -66,9 +66,11 @@ func NewIstioTestEnv(t *testing.T, d *appsv1.Deployment, s *serving.Service, ena
env.Platform.ResyncStatusFullConfig()
if enabled {
- env.Integration.Spec.Traits["istio"] = test.TraitSpecFromMap(t, map[string]interface{}{
- "enabled": true,
- })
+ env.Integration.Spec.Traits.Istio = &v1.IstioTrait{
+ Trait: v1.Trait{
+ Enabled: pointer.Bool(true),
+ },
+ }
}
return env
@@ -111,10 +113,8 @@ func TestIstioForcedInjectTrue(t *testing.T) {
}
env := NewIstioTestEnv(t, &d, &s, true)
- env.Integration.Spec.Traits["istio"] = test.TraitSpecFromMap(t, map[string]interface{}{
- "enabled": true,
- "inject": true,
- })
+ env.Integration.Spec.Traits.Istio.Enabled = pointer.Bool(true)
+ env.Integration.Spec.Traits.Istio.Inject = pointer.Bool(true)
err := env.Catalog.apply(&env)
assert.Nil(t, err)
@@ -138,10 +138,8 @@ func TestIstioForcedInjectFalse(t *testing.T) {
}
env := NewIstioTestEnv(t, &d, &s, true)
- env.Integration.Spec.Traits["istio"] = test.TraitSpecFromMap(t, map[string]interface{}{
- "enabled": true,
- "inject": false,
- })
+ env.Integration.Spec.Traits.Istio.Enabled = pointer.Bool(true)
+ env.Integration.Spec.Traits.Istio.Inject = pointer.Bool(false)
err := env.Catalog.apply(&env)
assert.Nil(t, err)
diff --git a/pkg/trait/jolokia.go b/pkg/trait/jolokia.go
index ca2725430..eae076c1a 100644
--- a/pkg/trait/jolokia.go
+++ b/pkg/trait/jolokia.go
@@ -29,50 +29,17 @@ import (
"github.com/apache/camel-k/pkg/util"
)
-// The Jolokia trait activates and configures the Jolokia Java agent.
-//
-// See https://jolokia.org/reference/html/agents.html
-//
-// +camel-k:trait=jolokia
-// nolint: tagliatelle
type jolokiaTrait struct {
- BaseTrait `property:",squash"`
- // The PEM encoded CA certification file path, used to verify client certificates,
- // applicable when `protocol` is `https` and `use-ssl-client-authentication` is `true`
- // (default `/var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt` for OpenShift).
- CaCert *string `property:"ca-cert" json:"CACert,omitempty"`
- // The principal(s) which must be given in a client certificate to allow access to the Jolokia endpoint,
- // applicable when `protocol` is `https` and `use-ssl-client-authentication` is `true`
- // (default `clientPrincipal=cn=system:master-proxy`, `cn=hawtio-online.hawtio.svc` and `cn=fuse-console.fuse.svc` for OpenShift).
- ClientPrincipal []string `property:"client-principal" json:"clientPrincipal,omitempty"`
- // Listen for multicast requests (default `false`)
- DiscoveryEnabled *bool `property:"discovery-enabled" json:"discoveryEnabled,omitempty"`
- // Mandate the client certificate contains a client flag in the extended key usage section,
- // applicable when `protocol` is `https` and `use-ssl-client-authentication` is `true`
- // (default `true` for OpenShift).
- ExtendedClientCheck *bool `property:"extended-client-check" json:"extendedClientCheck,omitempty"`
- // The Host address to which the Jolokia agent should bind to. If `"\*"` or `"0.0.0.0"` is given,
- // the servers binds to every network interface (default `"*"`).
- Host *string `property:"host" json:"host,omitempty"`
- // The password used for authentication, applicable when the `user` option is set.
- Password *string `property:"password" json:"password,omitempty"`
- // The Jolokia endpoint port (default `8778`).
- Port int `property:"port" json:"port,omitempty"`
- // The protocol to use, either `http` or `https` (default `https` for OpenShift)
- Protocol *string `property:"protocol" json:"protocol,omitempty"`
- // The user to be used for authentication
- User *string `property:"user" json:"user,omitempty"`
- // Whether client certificates should be used for authentication (default `true` for OpenShift).
- UseSslClientAuthentication *bool `property:"use-ssl-client-authentication" json:"useSSLClientAuthentication,omitempty"`
- // A list of additional Jolokia options as defined
- // in https://jolokia.org/reference/html/agents.html#agent-jvm-config[JVM agent configuration options]
- Options []string `property:"options" json:"options,omitempty"`
+ BaseTrait
+ v1.JolokiaTrait `property:",squash"`
}
func newJolokiaTrait() Trait {
return &jolokiaTrait{
BaseTrait: NewBaseTrait("jolokia", 1800),
- Port: 8778,
+ JolokiaTrait: v1.JolokiaTrait{
+ Port: 8778,
+ },
}
}
diff --git a/pkg/trait/jvm.go b/pkg/trait/jvm.go
index 58fda571b..0cca3267a 100644
--- a/pkg/trait/jvm.go
+++ b/pkg/trait/jvm.go
@@ -43,30 +43,18 @@ import (
"github.com/apache/camel-k/pkg/util/envvar"
)
-// The JVM trait is used to configure the JVM that runs the integration.
-//
-// +camel-k:trait=jvm.
type jvmTrait struct {
- BaseTrait `property:",squash"`
- // Activates remote debugging, so that a debugger can be attached to the JVM, e.g., using port-forwarding
- Debug *bool `property:"debug" json:"debug,omitempty"`
- // Suspends the target JVM immediately before the main class is loaded
- DebugSuspend *bool `property:"debug-suspend" json:"debugSuspend,omitempty"`
- // Prints the command used the start the JVM in the container logs (default `true`)
- PrintCommand *bool `property:"print-command" json:"printCommand,omitempty"`
- // Transport address at which to listen for the newly launched JVM (default `*:5005`)
- DebugAddress string `property:"debug-address" json:"debugAddress,omitempty"`
- // A list of JVM options
- Options []string `property:"options" json:"options,omitempty"`
- // Additional JVM classpath (use `Linux` classpath separator)
- Classpath string `property:"classpath" json:"classpath,omitempty"`
+ BaseTrait
+ v1.JVMTrait `property:",squash"`
}
func newJvmTrait() Trait {
return &jvmTrait{
- BaseTrait: NewBaseTrait("jvm", 2000),
- DebugAddress: "*:5005",
- PrintCommand: pointer.Bool(true),
+ BaseTrait: NewBaseTrait("jvm", 2000),
+ JVMTrait: v1.JVMTrait{
+ DebugAddress: "*:5005",
+ PrintCommand: pointer.Bool(true),
+ },
}
}
diff --git a/pkg/trait/kamelets.go b/pkg/trait/kamelets.go
index 9109235d8..821b08761 100644
--- a/pkg/trait/kamelets.go
+++ b/pkg/trait/kamelets.go
@@ -39,15 +39,9 @@ import (
"github.com/apache/camel-k/pkg/util/kamelets"
)
-// The kamelets trait is a platform trait used to inject Kamelets into the integration runtime.
-//
-// +camel-k:trait=kamelets.
type kameletsTrait struct {
- BaseTrait `property:",squash"`
- // Automatically inject all referenced Kamelets and their default configuration (enabled by default)
- Auto *bool `property:"auto"`
- // Comma separated list of Kamelet names to load into the current integration
- List string `property:"list"`
+ BaseTrait
+ v1.KameletsTrait `property:",squash"`
}
type configurationKey struct {
diff --git a/pkg/trait/knative.go b/pkg/trait/knative.go
index 1ec29109f..34fcd8375 100644
--- a/pkg/trait/knative.go
+++ b/pkg/trait/knative.go
@@ -45,46 +45,9 @@ import (
"github.com/apache/camel-k/pkg/util/kubernetes"
)
-// The Knative trait automatically discovers addresses of Knative resources and inject them into the
-// running integration.
-//
-// The full Knative configuration is injected in the CAMEL_KNATIVE_CONFIGURATION in JSON format.
-// The Camel Knative component will then use the full configuration to configure the routes.
-//
-// The trait is enabled by default when the Knative profile is active.
-//
-// +camel-k:trait=knative.
type knativeTrait struct {
- BaseTrait `property:",squash"`
- // Can be used to inject a Knative complete configuration in JSON format.
- Configuration string `property:"configuration" json:"configuration,omitempty"`
- // List of channels used as source of integration routes.
- // Can contain simple channel names or full Camel URIs.
- ChannelSources []string `property:"channel-sources" json:"channelSources,omitempty"`
- // List of channels used as destination of integration routes.
- // Can contain simple channel names or full Camel URIs.
- ChannelSinks []string `property:"channel-sinks" json:"channelSinks,omitempty"`
- // List of channels used as source of integration routes.
- EndpointSources []string `property:"endpoint-sources" json:"endpointSources,omitempty"`
- // List of endpoints used as destination of integration routes.
- // Can contain simple endpoint names or full Camel URIs.
- EndpointSinks []string `property:"endpoint-sinks" json:"endpointSinks,omitempty"`
- // List of event types that the integration will be subscribed to.
- // Can contain simple event types or full Camel URIs (to use a specific broker different from "default").
- EventSources []string `property:"event-sources" json:"eventSources,omitempty"`
- // List of event types that the integration will produce.
- // Can contain simple event types or full Camel URIs (to use a specific broker).
- EventSinks []string `property:"event-sinks" json:"eventSinks,omitempty"`
- // Enables filtering on events based on the header "ce-knativehistory". Since this header has been removed in newer versions of
- // Knative, filtering is disabled by default.
- FilterSourceChannels *bool `property:"filter-source-channels" json:"filterSourceChannels,omitempty"`
- // Allows binding the integration to a sink via a Knative SinkBinding resource.
- // This can be used when the integration targets a single sink.
- // It's enabled by default when the integration targets a single sink
- // (except when the integration is owned by a Knative source).
- SinkBinding *bool `property:"sink-binding" json:"sinkBinding,omitempty"`
- // Enable automatic discovery of all trait properties.
- Auto *bool `property:"auto" json:"auto,omitempty"`
+ BaseTrait
+ v1.KnativeTrait `property:",squash"`
}
const (
diff --git a/pkg/trait/knative_service.go b/pkg/trait/knative_service.go
index 8a7b106c9..351c92044 100644
--- a/pkg/trait/knative_service.go
+++ b/pkg/trait/knative_service.go
@@ -46,46 +46,9 @@ const (
knativeServingRolloutDurationAnnotation = "serving.knative.dev/rolloutDuration"
)
-// The Knative Service trait allows configuring options when running the Integration as a Knative service, instead of
-// a standard Kubernetes Deployment.
-//
-// Running an Integration as a Knative Service enables auto-scaling (and scaling-to-zero), but those features
-// are only relevant when the Camel route(s) use(s) an HTTP endpoint consumer.
-//
-// +camel-k:trait=knative-service.
type knativeServiceTrait struct {
- BaseTrait `property:",squash"`
- // 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" 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" 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" 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" 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" json:"maxScale,omitempty"`
- // Enables to gradually shift traffic to the latest Revision and sets the rollout duration.
- // It's disabled by default and must be expressed as a Golang `time.Duration` string representation,
- // rounded to a second precision.
- RolloutDuration string `property:"rollout-duration" json:"rolloutDuration,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" json:"auto,omitempty"`
+ BaseTrait
+ v1.KnativeServiceTrait `property:",squash"`
}
var _ ControllerStrategySelector = &knativeServiceTrait{}
diff --git a/pkg/trait/knative_service_test.go b/pkg/trait/knative_service_test.go
index 47531649b..e3c91637b 100644
--- a/pkg/trait/knative_service_test.go
+++ b/pkg/trait/knative_service_test.go
@@ -24,6 +24,7 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+ "k8s.io/utils/pointer"
serving "knative.dev/serving/pkg/apis/serving/v1"
@@ -87,10 +88,12 @@ func TestKnativeService(t *testing.T) {
{Type: "secret", Value: "my-secret"},
{Type: "property", Value: "my-property=my-property-value"},
},
- Traits: map[string]v1.TraitSpec{
- "knative-service": test.TraitSpecFromMap(t, map[string]interface{}{
- "enabled": true,
- }),
+ Traits: v1.Traits{
+ KnativeService: &v1.KnativeServiceTrait{
+ Trait: v1.Trait{
+ Enabled: pointer.Bool(true),
+ },
+ },
},
},
},
@@ -201,17 +204,19 @@ func TestKnativeServiceWithCustomContainerName(t *testing.T) {
Spec: v1.IntegrationSpec{
Profile: v1.TraitProfileKnative,
- Traits: map[string]v1.TraitSpec{
- "deployer": test.TraitSpecFromMap(t, map[string]interface{}{
- "kind": "knative-service",
- }),
- "knative-service": test.TraitSpecFromMap(t, map[string]interface{}{
- "enabled": true,
- "auto": false,
- }),
- "container": test.TraitSpecFromMap(t, map[string]interface{}{
- "name": "my-container-name",
- }),
+ Traits: v1.Traits{
+ Deployer: &v1.DeployerTrait{
+ Kind: "knative-service",
+ },
+ KnativeService: &v1.KnativeServiceTrait{
+ Trait: v1.Trait{
+ Enabled: pointer.Bool(true),
+ },
+ Auto: pointer.Bool(false),
+ },
+ Container: &v1.ContainerTrait{
+ Name: "my-container-name",
+ },
},
},
},
@@ -248,10 +253,10 @@ func TestKnativeServiceWithCustomContainerName(t *testing.T) {
assert.NotNil(t, s)
- trait := test.TraitSpecToMap(t, environment.Integration.Spec.Traits["container"])
+ trait := environment.Integration.Spec.Traits.Container
assert.Equal(
t,
- trait["name"],
+ trait.Name,
s.Spec.ConfigurationSpec.Template.Spec.Containers[0].Name,
)
}
@@ -359,10 +364,10 @@ func TestKnativeServiceWithRollout(t *testing.T) {
Language: v1.LanguageXML,
},
},
- Traits: map[string]v1.TraitSpec{
- "knative-service": test.TraitSpecFromMap(t, map[string]interface{}{
- "rolloutDuration": "60s",
- }),
+ Traits: v1.Traits{
+ KnativeService: &v1.KnativeServiceTrait{
+ RolloutDuration: "60s",
+ },
},
},
},
diff --git a/pkg/trait/knative_test.go b/pkg/trait/knative_test.go
index ac63b66b5..12bc8d4b0 100644
--- a/pkg/trait/knative_test.go
+++ b/pkg/trait/knative_test.go
@@ -24,6 +24,7 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+ "k8s.io/utils/pointer"
eventingduckv1 "knative.dev/eventing/pkg/apis/duck/v1"
eventing "knative.dev/eventing/pkg/apis/eventing/v1"
@@ -62,17 +63,19 @@ func TestKnativeEnvConfigurationFromTrait(t *testing.T) {
Profile: v1.TraitProfileKnative,
Sources: []v1.SourceSpec{},
Resources: []v1.ResourceSpec{},
- Traits: map[string]v1.TraitSpec{
- "knative": test.TraitSpecFromMap(t, map[string]interface{}{
- "enabled": true,
- "auto": false,
- "channelSources": []string{"channel-source-1"},
- "channelSinks": []string{"channel-sink-1"},
- "endpointSources": []string{"endpoint-source-1"},
- "endpointSinks": []string{"endpoint-sink-1", "endpoint-sink-2"},
- "eventSources": []string{"knative:event"},
- "eventSinks": []string{"knative:event"},
- }),
+ Traits: v1.Traits{
+ Knative: &v1.KnativeTrait{
+ Trait: v1.Trait{
+ Enabled: pointer.Bool(true),
+ },
+ Auto: pointer.Bool(false),
+ ChannelSources: []string{"channel-source-1"},
+ ChannelSinks: []string{"channel-sink-1"},
+ EndpointSources: []string{"endpoint-source-1"},
+ EndpointSinks: []string{"endpoint-sink-1", "endpoint-sink-2"},
+ EventSources: []string{"knative:event"},
+ EventSinks: []string{"knative:event"},
+ },
},
},
},
@@ -188,10 +191,12 @@ func TestKnativeEnvConfigurationFromSource(t *testing.T) {
},
},
Resources: []v1.ResourceSpec{},
- Traits: map[string]v1.TraitSpec{
- "knative": test.TraitSpecFromMap(t, map[string]interface{}{
- "enabled": true,
- }),
+ Traits: v1.Traits{
+ Knative: &v1.KnativeTrait{
+ Trait: v1.Trait{
+ Enabled: pointer.Bool(true),
+ },
+ },
},
},
},
@@ -373,10 +378,12 @@ func NewFakeEnvironment(t *testing.T, source v1.SourceSpec) Environment {
source,
},
Resources: []v1.ResourceSpec{},
- Traits: map[string]v1.TraitSpec{
- "knative": test.TraitSpecFromMap(t, map[string]interface{}{
- "enabled": true,
- }),
+ Traits: v1.Traits{
+ Knative: &v1.KnativeTrait{
+ Trait: v1.Trait{
+ Enabled: pointer.Bool(true),
+ },
+ },
},
},
},
diff --git a/pkg/trait/logging.go b/pkg/trait/logging.go
index 5b3237123..bb13043b1 100644
--- a/pkg/trait/logging.go
+++ b/pkg/trait/logging.go
@@ -20,6 +20,7 @@ package trait
import (
"k8s.io/utils/pointer"
+ v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
"github.com/apache/camel-k/pkg/util/envvar"
)
@@ -32,28 +33,17 @@ const (
defaultLogLevel = "INFO"
)
-// The Logging trait is used to configure Integration runtime logging options (such as color and format).
-// The logging backend is provided by Quarkus, whose configuration is documented at https://quarkus.io/guides/logging.
-//
-// +camel-k:trait=logging.
type loggingTrait struct {
- BaseTrait `property:",squash"`
- // Colorize the log output
- Color *bool `property:"color" json:"color,omitempty"`
- // Logs message format
- Format string `property:"format" json:"format,omitempty"`
- // Adjust the logging level (defaults to INFO)
- Level string `property:"level" json:"level,omitempty"`
- // Output the logs in JSON
- JSON *bool `property:"json" json:"json,omitempty"`
- // Enable "pretty printing" of the JSON logs
- JSONPrettyPrint *bool `property:"json-pretty-print" json:"jsonPrettyPrint,omitempty"`
+ BaseTrait
+ v1.LoggingTrait `property:",squash"`
}
func newLoggingTraitTrait() Trait {
return &loggingTrait{
BaseTrait: NewBaseTrait("logging", 800),
- Level: defaultLogLevel,
+ LoggingTrait: v1.LoggingTrait{
+ Level: defaultLogLevel,
+ },
}
}
diff --git a/pkg/trait/logging_test.go b/pkg/trait/logging_test.go
index 9c142e3c9..519932c91 100644
--- a/pkg/trait/logging_test.go
+++ b/pkg/trait/logging_test.go
@@ -25,11 +25,11 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+ "k8s.io/utils/pointer"
v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
"github.com/apache/camel-k/pkg/util/camel"
"github.com/apache/camel-k/pkg/util/kubernetes"
- "github.com/apache/camel-k/pkg/util/test"
)
func createLoggingTestEnv(t *testing.T, color bool, json bool, jsonPrettyPrint bool, logLevel string, logFormat string) *Environment {
@@ -54,14 +54,14 @@ func createLoggingTestEnv(t *testing.T, color bool, json bool, jsonPrettyPrint b
},
Spec: v1.IntegrationSpec{
Profile: v1.TraitProfileOpenShift,
- Traits: map[string]v1.TraitSpec{
- "logging": test.TraitSpecFromMap(t, map[string]interface{}{
- "color": color,
- "format": logFormat,
- "json": json,
- "json-pretty-print": jsonPrettyPrint,
- "level": logLevel,
- }),
+ Traits: v1.Traits{
+ Logging: &v1.LoggingTrait{
+ Color: pointer.Bool(color),
+ Format: logFormat,
+ JSON: pointer.Bool(json),
+ JSONPrettyPrint: pointer.Bool(jsonPrettyPrint),
+ Level: logLevel,
+ },
},
},
},
diff --git a/pkg/trait/mount.go b/pkg/trait/mount.go
index 039e3ccc3..fb81840c7 100644
--- a/pkg/trait/mount.go
+++ b/pkg/trait/mount.go
@@ -35,24 +35,9 @@ import (
utilResource "github.com/apache/camel-k/pkg/util/resource"
)
-// The Mount trait can be used to configure volumes mounted on the Integration Pods.
-//
-// +camel-k:trait=mount
-// nolint: tagliatelle
type mountTrait struct {
- BaseTrait `property:",squash"`
- // A list of configuration pointing to configmap/secret.
- // The configuration are expected to be UTF-8 resources as they are processed by runtime Camel Context and tried to be parsed as property files.
- // They are also made available on the classpath in order to ease their usage directly from the Route.
- // Syntax: [configmap|secret]:name[/key], where name represents the resource name and key optionally represents the resource key to be filtered
- Configs []string `property:"configs" json:"configs,omitempty"`
- // A list of resources (text or binary content) pointing to configmap/secret.
- // The resources are expected to be any resource type (text or binary content).
- // The destination path can be either a default location or any path specified by the user.
- // Syntax: [configmap|secret]:name[/key][@path], where name represents the resource name, key optionally represents the resource key to be filtered and path represents the destination path
- Resources []string `property:"resources" json:"resources,omitempty"`
- // A list of Persistent Volume Claims to be mounted. Syntax: [pvcname:/container/path]
- Volumes []string `property:"volumes" json:"volumes,omitempty"`
+ BaseTrait
+ v1.MountTrait `property:",squash"`
}
func newMountTrait() Trait {
diff --git a/pkg/trait/mount_test.go b/pkg/trait/mount_test.go
index 922124448..34a6e4924 100644
--- a/pkg/trait/mount_test.go
+++ b/pkg/trait/mount_test.go
@@ -38,7 +38,7 @@ func TestMountVolumesEmpty(t *testing.T) {
traitCatalog := NewCatalog(nil)
environment := getNominalEnv(t, traitCatalog)
- environment.Integration.Spec.Traits = map[string]v1.TraitSpec{}
+ environment.Integration.Spec.Traits = v1.Traits{} // empty traits
environment.Platform.ResyncStatusFullConfig()
err := traitCatalog.apply(environment)
@@ -153,12 +153,12 @@ func getNominalEnv(t *testing.T, traitCatalog *Catalog) *Environment {
Language: v1.LanguageJavaScript,
},
},
- Traits: map[string]v1.TraitSpec{
- "mount": test.TraitSpecFromMap(t, map[string]interface{}{
- "configs": []string{"configmap:my-cm"},
- "resources": []string{"secret:my-secret"},
- "volumes": []string{"my-pvc:/over/the/rainbow"},
- }),
+ Traits: v1.Traits{
+ Mount: &v1.MountTrait{
+ Configs: []string{"configmap:my-cm"},
+ Resources: []string{"secret:my-secret"},
+ Volumes: []string{"my-pvc:/over/the/rainbow"},
+ },
},
},
},
diff --git a/pkg/trait/openapi.go b/pkg/trait/openapi.go
index d1392bc30..1d48367d0 100644
--- a/pkg/trait/openapi.go
+++ b/pkg/trait/openapi.go
@@ -47,13 +47,9 @@ import (
"github.com/apache/camel-k/pkg/util/maven"
)
-// The OpenAPI DSL trait is internally used to allow creating integrations from a OpenAPI specs.
-//
-// +camel-k:trait=openapi.
type openAPITrait struct {
- BaseTrait `property:",squash"`
- // The configmaps holding the spec of the OpenAPI
- Configmaps []string `property:"configmaps" json:"configmaps,omitempty"`
+ BaseTrait
+ v1.OpenAPITrait `property:",squash"`
}
func newOpenAPITrait() Trait {
diff --git a/pkg/trait/owner.go b/pkg/trait/owner.go
index 5bff48922..0ac1f0259 100644
--- a/pkg/trait/owner.go
+++ b/pkg/trait/owner.go
@@ -27,16 +27,9 @@ import (
v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
)
-// The Owner trait ensures that all created resources belong to the integration being created
-// and transfers annotations and labels on the integration onto these owned resources.
-//
-// +camel-k:trait=owner.
type ownerTrait struct {
- BaseTrait `property:",squash"`
- // 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"`
+ BaseTrait
+ v1.OwnerTrait `property:",squash"`
}
func newOwnerTrait() Trait {
diff --git a/pkg/trait/owner_test.go b/pkg/trait/owner_test.go
index 2bf1a328f..96aaa8491 100644
--- a/pkg/trait/owner_test.go
+++ b/pkg/trait/owner_test.go
@@ -26,7 +26,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
- "github.com/apache/camel-k/pkg/util/test"
)
func TestOwner(t *testing.T) {
@@ -44,11 +43,11 @@ func SetUpOwnerEnvironment(t *testing.T) *Environment {
t.Helper()
env := createTestEnv(t, v1.IntegrationPlatformClusterOpenShift, "camel:core")
- env.Integration.Spec.Traits = map[string]v1.TraitSpec{
- "owner": test.TraitSpecFromMap(t, map[string]interface{}{
- "targetLabels": []string{"com.mycompany/mylabel1"},
- "targetAnnotations": []string{"com.mycompany/myannotation2"},
- }),
+ env.Integration.Spec.Traits = v1.Traits{
+ Owner: &v1.OwnerTrait{
+ TargetLabels: []string{"com.mycompany/mylabel1"},
+ TargetAnnotations: []string{"com.mycompany/myannotation2"},
+ },
}
env.Integration.SetLabels(map[string]string{
diff --git a/pkg/trait/pdb.go b/pkg/trait/pdb.go
index 92fcbf9b9..cb57e4a99 100644
--- a/pkg/trait/pdb.go
+++ b/pkg/trait/pdb.go
@@ -28,19 +28,9 @@ import (
v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
)
-// The PDB trait allows to configure the PodDisruptionBudget resource for the Integration pods.
-//
-// +camel-k:trait=pdb.
type pdbTrait struct {
- BaseTrait `property:",squash"`
- // The number of pods for the Integration that must still be available after an eviction.
- // It can be either an absolute number or a percentage.
- // Only one of `min-available` and `max-unavailable` can be specified.
- MinAvailable string `property:"min-available" json:"minAvailable,omitempty"`
- // The number of pods for the Integration that can be unavailable after an eviction.
- // It can be either an absolute number or a percentage (default `1` if `min-available` is also not set).
- // Only one of `max-unavailable` and `min-available` can be specified.
- MaxUnavailable string `property:"max-unavailable" json:"maxUnavailable,omitempty"`
+ BaseTrait
+ v1.PDBTrait `property:",squash"`
}
func newPdbTrait() Trait {
diff --git a/pkg/trait/platform.go b/pkg/trait/platform.go
index c80c99c2f..6c1cebabe 100644
--- a/pkg/trait/platform.go
+++ b/pkg/trait/platform.go
@@ -26,21 +26,9 @@ import (
"github.com/apache/camel-k/pkg/util/openshift"
)
-// The platform trait is a base trait that is used to assign an integration platform to an integration.
-//
-// In case the platform is missing, the trait is allowed to create a default platform.
-// This feature is especially useful in contexts where there's no need to provide a custom configuration for the platform
-// (e.g. on OpenShift the default settings work, since there's an embedded container image registry).
-//
-// +camel-k:trait=platform.
type platformTrait struct {
- BaseTrait `property:",squash"`
- // To create a default (empty) platform when the platform is missing.
- CreateDefault *bool `property:"create-default" json:"createDefault,omitempty"`
- // Indicates if the platform should be created globally in the case of global operator (default true).
- Global *bool `property:"global" json:"global,omitempty"`
- // To automatically detect from the environment if a default platform can be created (it will be created on OpenShift only).
- Auto *bool `property:"auto" json:"auto,omitempty"`
+ BaseTrait
+ v1.PlatformTrait `property:",squash"`
}
func newPlatformTrait() Trait {
diff --git a/pkg/trait/pod.go b/pkg/trait/pod.go
index c6415189e..6bdc6763f 100644
--- a/pkg/trait/pod.go
+++ b/pkg/trait/pod.go
@@ -32,16 +32,9 @@ import (
v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
)
-// The pod trait allows the customization of the Integration pods.
-// It applies the `PodSpecTemplate` struct contained in the Integration `.spec.podTemplate` field,
-// into the Integration deployment Pods template, using strategic merge patch.
-//
-// This can be used to customize the container where Camel routes execute,
-// by using the `integration` container name.
-//
-// +camel-k:trait=pod.
type podTrait struct {
- BaseTrait `property:",squash"`
+ BaseTrait
+ v1.PodTrait `property:",squash"`
}
func newPodTrait() Trait {
diff --git a/pkg/trait/prometheus.go b/pkg/trait/prometheus.go
index 9dd90cf36..9997bac76 100644
--- a/pkg/trait/prometheus.go
+++ b/pkg/trait/prometheus.go
@@ -30,30 +30,17 @@ import (
"github.com/apache/camel-k/pkg/util"
)
-// The Prometheus trait configures a Prometheus-compatible endpoint. It also creates a `PodMonitor` resource,
-// so that the endpoint can be scraped automatically, when using the Prometheus operator.
-//
-// The metrics are exposed using MicroProfile Metrics.
-//
-// WARNING: The creation of the `PodMonitor` resource requires the https://github.com/coreos/prometheus-operator[Prometheus Operator]
-// custom resource definition to be installed.
-// You can set `pod-monitor` to `false` for the Prometheus trait to work without the Prometheus Operator.
-//
-// The Prometheus trait is disabled by default.
-//
-// +camel-k:trait=prometheus.
type prometheusTrait struct {
- BaseTrait `property:",squash"`
- // Whether a `PodMonitor` resource is created (default `true`).
- PodMonitor *bool `property:"pod-monitor" json:"podMonitor,omitempty"`
- // The `PodMonitor` resource labels, applicable when `pod-monitor` is `true`.
- PodMonitorLabels []string `property:"pod-monitor-labels" json:"podMonitorLabels,omitempty"`
+ BaseTrait
+ v1.PrometheusTrait `property:",squash"`
}
func newPrometheusTrait() Trait {
return &prometheusTrait{
- BaseTrait: NewBaseTrait("prometheus", 1900),
- PodMonitor: pointer.Bool(true),
+ BaseTrait: NewBaseTrait("prometheus", 1900),
+ PrometheusTrait: v1.PrometheusTrait{
+ PodMonitor: pointer.Bool(true),
+ },
}
}
diff --git a/pkg/trait/pull_secret.go b/pkg/trait/pull_secret.go
index 05469f913..ab758bb4f 100644
--- a/pkg/trait/pull_secret.go
+++ b/pkg/trait/pull_secret.go
@@ -29,31 +29,15 @@ import (
ctrl "sigs.k8s.io/controller-runtime/pkg/client"
+ v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
"github.com/apache/camel-k/pkg/platform"
"github.com/apache/camel-k/pkg/util/kubernetes"
"github.com/apache/camel-k/pkg/util/openshift"
)
-// The Pull Secret trait sets a pull secret on the pod,
-// to allow Kubernetes to retrieve the container image from an external registry.
-//
-// The pull secret can be specified manually or, in case you've configured authentication for an external container registry
-// on the `IntegrationPlatform`, the same secret is used to pull images.
-//
-// It's enabled by default whenever you configure authentication for an external container registry,
-// so it assumes that external registries are private.
-//
-// If your registry does not need authentication for pulling images, you can disable this trait.
-//
-// +camel-k:trait=pull-secret.
type pullSecretTrait struct {
- BaseTrait `property:",squash"`
- // The pull secret name to set on the Pod. If left empty this is automatically taken from the `IntegrationPlatform` registry configuration.
- SecretName string `property:"secret-name" json:"secretName,omitempty"`
- // When using a global operator with a shared platform, this enables delegation of the `system:image-puller` cluster role on the operator namespace to the integration service account.
- ImagePullerDelegation *bool `property:"image-puller-delegation" json:"imagePullerDelegation,omitempty"`
- // Automatically configures the platform registry secret on the pod if it is of type `kubernetes.io/dockerconfigjson`.
- Auto *bool `property:"auto" json:"auto,omitempty"`
+ BaseTrait
+ v1.PullSecretTrait `property:",squash"`
}
func newPullSecretTrait() Trait {
diff --git a/pkg/trait/quarkus.go b/pkg/trait/quarkus.go
index 5abe7f7d5..9890f124c 100644
--- a/pkg/trait/quarkus.go
+++ b/pkg/trait/quarkus.go
@@ -18,7 +18,6 @@ limitations under the License.
package trait
import (
- "encoding/json"
"fmt"
"sort"
@@ -33,40 +32,18 @@ import (
"github.com/apache/camel-k/pkg/util/kubernetes"
)
-type quarkusPackageType string
-
const (
quarkusTraitID = "quarkus"
-
- fastJarPackageType quarkusPackageType = "fast-jar"
- nativePackageType quarkusPackageType = "native"
)
-var kitPriority = map[quarkusPackageType]string{
- fastJarPackageType: "1000",
- nativePackageType: "2000",
+var kitPriority = map[v1.QuarkusPackageType]string{
+ v1.FastJarPackageType: "1000",
+ v1.NativePackageType: "2000",
}
-// The Quarkus trait configures the Quarkus runtime.
-//
-// It's enabled by default.
-//
-// NOTE: Compiling to a native executable, i.e. when using `package-type=native`, is only supported
-// for kamelets, as well as YAML and XML integrations.
-// It also requires at least 4GiB of memory, so the Pod running the native build, that is either
-// the operator Pod, or the build Pod (depending on the build strategy configured for the platform),
-// must have enough memory available.
-//
-// +camel-k:trait=quarkus.
type quarkusTrait struct {
- BaseTrait `property:",squash"`
- // The Quarkus package types, either `fast-jar` or `native` (default `fast-jar`).
- // In case both `fast-jar` and `native` are specified, two `IntegrationKit` resources are created,
- // with the `native` kit having precedence over the `fast-jar` one once ready.
- // The order influences the resolution of the current kit for the integration.
- // The kit corresponding to the first package type will be assigned to the
- // integration in case no existing kit that matches the integration exists.
- PackageTypes []quarkusPackageType `property:"package-type" json:"packageTypes,omitempty"`
+ BaseTrait
+ v1.QuarkusTrait `property:",squash"`
}
func newQuarkusTrait() Trait {
@@ -97,13 +74,13 @@ func (t *quarkusTrait) Matches(trait Trait) bool {
return false
}
- if len(t.PackageTypes) == 0 && len(qt.PackageTypes) != 0 && !containsPackageType(qt.PackageTypes, fastJarPackageType) {
+ if len(t.PackageTypes) == 0 && len(qt.PackageTypes) != 0 && !containsPackageType(qt.PackageTypes, v1.FastJarPackageType) {
return false
}
types:
for _, pt := range t.PackageTypes {
- if pt == fastJarPackageType && len(qt.PackageTypes) == 0 {
+ if pt == v1.FastJarPackageType && len(qt.PackageTypes) == 0 {
continue
}
if containsPackageType(qt.PackageTypes, pt) {
@@ -128,7 +105,7 @@ func (t *quarkusTrait) Configure(e *Environment) (bool, error) {
func (t *quarkusTrait) Apply(e *Environment) error {
if e.IntegrationInPhase(v1.IntegrationPhaseBuildingKit) {
- if containsPackageType(t.PackageTypes, nativePackageType) {
+ if containsPackageType(t.PackageTypes, v1.NativePackageType) {
// Native compilation is only supported for a subset of languages,
// so let's check for compatibility, and fail-fast the Integration,
// to save compute resources and user time.
@@ -151,7 +128,7 @@ func (t *quarkusTrait) Apply(e *Environment) error {
switch len(t.PackageTypes) {
case 0:
- kit := t.newIntegrationKit(e, fastJarPackageType)
+ kit := t.newIntegrationKit(e, v1.FastJarPackageType)
e.IntegrationKits = append(e.IntegrationKits, *kit)
case 1:
@@ -161,25 +138,10 @@ func (t *quarkusTrait) Apply(e *Environment) error {
default:
for _, packageType := range t.PackageTypes {
kit := t.newIntegrationKit(e, packageType)
- data, err := json.Marshal(kit.Spec.Traits[quarkusTraitID].Configuration)
- if err != nil {
- return err
- }
- trait := quarkusTrait{}
- err = json.Unmarshal(data, &trait)
- if err != nil {
- return err
- }
- trait.PackageTypes = []quarkusPackageType{packageType}
- data, err = json.Marshal(trait)
- if err != nil {
- return err
- }
- kit.Spec.Traits[quarkusTraitID] = v1.TraitSpec{
- Configuration: v1.TraitConfiguration{
- RawMessage: data,
- },
+ if kit.Spec.Traits.Quarkus == nil {
+ kit.Spec.Traits.Quarkus = &v1.QuarkusTrait{}
}
+ kit.Spec.Traits.Quarkus.PackageTypes = []v1.QuarkusPackageType{packageType}
e.IntegrationKits = append(e.IntegrationKits, *kit)
}
}
@@ -212,14 +174,14 @@ func (t *quarkusTrait) Apply(e *Environment) error {
}
if native {
- build.Maven.Properties["quarkus.package.type"] = string(nativePackageType)
+ build.Maven.Properties["quarkus.package.type"] = string(v1.NativePackageType)
steps = append(steps, builder.Image.NativeImageContext)
// Spectrum does not rely on Dockerfile to assemble the image
if e.Platform.Status.Build.PublishStrategy != v1.IntegrationPlatformBuildPublishStrategySpectrum {
steps = append(steps, builder.Image.ExecutableDockerfile)
}
} else {
- build.Maven.Properties["quarkus.package.type"] = string(fastJarPackageType)
+ build.Maven.Properties["quarkus.package.type"] = string(v1.FastJarPackageType)
steps = append(steps, builder.Quarkus.ComputeQuarkusDependencies, builder.Image.IncrementalImageContext)
// Spectrum does not rely on Dockerfile to assemble the image
if e.Platform.Status.Build.PublishStrategy != v1.IntegrationPlatformBuildPublishStrategySpectrum {
@@ -249,7 +211,7 @@ func (t *quarkusTrait) Apply(e *Environment) error {
return nil
}
-func (t *quarkusTrait) newIntegrationKit(e *Environment, packageType quarkusPackageType) *v1.IntegrationKit {
+func (t *quarkusTrait) newIntegrationKit(e *Environment, packageType v1.QuarkusPackageType) *v1.IntegrationKit {
integration := e.Integration
kit := v1.NewIntegrationKit(integration.GetIntegrationKitNamespace(e.Platform), fmt.Sprintf("kit-%s", xid.New()))
@@ -276,35 +238,24 @@ func (t *quarkusTrait) newIntegrationKit(e *Environment, packageType quarkusPack
kit.Annotations[v1.OperatorIDAnnotation] = operatorID
}
- traits := t.getKitTraits(e)
-
kit.Spec = v1.IntegrationKitSpec{
Dependencies: e.Integration.Status.Dependencies,
Repositories: e.Integration.Spec.Repositories,
- Traits: traits,
+ Traits: v1.IntegrationKitTraits{
+ Builder: e.Integration.Spec.Traits.Builder,
+ Quarkus: e.Integration.Spec.Traits.Quarkus,
+ },
}
return kit
}
-func (t *quarkusTrait) getKitTraits(e *Environment) map[string]v1.TraitSpec {
- traits := make(map[string]v1.TraitSpec)
- for name, spec := range e.Integration.Spec.Traits {
- t := e.Catalog.GetTrait(name)
- if t != nil && !t.InfluencesKit() {
- continue
- }
- traits[name] = spec
- }
- return traits
-}
-
func (t *quarkusTrait) isNativeKit(e *Environment) (bool, error) {
switch types := t.PackageTypes; len(types) {
case 0:
return false, nil
case 1:
- return types[0] == nativePackageType, nil
+ return types[0] == v1.NativePackageType, nil
default:
return false, fmt.Errorf("kit %q has more than one package type", e.IntegrationKit.Name)
}
@@ -324,7 +275,7 @@ func getBuilderTask(tasks []v1.Task) *v1.BuilderTask {
return nil
}
-func containsPackageType(types []quarkusPackageType, t quarkusPackageType) bool {
+func containsPackageType(types []v1.QuarkusPackageType, t v1.QuarkusPackageType) bool {
for _, ti := range types {
if t == ti {
return true
diff --git a/pkg/trait/registry.go b/pkg/trait/registry.go
index fdc2ac79f..368410675 100644
--- a/pkg/trait/registry.go
+++ b/pkg/trait/registry.go
@@ -36,12 +36,9 @@ import (
ctrl "sigs.k8s.io/controller-runtime/pkg/client"
)
-// The Registry trait sets up Maven to use the Image registry
-// as a Maven repository.
-//
-// +camel-k:trait=registry.
type registryTrait struct {
- BaseTrait `property:",squash"`
+ BaseTrait
+ v1.RegistryTrait
}
func newRegistryTrait() Trait {
diff --git a/pkg/trait/route.go b/pkg/trait/route.go
index 4575cd88b..652f6bee5 100644
--- a/pkg/trait/route.go
+++ b/pkg/trait/route.go
@@ -33,68 +33,10 @@ import (
"github.com/apache/camel-k/pkg/util/kubernetes"
)
-// The Route trait can be used to configure the creation of OpenShift routes for the integration.
-//
-// The certificate and key contents may be sourced either from the local filesystem or in a Openshift `secret` object.
-// The user may use the parameters ending in `-secret` (example: `tls-certificate-secret`) to reference a certificate stored in a `secret`.
-// Parameters ending in `-secret` have higher priorities and in case the same route parameter is set, for example: `tls-key-secret` and `tls-key`,
-// then `tls-key-secret` is used.
-// The recommended approach to set the key and certificates is to use `secrets` to store their contents and use the
-// following parameters to reference them: `tls-certificate-secret`, `tls-key-secret`, `tls-ca-certificate-secret`, `tls-destination-ca-certificate-secret`
-// See the examples section at the end of this page to see the setup options.
-//
-// +camel-k:trait=route
-// nolint: tagliatelle
type routeTrait struct {
- BaseTrait `property:",squash"`
- // To configure the host exposed by the route.
- Host string `property:"host" json:"host,omitempty"`
- // The TLS termination type, like `edge`, `passthrough` or `reencrypt`.
- //
- // Refer to the OpenShift route documentation for additional information.
- TLSTermination string `property:"tls-termination" json:"tlsTermination,omitempty"`
- // The TLS certificate contents.
- //
- // Refer to the OpenShift route documentation for additional information.
- TLSCertificate string `property:"tls-certificate" json:"tlsCertificate,omitempty"`
- // The secret name and key reference to the TLS certificate. The format is "secret-name[/key-name]", the value represents the secret name, if there is only one key in the secret it will be read, otherwise you can set a key name separated with a "/".
- //
- // Refer to the OpenShift route documentation for additional information.
- TLSCertificateSecret string `property:"tls-certificate-secret" json:"tlsCertificateSecret,omitempty"`
- // The TLS certificate key contents.
- //
- // Refer to the OpenShift route documentation for additional information.
- TLSKey string `property:"tls-key" json:"tlsKey,omitempty"`
- // The secret name and key reference to the TLS certificate key. The format is "secret-name[/key-name]", the value represents the secret name, if there is only one key in the secret it will be read, otherwise you can set a key name separated with a "/".
- //
- // Refer to the OpenShift route documentation for additional information.
- TLSKeySecret string `property:"tls-key-secret" json:"tlsKeySecret,omitempty"`
- // The TLS CA certificate contents.
- //
- // Refer to the OpenShift route documentation for additional information.
- TLSCACertificate string `property:"tls-ca-certificate" json:"tlsCACertificate,omitempty"`
- // The secret name and key reference to the TLS CA certificate. The format is "secret-name[/key-name]", the value represents the secret name, if there is only one key in the secret it will be read, otherwise you can set a key name separated with a "/".
- //
- // Refer to the OpenShift route documentation for additional information.
- TLSCACertificateSecret string `property:"tls-ca-certificate-secret" json:"tlsCACertificateSecret,omitempty"`
- // The destination CA certificate provides the contents of the ca certificate of the final destination. When using reencrypt
- // termination this file should be provided in order to have routers use it for health checks on the secure connection.
- // If this field is not specified, the router may provide its own destination CA and perform hostname validation using
- // the short service name (service.namespace.svc), which allows infrastructure generated certificates to automatically
- // verify.
- //
- // Refer to the OpenShift route documentation for additional information.
- TLSDestinationCACertificate string `property:"tls-destination-ca-certificate" json:"tlsDestinationCACertificate,omitempty"`
- // The secret name and key reference to the destination CA certificate. The format is "secret-name[/key-name]", the value represents the secret name, if there is only one key in the secret it will be read, otherwise you can set a key name separated with a "/".
- //
- // Refer to the OpenShift route documentation for additional information.
- TLSDestinationCACertificateSecret string `property:"tls-destination-ca-certificate-secret" json:"tlsDestinationCACertificateSecret,omitempty"`
- // To configure how to deal with insecure traffic, e.g. `Allow`, `Disable` or `Redirect` traffic.
- //
- // Refer to the OpenShift route documentation for additional information.
- TLSInsecureEdgeTerminationPolicy string `property:"tls-insecure-edge-termination-policy" json:"tlsInsecureEdgeTerminationPolicy,omitempty"`
-
- service *corev1.Service
+ BaseTrait
+ v1.RouteTrait `property:",squash"`
+ service *corev1.Service
}
func newRouteTrait() Trait {
diff --git a/pkg/trait/route_test.go b/pkg/trait/route_test.go
index 96c67a4c4..241210177 100644
--- a/pkg/trait/route_test.go
+++ b/pkg/trait/route_test.go
@@ -27,6 +27,7 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+ "k8s.io/utils/pointer"
v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
"github.com/apache/camel-k/pkg/util/camel"
@@ -217,10 +218,12 @@ func TestRoute_Default(t *testing.T) {
func TestRoute_Disabled(t *testing.T) {
name := xid.New().String()
environment := createTestRouteEnvironment(t, name)
- environment.Integration.Spec.Traits = map[string]v1.TraitSpec{
- "route": test.TraitSpecFromMap(t, map[string]interface{}{
- "enabled": false,
- }),
+ environment.Integration.Spec.Traits = v1.Traits{
+ Route: &v1.RouteTrait{
+ Trait: v1.Trait{
+ Enabled: pointer.Bool(false),
+ },
+ },
}
traitsCatalog := environment.Catalog
@@ -256,10 +259,10 @@ func TestRoute_Host(t *testing.T) {
environment := createTestRouteEnvironment(t, name)
traitsCatalog := environment.Catalog
- environment.Integration.Spec.Traits = map[string]v1.TraitSpec{
- "route": test.TraitSpecFromMap(t, map[string]interface{}{
- "host": host,
- }),
+ environment.Integration.Spec.Traits = v1.Traits{
+ Route: &v1.RouteTrait{
+ Host: host,
+ },
}
err := traitsCatalog.apply(environment)
@@ -282,15 +285,15 @@ func TestRoute_TLS_From_Secret_reencrypt(t *testing.T) {
environment := createTestRouteEnvironment(t, name)
traitsCatalog := environment.Catalog
- environment.Integration.Spec.Traits = map[string]v1.TraitSpec{
- "route": test.TraitSpecFromMap(t, map[string]interface{}{
- "tlsTermination": string(routev1.TLSTerminationReencrypt),
- "host": host,
- "tlsKeySecret": tlsKeySecretName,
- "tlsCertificateSecret": tlsMultipleSecretsName + "/" + tlsMultipleSecretsCert1Key,
- "tlsCACertificateSecret": tlsMultipleSecretsName + "/" + tlsMultipleSecretsCert2Key,
- "tlsDestinationCACertificateSecret": tlsMultipleSecretsName + "/" + tlsMultipleSecretsCert3Key,
- }),
+ environment.Integration.Spec.Traits = v1.Traits{
+ Route: &v1.RouteTrait{
+ TLSTermination: string(routev1.TLSTerminationReencrypt),
+ Host: host,
+ TLSKeySecret: tlsKeySecretName,
+ TLSCertificateSecret: tlsMultipleSecretsName + "/" + tlsMultipleSecretsCert1Key,
+ TLSCACertificateSecret: tlsMultipleSecretsName + "/" + tlsMultipleSecretsCert2Key,
+ TLSDestinationCACertificateSecret: tlsMultipleSecretsName + "/" + tlsMultipleSecretsCert3Key,
+ },
}
err := traitsCatalog.apply(environment)
@@ -317,15 +320,15 @@ func TestRoute_TLS_wrong_secret(t *testing.T) {
environment := createTestRouteEnvironment(t, name)
traitsCatalog := environment.Catalog
- environment.Integration.Spec.Traits = map[string]v1.TraitSpec{
- "route": test.TraitSpecFromMap(t, map[string]interface{}{
- "tlsTermination": string(routev1.TLSTerminationReencrypt),
- "host": host,
- "tlsKeySecret": "foo",
- "tlsCertificateSecret": "bar",
- "tlsCACertificateSecret": "test",
- "tlsDestinationCACertificateSecret": "404",
- }),
+ environment.Integration.Spec.Traits = v1.Traits{
+ Route: &v1.RouteTrait{
+ TLSTermination: string(routev1.TLSTerminationReencrypt),
+ Host: host,
+ TLSKeySecret: "foo",
+ TLSCertificateSecret: "bar",
+ TLSCACertificateSecret: "test",
+ TLSDestinationCACertificateSecret: "404",
+ },
}
err := traitsCatalog.apply(environment)
@@ -346,14 +349,14 @@ func TestRoute_TLS_secret_wrong_key(t *testing.T) {
environment := createTestRouteEnvironment(t, name)
traitsCatalog := environment.Catalog
- environment.Integration.Spec.Traits = map[string]v1.TraitSpec{
- "route": test.TraitSpecFromMap(t, map[string]interface{}{
- "tlsTermination": string(routev1.TLSTerminationReencrypt),
- "host": host,
- "tlsKeySecret": tlsKeySecretName,
- "tlsCertificateSecret": tlsMultipleSecretsName + "/" + tlsMultipleSecretsCert1Key,
- "tlsCACertificateSecret": tlsMultipleSecretsName + "/foo",
- }),
+ environment.Integration.Spec.Traits = v1.Traits{
+ Route: &v1.RouteTrait{
+ TLSTermination: string(routev1.TLSTerminationReencrypt),
+ Host: host,
+ TLSKeySecret: tlsKeySecretName,
+ TLSCertificateSecret: tlsMultipleSecretsName + "/" + tlsMultipleSecretsCert1Key,
+ TLSCACertificateSecret: tlsMultipleSecretsName + "/foo",
+ },
}
err := traitsCatalog.apply(environment)
@@ -374,14 +377,14 @@ func TestRoute_TLS_secret_missing_key(t *testing.T) {
environment := createTestRouteEnvironment(t, name)
traitsCatalog := environment.Catalog
- environment.Integration.Spec.Traits = map[string]v1.TraitSpec{
- "route": test.TraitSpecFromMap(t, map[string]interface{}{
- "tlsTermination": string(routev1.TLSTerminationReencrypt),
- "host": host,
- "tlsKeySecret": tlsKeySecretName,
- "tlsCertificateSecret": tlsMultipleSecretsName + "/" + tlsMultipleSecretsCert1Key,
- "tlsCACertificateSecret": tlsMultipleSecretsName,
- }),
+ environment.Integration.Spec.Traits = v1.Traits{
+ Route: &v1.RouteTrait{
+ TLSTermination: string(routev1.TLSTerminationReencrypt),
+ Host: host,
+ TLSKeySecret: tlsKeySecretName,
+ TLSCertificateSecret: tlsMultipleSecretsName + "/" + tlsMultipleSecretsCert1Key,
+ TLSCACertificateSecret: tlsMultipleSecretsName,
+ },
}
err := traitsCatalog.apply(environment)
@@ -402,15 +405,15 @@ func TestRoute_TLS_reencrypt(t *testing.T) {
environment := createTestRouteEnvironment(t, name)
traitsCatalog := environment.Catalog
- environment.Integration.Spec.Traits = map[string]v1.TraitSpec{
- "route": test.TraitSpecFromMap(t, map[string]interface{}{
- "tlsTermination": string(routev1.TLSTerminationReencrypt),
- "host": host,
- "tlsKey": key,
- "tlsCertificate": cert,
- "tlsCACertificate": caCert,
- "tlsDestinationCACertificate": destinationCaCert,
- }),
+ environment.Integration.Spec.Traits = v1.Traits{
+ Route: &v1.RouteTrait{
+ TLSTermination: string(routev1.TLSTerminationReencrypt),
+ Host: host,
+ TLSKey: key,
+ TLSCertificate: cert,
+ TLSCACertificate: caCert,
+ TLSDestinationCACertificate: destinationCaCert,
+ },
}
err := traitsCatalog.apply(environment)
@@ -437,14 +440,14 @@ func TestRoute_TLS_edge(t *testing.T) {
environment := createTestRouteEnvironment(t, name)
traitsCatalog := environment.Catalog
- environment.Integration.Spec.Traits = map[string]v1.TraitSpec{
- "route": test.TraitSpecFromMap(t, map[string]interface{}{
- "tlsTermination": string(routev1.TLSTerminationEdge),
- "host": host,
- "tlsKey": key,
- "tlsCertificate": cert,
- "tlsCACertificate": caCert,
- }),
+ environment.Integration.Spec.Traits = v1.Traits{
+ Route: &v1.RouteTrait{
+ TLSTermination: string(routev1.TLSTerminationEdge),
+ Host: host,
+ TLSKey: key,
+ TLSCertificate: cert,
+ TLSCACertificate: caCert,
+ },
}
err := traitsCatalog.apply(environment)
@@ -471,12 +474,12 @@ func TestRoute_TLS_passthrough(t *testing.T) {
environment := createTestRouteEnvironment(t, name)
traitsCatalog := environment.Catalog
- environment.Integration.Spec.Traits = map[string]v1.TraitSpec{
- "route": test.TraitSpecFromMap(t, map[string]interface{}{
- "tlsTermination": string(routev1.TLSTerminationPassthrough),
- "host": host,
- "tlsInsecureEdgeTerminationPolicy": routev1.InsecureEdgeTerminationPolicyAllow,
- }),
+ environment.Integration.Spec.Traits = v1.Traits{
+ Route: &v1.RouteTrait{
+ TLSTermination: string(routev1.TLSTerminationPassthrough),
+ Host: host,
+ TLSInsecureEdgeTerminationPolicy: string(routev1.InsecureEdgeTerminationPolicyAllow),
+ },
}
err := traitsCatalog.apply(environment)
@@ -501,10 +504,10 @@ func TestRoute_TLS_passthrough(t *testing.T) {
func TestRoute_WithCustomServicePort(t *testing.T) {
name := xid.New().String()
environment := createTestRouteEnvironment(t, name)
- environment.Integration.Spec.Traits = map[string]v1.TraitSpec{
- containerTraitID: test.TraitSpecFromMap(t, map[string]interface{}{
- "servicePortName": "my-port",
- }),
+ environment.Integration.Spec.Traits = v1.Traits{
+ Container: &v1.ContainerTrait{
+ ServicePortName: "my-port",
+ },
}
traitsCatalog := environment.Catalog
@@ -522,10 +525,10 @@ func TestRoute_WithCustomServicePort(t *testing.T) {
assert.NotNil(t, route)
assert.NotNil(t, route.Spec.Port)
- trait := test.TraitSpecToMap(t, environment.Integration.Spec.Traits[containerTraitID])
+ trait := environment.Integration.Spec.Traits.Container
assert.Equal(
t,
- trait["servicePortName"],
+ trait.ServicePortName,
route.Spec.Port.TargetPort.StrVal,
)
}
diff --git a/pkg/trait/service.go b/pkg/trait/service.go
index 5c47a5fe0..5a2e3de47 100644
--- a/pkg/trait/service.go
+++ b/pkg/trait/service.go
@@ -27,18 +27,9 @@ import (
"github.com/apache/camel-k/pkg/util/kubernetes"
)
-// The Service trait exposes the integration with a Service resource so that it can be accessed by other applications
-// (or integrations) in the same namespace.
-//
-// It's enabled by default if the integration depends on a Camel component that can expose a HTTP endpoint.
-//
-// +camel-k:trait=service.
type serviceTrait struct {
- BaseTrait `property:",squash"`
- // To automatically detect from the code if a Service needs to be created.
- Auto *bool `property:"auto" json:"auto,omitempty"`
- // Enable Service to be exposed as NodePort (default `false`).
- NodePort *bool `property:"node-port" json:"nodePort,omitempty"`
+ BaseTrait
+ v1.ServiceTrait `property:",squash"`
}
const serviceTraitID = "service"
diff --git a/pkg/trait/service_binding.go b/pkg/trait/service_binding.go
index de6f607fa..f57ab57a4 100644
--- a/pkg/trait/service_binding.go
+++ b/pkg/trait/service_binding.go
@@ -36,14 +36,9 @@ import (
"github.com/apache/camel-k/pkg/util/reference"
)
-// The Service Binding trait allows users to connect to Services in Kubernetes:
-// https://github.com/k8s-service-bindings/spec#service-binding
-// As the specification is still evolving this is subject to change
-// +camel-k:trait=service-binding.
type serviceBindingTrait struct {
- BaseTrait `property:",squash"`
- // List of Services in the form [[apigroup/]version:]kind:[namespace/]name
- Services []string `property:"services" json:"services,omitempty"`
+ BaseTrait
+ v1.ServiceBindingTrait `property:",squash"`
}
func newServiceBindingTrait() Trait {
diff --git a/pkg/trait/service_test.go b/pkg/trait/service_test.go
index f97d6bc2c..7e9d59283 100644
--- a/pkg/trait/service_test.go
+++ b/pkg/trait/service_test.go
@@ -25,12 +25,12 @@ import (
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+ "k8s.io/utils/pointer"
v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
"github.com/apache/camel-k/pkg/util/camel"
"github.com/apache/camel-k/pkg/util/gzip"
"github.com/apache/camel-k/pkg/util/kubernetes"
- "github.com/apache/camel-k/pkg/util/test"
)
const (
@@ -70,11 +70,13 @@ func TestServiceWithDefaults(t *testing.T) {
Language: v1.LanguageJavaScript,
},
},
- Traits: map[string]v1.TraitSpec{
- "service": test.TraitSpecFromMap(t, map[string]interface{}{
- "enabled": true,
- "auto": false,
- }),
+ Traits: v1.Traits{
+ Service: &v1.ServiceTrait{
+ Trait: v1.Trait{
+ Enabled: pointer.Bool(true),
+ },
+ Auto: pointer.Bool(false),
+ },
},
},
},
@@ -161,19 +163,23 @@ func TestService(t *testing.T) {
Language: v1.LanguageJavaScript,
},
},
- Traits: map[string]v1.TraitSpec{
- "service": test.TraitSpecFromMap(t, map[string]interface{}{
- "enabled": true,
- }),
- "container": test.TraitSpecFromMap(t, map[string]interface{}{
- "enabled": true,
- "auto": false,
- "expose": true,
- "port": 8081,
- "portName": "http-8081",
- "servicePort": 81,
- "servicePortName": "http-81",
- }),
+ Traits: v1.Traits{
+ Service: &v1.ServiceTrait{
+ Trait: v1.Trait{
+ Enabled: pointer.Bool(true),
+ },
+ },
+ Container: &v1.ContainerTrait{
+ Trait: v1.Trait{
+ Enabled: pointer.Bool(true),
+ },
+ Auto: pointer.Bool(false),
+ Expose: pointer.Bool(true),
+ Port: 8081,
+ PortName: "http-8081",
+ ServicePort: 81,
+ ServicePortName: "http-81",
+ },
},
},
},
@@ -245,14 +251,16 @@ func TestServiceWithCustomContainerName(t *testing.T) {
},
Spec: v1.IntegrationSpec{
Profile: v1.TraitProfileKubernetes,
- Traits: map[string]v1.TraitSpec{
- "service": test.TraitSpecFromMap(t, map[string]interface{}{
- "enabled": true,
- "auto": false,
- }),
- "container": test.TraitSpecFromMap(t, map[string]interface{}{
- "name": "my-container-name",
- }),
+ Traits: v1.Traits{
+ Service: &v1.ServiceTrait{
+ Trait: v1.Trait{
+ Enabled: pointer.Bool(true),
+ },
+ Auto: pointer.Bool(false),
+ },
+ Container: &v1.ContainerTrait{
+ Name: "my-container-name",
+ },
},
},
},
@@ -289,10 +297,10 @@ func TestServiceWithCustomContainerName(t *testing.T) {
assert.Len(t, d.Spec.Template.Spec.Containers, 1)
- trait := test.TraitSpecToMap(t, environment.Integration.Spec.Traits["container"])
+ trait := environment.Integration.Spec.Traits.Container
assert.Equal(
t,
- trait["name"],
+ trait.Name,
d.Spec.Template.Spec.Containers[0].Name,
)
}
@@ -329,12 +337,14 @@ func TestServiceWithNodePort(t *testing.T) {
Language: v1.LanguageJavaScript,
},
},
- Traits: map[string]v1.TraitSpec{
- "service": test.TraitSpecFromMap(t, map[string]interface{}{
- "enabled": true,
- "auto": false,
- "nodePort": true,
- }),
+ Traits: v1.Traits{
+ Service: &v1.ServiceTrait{
+ Trait: v1.Trait{
+ Enabled: pointer.Bool(true),
+ },
+ Auto: pointer.Bool(false),
+ NodePort: pointer.Bool(true),
+ },
},
},
},
diff --git a/pkg/trait/toleration.go b/pkg/trait/toleration.go
index 925d53d78..83483830c 100644
--- a/pkg/trait/toleration.go
+++ b/pkg/trait/toleration.go
@@ -23,27 +23,13 @@ import (
corev1 "k8s.io/api/core/v1"
"k8s.io/utils/pointer"
+ v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
"github.com/apache/camel-k/pkg/util/kubernetes"
)
-// This trait sets Tolerations over Integration pods. Tolerations allow (but do not require) the pods to schedule onto nodes with matching taints.
-// See https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/ for more details.
-//
-// The toleration should be expressed in a similar manner that of taints, i.e., `Key[=Value]:Effect[:Seconds]`, where values in square brackets are optional.
-//
-// For examples:
-//
-// - `node-role.kubernetes.io/master:NoSchedule`
-// - `node.kubernetes.io/network-unavailable:NoExecute:3000`
-// - `disktype=ssd:PreferNoSchedule`
-//
-// It's disabled by default.
-//
-// +camel-k:trait=toleration.
type tolerationTrait struct {
- BaseTrait `property:",squash"`
- // The list of taints to tolerate, in the form `Key[=Value]:Effect[:Seconds]`
- Taints []string `property:"taints" json:"taints,omitempty"`
+ BaseTrait
+ v1.TolerationTrait `property:",squash"`
}
func newTolerationTrait() Trait {
diff --git a/pkg/trait/trait_configure.go b/pkg/trait/trait_configure.go
index 1bba95bd0..223d6926f 100644
--- a/pkg/trait/trait_configure.go
+++ b/pkg/trait/trait_configure.go
@@ -32,30 +32,24 @@ import (
func (c *Catalog) configure(env *Environment) error {
if env.Platform != nil {
- if env.Platform.Status.Traits != nil {
- if err := c.configureTraits(env.Platform.Status.Traits); err != nil {
- return err
- }
+ if err := c.configureTraits(env.Platform.Status.Traits); err != nil {
+ return err
}
if err := c.configureTraitsFromAnnotations(env.Platform.Annotations); err != nil {
return err
}
}
if env.IntegrationKit != nil {
- if env.IntegrationKit.Spec.Traits != nil {
- if err := c.configureTraits(env.IntegrationKit.Spec.Traits); err != nil {
- return err
- }
+ if err := c.configureTraits(env.IntegrationKit.Spec.Traits); err != nil {
+ return err
}
if err := c.configureTraitsFromAnnotations(env.IntegrationKit.Annotations); err != nil {
return err
}
}
if env.Integration != nil {
- if env.Integration.Spec.Traits != nil {
- if err := c.configureTraits(env.Integration.Spec.Traits); err != nil {
- return err
- }
+ if err := c.configureTraits(env.Integration.Spec.Traits); err != nil {
+ return err
}
if err := c.configureTraitsFromAnnotations(env.Integration.Annotations); err != nil {
return err
@@ -65,11 +59,14 @@ func (c *Catalog) configure(env *Environment) error {
return nil
}
-func (c *Catalog) configureTraits(traits map[string]v1.TraitSpec) error {
- for id, traitSpec := range traits {
- catTrait := c.GetTrait(id)
- if catTrait != nil {
- trait := traitSpec
+func (c *Catalog) configureTraits(traits interface{}) error {
+ traitsMap, err := ToMap(traits)
+ if err != nil {
+ return err
+ }
+
+ for id, trait := range traitsMap {
+ if catTrait := c.GetTrait(id); catTrait != nil {
if err := decodeTraitSpec(&trait, catTrait); err != nil {
return err
}
@@ -79,8 +76,8 @@ func (c *Catalog) configureTraits(traits map[string]v1.TraitSpec) error {
return nil
}
-func decodeTraitSpec(in *v1.TraitSpec, target interface{}) error {
- data, err := json.Marshal(&in.Configuration)
+func decodeTraitSpec(in interface{}, target interface{}) error {
+ data, err := json.Marshal(&in)
if err != nil {
return err
}
diff --git a/pkg/trait/trait_configure_test.go b/pkg/trait/trait_configure_test.go
index e92c4985f..0cfe1b853 100644
--- a/pkg/trait/trait_configure_test.go
+++ b/pkg/trait/trait_configure_test.go
@@ -23,9 +23,9 @@ import (
"github.com/stretchr/testify/assert"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+ "k8s.io/utils/pointer"
v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
- "github.com/apache/camel-k/pkg/util/test"
)
func TestTraitConfigurationFromAnnotations(t *testing.T) {
@@ -39,11 +39,11 @@ func TestTraitConfigurationFromAnnotations(t *testing.T) {
},
Spec: v1.IntegrationSpec{
Profile: v1.TraitProfileKubernetes,
- Traits: map[string]v1.TraitSpec{
- "cron": test.TraitSpecFromMap(t, map[string]interface{}{
- "fallback": true,
- "concurrencyPolicy": "mypolicy",
- }),
+ Traits: v1.Traits{
+ Cron: &v1.CronTrait{
+ Fallback: pointer.Bool(true),
+ ConcurrencyPolicy: "mypolicy",
+ },
},
},
},
@@ -82,42 +82,44 @@ func TestTraitConfigurationOverrideRulesFromAnnotations(t *testing.T) {
},
},
Spec: v1.IntegrationPlatformSpec{
- Traits: map[string]v1.TraitSpec{
- "cron": test.TraitSpecFromMap(t, map[string]interface{}{
- "components": "cmp1",
- "schedule": "schedule1",
- }),
+ Traits: v1.Traits{
+ Cron: &v1.CronTrait{
+ Components: "cmp1",
+ Schedule: "schedule1",
+ ConcurrencyPolicy: "policy1",
+ },
},
},
},
IntegrationKit: &v1.IntegrationKit{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
- "trait.camel.apache.org/cron.components": "cmp4",
+ "trait.camel.apache.org/cron.components": "cmp3",
"trait.camel.apache.org/cron.concurrency-policy": "policy2",
+ "trait.camel.apache.org/builder.verbose": "true",
},
},
Spec: v1.IntegrationKitSpec{
- Traits: map[string]v1.TraitSpec{
- "cron": test.TraitSpecFromMap(t, map[string]interface{}{
- "components": "cmp3",
- "concurrencyPolicy": "policy1",
- }),
+ Traits: v1.IntegrationKitTraits{
+ Builder: &v1.BuilderTrait{
+ Verbose: pointer.Bool(false),
+ },
},
},
},
Integration: &v1.Integration{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
+ "trait.camel.apache.org/cron.components": "cmp4",
"trait.camel.apache.org/cron.concurrency-policy": "policy4",
},
},
Spec: v1.IntegrationSpec{
Profile: v1.TraitProfileKubernetes,
- Traits: map[string]v1.TraitSpec{
- "cron": test.TraitSpecFromMap(t, map[string]interface{}{
- "concurrencyPolicy": "policy3",
- }),
+ Traits: v1.Traits{
+ Cron: &v1.CronTrait{
+ ConcurrencyPolicy: "policy3",
+ },
},
},
},
@@ -127,6 +129,7 @@ func TestTraitConfigurationOverrideRulesFromAnnotations(t *testing.T) {
assert.Equal(t, "schedule2", c.GetTrait("cron").(*cronTrait).Schedule)
assert.Equal(t, "cmp4", c.GetTrait("cron").(*cronTrait).Components)
assert.Equal(t, "policy4", c.GetTrait("cron").(*cronTrait).ConcurrencyPolicy)
+ assert.Equal(t, pointer.Bool(true), c.GetTrait("builder").(*builderTrait).Verbose)
}
func TestTraitListConfigurationFromAnnotations(t *testing.T) {
diff --git a/pkg/trait/trait_register.go b/pkg/trait/trait_register.go
index ff48f934f..ff4c0da15 100644
--- a/pkg/trait/trait_register.go
+++ b/pkg/trait/trait_register.go
@@ -30,7 +30,7 @@ func init() {
AddToTraits(newDeploymentTrait)
AddToTraits(newEnvironmentTrait)
AddToTraits(newErrorHandlerTrait)
- AddToTraits(newGarbageCollectorTrait)
+ AddToTraits(newGCTrait)
AddToTraits(newHealthTrait)
AddToTraits(NewInitTrait)
AddToTraits(newIngressTrait)
diff --git a/pkg/trait/trait_test.go b/pkg/trait/trait_test.go
index c88ee94c5..c2aeb40fc 100644
--- a/pkg/trait/trait_test.go
+++ b/pkg/trait/trait_test.go
@@ -28,11 +28,11 @@ import (
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+ "k8s.io/utils/pointer"
v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
"github.com/apache/camel-k/pkg/util/camel"
"github.com/apache/camel-k/pkg/util/kubernetes"
- "github.com/apache/camel-k/pkg/util/test"
)
const (
@@ -79,10 +79,6 @@ func TestOpenShiftTraitsWithWeb(t *testing.T) {
func TestOpenShiftTraitsWithWebAndConfig(t *testing.T) {
env := createTestEnv(t, v1.IntegrationPlatformClusterOpenShift, "from('netty-http:http').to('log:info')")
- env.Integration.Spec.Traits = make(map[string]v1.TraitSpec)
- env.Integration.Spec.Traits["service"] = test.TraitSpecFromMap(t, map[string]interface{}{
- "port": 7071,
- })
res := processTestEnv(t, env)
assert.NotNil(t, env.GetTrait("service"))
assert.NotNil(t, env.GetTrait("route"))
@@ -93,11 +89,11 @@ func TestOpenShiftTraitsWithWebAndConfig(t *testing.T) {
func TestOpenShiftTraitsWithWebAndDisabledTrait(t *testing.T) {
env := createTestEnv(t, v1.IntegrationPlatformClusterOpenShift, "from('netty-http:http').to('log:info')")
- env.Integration.Spec.Traits = make(map[string]v1.TraitSpec)
- env.Integration.Spec.Traits["service"] = test.TraitSpecFromMap(t, map[string]interface{}{
- "enabled": false,
- "port": 7071,
- })
+ env.Integration.Spec.Traits.Service = &v1.ServiceTrait{
+ Trait: v1.Trait{
+ Enabled: pointer.Bool(false),
+ },
+ }
res := processTestEnv(t, env)
assert.Nil(t, env.GetTrait("service"))
assert.Nil(t, env.GetTrait("route")) // No route without service
@@ -140,17 +136,16 @@ func TestKubernetesTraitsWithWeb(t *testing.T) {
}
func TestTraitDecode(t *testing.T) {
- env := createTestEnv(t, v1.IntegrationPlatformClusterOpenShift, "")
- env.Integration.Spec.Traits = make(map[string]v1.TraitSpec)
- svcTrait := test.TraitSpecFromMap(t, map[string]interface{}{
- "enabled": false,
- "port": 7071,
- "cippa": "lippa",
- })
- env.Integration.Spec.Traits["service"] = svcTrait
+ trait := v1.ContainerTrait{
+ Trait: v1.Trait{
+ Enabled: pointer.Bool(false),
+ },
+ Port: 7071,
+ Auto: pointer.Bool(true),
+ }
ctr, _ := newContainerTrait().(*containerTrait)
- err := decodeTraitSpec(&svcTrait, ctr)
+ err := decodeTraitSpec(&trait, ctr)
assert.Nil(t, err)
assert.Equal(t, 7071, ctr.Port)
@@ -161,25 +156,23 @@ func TestTraitDecode(t *testing.T) {
func TestTraitHierarchyDecode(t *testing.T) {
env := createTestEnv(t, v1.IntegrationPlatformClusterOpenShift, "")
- env.Platform.Spec.Traits = make(map[string]v1.TraitSpec)
- env.Platform.Spec.Traits["knative-service"] = test.TraitSpecFromMap(t, map[string]interface{}{
- "enabled": false,
- "minScale": 1,
- "maxScale": 10,
- "autoscalingTarget": 15,
- })
+ env.Platform.Spec.Traits.KnativeService = &v1.KnativeServiceTrait{
+ Trait: v1.Trait{
+ Enabled: pointer.Bool(false),
+ },
+ MinScale: pointer.Int(1),
+ MaxScale: pointer.Int(10),
+ Target: pointer.Int(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,
- "minScale": 5,
- })
-
- env.Integration.Spec.Traits = make(map[string]v1.TraitSpec)
- env.Integration.Spec.Traits["knative-service"] = test.TraitSpecFromMap(t, map[string]interface{}{
- "maxScale": 20,
- })
+ env.Integration.Spec.Traits.KnativeService = &v1.KnativeServiceTrait{
+ Trait: v1.Trait{
+ Enabled: pointer.Bool(true),
+ },
+ MinScale: pointer.Int(5),
+ MaxScale: pointer.Int(20),
+ }
c := NewTraitTestCatalog()
err := c.configure(env)
diff --git a/pkg/trait/trait_types.go b/pkg/trait/trait_types.go
index a53ec9841..c38780cb5 100644
--- a/pkg/trait/trait_types.go
+++ b/pkg/trait/trait_types.go
@@ -115,9 +115,7 @@ func NewBaseTrait(id string, order int) BaseTrait {
// BaseTrait is the root trait with noop implementations for hooks.
type BaseTrait struct {
- TraitID ID `json:"-"`
- // Can be used to enable or disable a trait. All traits share this common property.
- Enabled *bool `property:"enabled" json:"enabled,omitempty"`
+ TraitID ID `json:"-"`
Client client.Client `json:"-"`
ExecutionOrder int `json:"-"`
L log.Logger `json:"-"`
diff --git a/pkg/trait/util.go b/pkg/trait/util.go
index 3d52ca136..97ae4748d 100644
--- a/pkg/trait/util.go
+++ b/pkg/trait/util.go
@@ -19,6 +19,7 @@ package trait
import (
"context"
+ "encoding/json"
"fmt"
"reflect"
"regexp"
@@ -26,6 +27,7 @@ import (
"strings"
user "github.com/mitchellh/go-homedir"
+ "github.com/pkg/errors"
"github.com/scylladb/go-set/strset"
ctrl "sigs.k8s.io/controller-runtime/pkg/client"
@@ -221,3 +223,37 @@ func AddSourceDependencies(source v1.SourceSpec, catalog *camel.RuntimeCatalog)
return dependencies
}
+
+// ToMap accepts either v1.Traits or v1.IntegrationKitTraits and converts it to a map.
+func ToMap(traits interface{}) (map[string]map[string]interface{}, error) {
+ _, ok1 := traits.(v1.Traits)
+ _, ok2 := traits.(v1.IntegrationKitTraits)
+ if !ok1 && !ok2 {
+ return nil, errors.New("traits must be either v1.Traits or v1.IntegrationKitTraits")
+ }
+
+ data, err := json.Marshal(traits)
+ if err != nil {
+ return nil, err
+ }
+ traitsMap := make(map[string]map[string]interface{})
+ if err = json.Unmarshal(data, &traitsMap); err != nil {
+ return nil, err
+ }
+
+ return traitsMap, nil
+}
+
+// ToTrait unmarshals a map configuration to a target trait
+func ToTrait(trait map[string]interface{}, target interface{}) error {
+ data, err := json.Marshal(trait)
+ if err != nil {
+ return err
+ }
+ err = json.Unmarshal(data, &target)
+ if err != nil {
+ return err
+ }
+
+ return nil
+}
diff --git a/pkg/util/bindings/api.go b/pkg/util/bindings/api.go
index ea98f8822..151125e94 100644
--- a/pkg/util/bindings/api.go
+++ b/pkg/util/bindings/api.go
@@ -40,7 +40,7 @@ type Binding struct {
// Step is to support complex mapping such as Camel's EIPs
Step map[string]interface{}
// Traits is a partial trait specification that should be merged into the integration
- Traits map[string]v1.TraitSpec
+ Traits v1.Traits
// ApplicationProperties contain properties that should be set on the integration for the binding to work
ApplicationProperties map[string]string
}
diff --git a/pkg/util/bindings/bindings_test.go b/pkg/util/bindings/bindings_test.go
index f9c101746..da1c6dd10 100644
--- a/pkg/util/bindings/bindings_test.go
+++ b/pkg/util/bindings/bindings_test.go
@@ -24,12 +24,15 @@ import (
"net/url"
"testing"
+ corev1 "k8s.io/api/core/v1"
+ "k8s.io/utils/pointer"
+
camelv1 "github.com/apache/camel-k/pkg/apis/camel/v1"
knativeapis "github.com/apache/camel-k/pkg/apis/camel/v1/knative"
"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
"github.com/apache/camel-k/pkg/util/test"
+
"github.com/stretchr/testify/assert"
- corev1 "k8s.io/api/core/v1"
)
func TestBindings(t *testing.T) {
@@ -38,7 +41,7 @@ func TestBindings(t *testing.T) {
endpoint v1alpha1.Endpoint
profile camelv1.TraitProfile
uri string
- traits map[string]camelv1.TraitSpec
+ traits camelv1.Traits
props map[string]string
}{
{
@@ -174,21 +177,23 @@ func TestBindings(t *testing.T) {
{
endpointType: v1alpha1.EndpointTypeSink,
endpoint: v1alpha1.Endpoint{
- URI: asStringPointer("https://myurl/hey"),
+ URI: pointer.String("https://myurl/hey"),
Properties: asEndpointProperties(map[string]string{
"ce.override.ce-type": "mytype",
}),
},
uri: "knative:endpoint/sink?ce.override.ce-type=mytype",
- traits: asTraitSpec("knative", map[string]interface{}{
- "sinkBinding": false,
- "configuration": asKnativeConfig("https://myurl/hey"),
- }),
+ traits: camelv1.Traits{
+ Knative: &camelv1.KnativeTrait{
+ SinkBinding: pointer.Bool(false),
+ Configuration: asKnativeConfig("https://myurl/hey"),
+ },
+ },
},
{
endpointType: v1alpha1.EndpointTypeSink,
endpoint: v1alpha1.Endpoint{
- URI: asStringPointer("https://myurl/hey"),
+ URI: pointer.String("https://myurl/hey"),
},
profile: camelv1.TraitProfileKubernetes,
uri: "https://myurl/hey",
@@ -196,14 +201,13 @@ func TestBindings(t *testing.T) {
{
endpointType: v1alpha1.EndpointTypeSink,
endpoint: v1alpha1.Endpoint{
- URI: asStringPointer("docker://xxx"),
+ URI: pointer.String("docker://xxx"),
},
uri: "docker://xxx",
},
}
- for i := range testcases {
- tc := testcases[i]
+ for i, tc := range testcases {
t.Run(fmt.Sprintf("test-%d-%s", i, tc.uri), func(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
@@ -245,24 +249,6 @@ func asEndpointProperties(props map[string]string) *v1alpha1.EndpointProperties
}
}
-func asTraitSpec(key string, data map[string]interface{}) map[string]camelv1.TraitSpec {
- res := make(map[string]camelv1.TraitSpec)
- serialized, err := json.Marshal(data)
- if err != nil {
- panic(err)
- }
- res[key] = camelv1.TraitSpec{
- Configuration: camelv1.TraitConfiguration{
- RawMessage: serialized,
- },
- }
- return res
-}
-
-func asStringPointer(str string) *string {
- return &str
-}
-
func asKnativeConfig(endpointURL string) string {
serviceURL, err := url.Parse(endpointURL)
if err != nil {
diff --git a/pkg/util/bindings/knative_uri.go b/pkg/util/bindings/knative_uri.go
index f1a12004d..5bf7ce935 100644
--- a/pkg/util/bindings/knative_uri.go
+++ b/pkg/util/bindings/knative_uri.go
@@ -18,10 +18,11 @@ limitations under the License.
package bindings
import (
- "encoding/json"
"net/url"
"strings"
+ "k8s.io/utils/pointer"
+
v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
knativeapis "github.com/apache/camel-k/pkg/apis/camel/v1/knative"
"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
@@ -53,7 +54,6 @@ func (k KnativeURIBindingProvider) Translate(ctx BindingContext, endpointCtx End
return nil, nil
}
- knativeConfig := make(map[string]interface{})
originalURI, err := url.Parse(*e.URI)
if err != nil {
return nil, err
@@ -71,12 +71,6 @@ func (k KnativeURIBindingProvider) Translate(ctx BindingContext, endpointCtx End
if err != nil {
return nil, err
}
- knativeConfig["configuration"] = config
- knativeConfig["sinkBinding"] = false
- knativeConfigJSON, err := json.Marshal(knativeConfig)
- if err != nil {
- return nil, err
- }
// Rewrite URI to match the service definition
serviceURI := "knative:endpoint/sink"
@@ -88,11 +82,10 @@ func (k KnativeURIBindingProvider) Translate(ctx BindingContext, endpointCtx End
return &Binding{
URI: serviceURI,
- Traits: map[string]v1.TraitSpec{
- "knative": {
- Configuration: v1.TraitConfiguration{
- RawMessage: knativeConfigJSON,
- },
+ Traits: v1.Traits{
+ Knative: &v1.KnativeTrait{
+ Configuration: config,
+ SinkBinding: pointer.Bool(false),
},
},
}, nil
diff --git a/pkg/util/digest/digest.go b/pkg/util/digest/digest.go
index 0ab8c9e8d..cdeee2834 100644
--- a/pkg/util/digest/digest.go
+++ b/pkg/util/digest/digest.go
@@ -98,28 +98,12 @@ func ComputeForIntegration(integration *v1.Integration) (string, error) {
}
// Integration traits
- for _, name := range sortedTraitSpecMapKeys(integration.Spec.Traits) {
- if _, err := hash.Write([]byte(name + "[")); err != nil {
- return "", err
- }
- spec, err := json.Marshal(integration.Spec.Traits[name].Configuration)
- if err != nil {
- return "", err
- }
- trait := make(map[string]interface{})
- err = json.Unmarshal(spec, &trait)
- if err != nil {
- return "", err
- }
- for _, prop := range util.SortedMapKeys(trait) {
- val := trait[prop]
- if _, err := hash.Write([]byte(fmt.Sprintf("%s=%v,", prop, val))); err != nil {
- return "", err
- }
- }
- if _, err := hash.Write([]byte("]")); err != nil {
- return "", err
- }
+ traits, err := json.Marshal(integration.Spec.Traits)
+ if err != nil {
+ return "", err
+ }
+ if _, err := hash.Write(traits); err != nil {
+ return "", err
}
// Integration traits as annotations
for _, k := range sortedTraitAnnotationsKeys(integration) {
@@ -232,17 +216,6 @@ func ComputeForSource(s v1.SourceSpec) (string, error) {
return digest, nil
}
-func sortedTraitSpecMapKeys(m map[string]v1.TraitSpec) []string {
- res := make([]string, len(m))
- i := 0
- for k := range m {
- res[i] = k
- i++
- }
- sort.Strings(res)
- return res
-}
-
func sortedTraitAnnotationsKeys(it *v1.Integration) []string {
res := make([]string, 0, len(it.Annotations))
for k := range it.Annotations {