You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pc...@apache.org on 2023/10/16 07:41:22 UTC

[camel-k] 02/02: fix(traits): kamelets and jvm not platform traits

This is an automated email from the ASF dual-hosted git repository.

pcongiusti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit eb02913a8a0aef329dadef23120f288cdf4de6da
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Fri Oct 13 15:58:39 2023 +0200

    fix(traits): kamelets and jvm not platform traits
    
    At least, according our E2E tests.
---
 .../bases/camel.apache.org_integrationplatforms.yaml   | 12 ++++++++----
 config/crd/bases/camel.apache.org_integrations.yaml    |  6 ++++--
 config/crd/bases/camel.apache.org_kameletbindings.yaml |  6 ++++--
 config/crd/bases/camel.apache.org_pipes.yaml           |  6 ++++--
 docs/modules/ROOT/partials/apis/camel-k-crds.adoc      | 18 +++++++++---------
 docs/modules/traits/pages/jvm.adoc                     |  4 +---
 docs/modules/traits/pages/kamelets.adoc                |  4 +---
 helm/camel-k/crds/crd-integration-platform.yaml        | 12 ++++++++----
 helm/camel-k/crds/crd-integration.yaml                 |  6 ++++--
 helm/camel-k/crds/crd-kamelet-binding.yaml             |  6 ++++--
 helm/camel-k/crds/crd-pipe.yaml                        |  6 ++++--
 pkg/apis/camel/v1/trait/jvm.go                         |  2 +-
 pkg/apis/camel/v1/trait/kamelets.go                    |  2 +-
 pkg/apis/camel/v1/trait/zz_generated.deepcopy.go       |  4 ++--
 pkg/trait/jvm.go                                       |  8 ++++++--
 pkg/trait/kamelets.go                                  |  6 +++---
 resources/traits.yaml                                  | 10 ++++++----
 17 files changed, 70 insertions(+), 48 deletions(-)

diff --git a/config/crd/bases/camel.apache.org_integrationplatforms.yaml b/config/crd/bases/camel.apache.org_integrationplatforms.yaml
index 9ce27b07b..d34c2f432 100644
--- a/config/crd/bases/camel.apache.org_integrationplatforms.yaml
+++ b/config/crd/bases/camel.apache.org_integrationplatforms.yaml
@@ -1157,7 +1157,8 @@ spec:
                           main class is loaded
                         type: boolean
                       enabled:
-                        description: 'Deprecated: no longer in use.'
+                        description: Can be used to enable or disable a trait. All
+                          traits share this common property.
                         type: boolean
                       options:
                         description: A list of JVM options
@@ -1182,7 +1183,8 @@ spec:
                         type: object
                         x-kubernetes-preserve-unknown-fields: true
                       enabled:
-                        description: 'Deprecated: no longer in use.'
+                        description: Can be used to enable or disable a trait. All
+                          traits share this common property.
                         type: boolean
                       list:
                         description: Comma separated list of Kamelet names to load
@@ -2969,7 +2971,8 @@ spec:
                           main class is loaded
                         type: boolean
                       enabled:
-                        description: 'Deprecated: no longer in use.'
+                        description: Can be used to enable or disable a trait. All
+                          traits share this common property.
                         type: boolean
                       options:
                         description: A list of JVM options
@@ -2994,7 +2997,8 @@ spec:
                         type: object
                         x-kubernetes-preserve-unknown-fields: true
                       enabled:
-                        description: 'Deprecated: no longer in use.'
+                        description: Can be used to enable or disable a trait. All
+                          traits share this common property.
                         type: boolean
                       list:
                         description: Comma separated list of Kamelet names to load
diff --git a/config/crd/bases/camel.apache.org_integrations.yaml b/config/crd/bases/camel.apache.org_integrations.yaml
index 4fa5b64be..608118fef 100644
--- a/config/crd/bases/camel.apache.org_integrations.yaml
+++ b/config/crd/bases/camel.apache.org_integrations.yaml
@@ -7074,7 +7074,8 @@ spec:
                           main class is loaded
                         type: boolean
                       enabled:
-                        description: 'Deprecated: no longer in use.'
+                        description: Can be used to enable or disable a trait. All
+                          traits share this common property.
                         type: boolean
                       options:
                         description: A list of JVM options
@@ -7099,7 +7100,8 @@ spec:
                         type: object
                         x-kubernetes-preserve-unknown-fields: true
                       enabled:
-                        description: 'Deprecated: no longer in use.'
+                        description: Can be used to enable or disable a trait. All
+                          traits share this common property.
                         type: boolean
                       list:
                         description: Comma separated list of Kamelet names to load
diff --git a/config/crd/bases/camel.apache.org_kameletbindings.yaml b/config/crd/bases/camel.apache.org_kameletbindings.yaml
index d0356a2a4..b40d8c9a8 100644
--- a/config/crd/bases/camel.apache.org_kameletbindings.yaml
+++ b/config/crd/bases/camel.apache.org_kameletbindings.yaml
@@ -7360,7 +7360,8 @@ spec:
                               the main class is loaded
                             type: boolean
                           enabled:
-                            description: 'Deprecated: no longer in use.'
+                            description: Can be used to enable or disable a trait.
+                              All traits share this common property.
                             type: boolean
                           options:
                             description: A list of JVM options
@@ -7385,7 +7386,8 @@ spec:
                             type: object
                             x-kubernetes-preserve-unknown-fields: true
                           enabled:
-                            description: 'Deprecated: no longer in use.'
+                            description: Can be used to enable or disable a trait.
+                              All traits share this common property.
                             type: boolean
                           list:
                             description: Comma separated list of Kamelet names to
diff --git a/config/crd/bases/camel.apache.org_pipes.yaml b/config/crd/bases/camel.apache.org_pipes.yaml
index 804c1667d..ca6c71c0e 100644
--- a/config/crd/bases/camel.apache.org_pipes.yaml
+++ b/config/crd/bases/camel.apache.org_pipes.yaml
@@ -7358,7 +7358,8 @@ spec:
                               the main class is loaded
                             type: boolean
                           enabled:
-                            description: 'Deprecated: no longer in use.'
+                            description: Can be used to enable or disable a trait.
+                              All traits share this common property.
                             type: boolean
                           options:
                             description: A list of JVM options
@@ -7383,7 +7384,8 @@ spec:
                             type: object
                             x-kubernetes-preserve-unknown-fields: true
                           enabled:
-                            description: 'Deprecated: no longer in use.'
+                            description: Can be used to enable or disable a trait.
+                              All traits share this common property.
                             type: boolean
                           list:
                             description: Comma separated list of Kamelet names to
diff --git a/docs/modules/ROOT/partials/apis/camel-k-crds.adoc b/docs/modules/ROOT/partials/apis/camel-k-crds.adoc
index 5cef30702..d280492a7 100644
--- a/docs/modules/ROOT/partials/apis/camel-k-crds.adoc
+++ b/docs/modules/ROOT/partials/apis/camel-k-crds.adoc
@@ -6731,9 +6731,9 @@ The JVM trait is used to configure the JVM that runs the integration.
 |Field
 |Description
 
-|`PlatformBaseTrait` +
-*xref:#_camel_apache_org_v1_trait_PlatformBaseTrait[PlatformBaseTrait]*
-|(Members of `PlatformBaseTrait` are embedded into this type.)
+|`Trait` +
+*xref:#_camel_apache_org_v1_trait_Trait[Trait]*
+|(Members of `Trait` are embedded into this type.)
 
 
 
@@ -6911,9 +6911,9 @@ The kamelets trait is a platform trait used to inject Kamelets into the integrat
 |Field
 |Description
 
-|`PlatformBaseTrait` +
-*xref:#_camel_apache_org_v1_trait_PlatformBaseTrait[PlatformBaseTrait]*
-|(Members of `PlatformBaseTrait` are embedded into this type.)
+|`Trait` +
+*xref:#_camel_apache_org_v1_trait_Trait[Trait]*
+|(Members of `Trait` are embedded into this type.)
 
 
 
@@ -7417,8 +7417,6 @@ Only one of `max-unavailable` and `min-available` can be specified.
 * <<#_camel_apache_org_v1_trait_DeploymentTrait, DeploymentTrait>>
 * <<#_camel_apache_org_v1_trait_EnvironmentTrait, EnvironmentTrait>>
 * <<#_camel_apache_org_v1_trait_ErrorHandlerTrait, ErrorHandlerTrait>>
-* <<#_camel_apache_org_v1_trait_JVMTrait, JVMTrait>>
-* <<#_camel_apache_org_v1_trait_KameletsTrait, KameletsTrait>>
 * <<#_camel_apache_org_v1_trait_MountTrait, MountTrait>>
 * <<#_camel_apache_org_v1_trait_OpenAPITrait, OpenAPITrait>>
 * <<#_camel_apache_org_v1_trait_PlatformTrait, PlatformTrait>>
@@ -8054,7 +8052,9 @@ The list of taints to tolerate, in the form `Key[=Value]:Effect[:Seconds]`
 * <<#_camel_apache_org_v1_trait_HealthTrait, HealthTrait>>
 * <<#_camel_apache_org_v1_trait_IngressTrait, IngressTrait>>
 * <<#_camel_apache_org_v1_trait_IstioTrait, IstioTrait>>
+* <<#_camel_apache_org_v1_trait_JVMTrait, JVMTrait>>
 * <<#_camel_apache_org_v1_trait_JolokiaTrait, JolokiaTrait>>
+* <<#_camel_apache_org_v1_trait_KameletsTrait, KameletsTrait>>
 * <<#_camel_apache_org_v1_trait_KnativeServiceTrait, KnativeServiceTrait>>
 * <<#_camel_apache_org_v1_trait_KnativeTrait, KnativeTrait>>
 * <<#_camel_apache_org_v1_trait_LoggingTrait, LoggingTrait>>
@@ -8069,7 +8069,7 @@ The list of taints to tolerate, in the form `Key[=Value]:Effect[:Seconds]`
 * <<#_camel_apache_org_v1_trait_ServiceTrait, ServiceTrait>>
 * <<#_camel_apache_org_v1_trait_TolerationTrait, TolerationTrait>>
 
-Trait is the base type for all traits. It could be disabled by the user
+Trait is the base type for all traits. It could be disabled by the user.
 
 [cols="2,2a",options="header"]
 |===
diff --git a/docs/modules/traits/pages/jvm.adoc b/docs/modules/traits/pages/jvm.adoc
index 5e6780e87..7c7056d5c 100755
--- a/docs/modules/traits/pages/jvm.adoc
+++ b/docs/modules/traits/pages/jvm.adoc
@@ -6,8 +6,6 @@ The JVM trait is used to configure the JVM that runs the integration.
 
 This trait is available in the following profiles: **Kubernetes, Knative, OpenShift**.
 
-NOTE: The jvm trait is a *platform trait* and cannot be disabled by the user.
-
 // End of autogenerated code - DO NOT EDIT! (description)
 // Start of autogenerated code - DO NOT EDIT! (configuration)
 == Configuration
@@ -25,7 +23,7 @@ The following configuration options are available:
 
 | jvm.enabled
 | bool
-| Deprecated: no longer in use.
+| Can be used to enable or disable a trait. All traits share this common property.
 
 | jvm.debug
 | bool
diff --git a/docs/modules/traits/pages/kamelets.adoc b/docs/modules/traits/pages/kamelets.adoc
index 7930d7868..0336e0ff4 100755
--- a/docs/modules/traits/pages/kamelets.adoc
+++ b/docs/modules/traits/pages/kamelets.adoc
@@ -6,8 +6,6 @@ The kamelets trait is a platform trait used to inject Kamelets into the integrat
 
 This trait is available in the following profiles: **Kubernetes, Knative, OpenShift**.
 
-NOTE: The kamelets trait is a *platform trait* and cannot be disabled by the user.
-
 // End of autogenerated code - DO NOT EDIT! (description)
 // Start of autogenerated code - DO NOT EDIT! (configuration)
 == Configuration
@@ -25,7 +23,7 @@ The following configuration options are available:
 
 | kamelets.enabled
 | bool
-| Deprecated: no longer in use.
+| Can be used to enable or disable a trait. All traits share this common property.
 
 | kamelets.auto
 | bool
diff --git a/helm/camel-k/crds/crd-integration-platform.yaml b/helm/camel-k/crds/crd-integration-platform.yaml
index 9ce27b07b..d34c2f432 100644
--- a/helm/camel-k/crds/crd-integration-platform.yaml
+++ b/helm/camel-k/crds/crd-integration-platform.yaml
@@ -1157,7 +1157,8 @@ spec:
                           main class is loaded
                         type: boolean
                       enabled:
-                        description: 'Deprecated: no longer in use.'
+                        description: Can be used to enable or disable a trait. All
+                          traits share this common property.
                         type: boolean
                       options:
                         description: A list of JVM options
@@ -1182,7 +1183,8 @@ spec:
                         type: object
                         x-kubernetes-preserve-unknown-fields: true
                       enabled:
-                        description: 'Deprecated: no longer in use.'
+                        description: Can be used to enable or disable a trait. All
+                          traits share this common property.
                         type: boolean
                       list:
                         description: Comma separated list of Kamelet names to load
@@ -2969,7 +2971,8 @@ spec:
                           main class is loaded
                         type: boolean
                       enabled:
-                        description: 'Deprecated: no longer in use.'
+                        description: Can be used to enable or disable a trait. All
+                          traits share this common property.
                         type: boolean
                       options:
                         description: A list of JVM options
@@ -2994,7 +2997,8 @@ spec:
                         type: object
                         x-kubernetes-preserve-unknown-fields: true
                       enabled:
-                        description: 'Deprecated: no longer in use.'
+                        description: Can be used to enable or disable a trait. All
+                          traits share this common property.
                         type: boolean
                       list:
                         description: Comma separated list of Kamelet names to load
diff --git a/helm/camel-k/crds/crd-integration.yaml b/helm/camel-k/crds/crd-integration.yaml
index 4fa5b64be..608118fef 100644
--- a/helm/camel-k/crds/crd-integration.yaml
+++ b/helm/camel-k/crds/crd-integration.yaml
@@ -7074,7 +7074,8 @@ spec:
                           main class is loaded
                         type: boolean
                       enabled:
-                        description: 'Deprecated: no longer in use.'
+                        description: Can be used to enable or disable a trait. All
+                          traits share this common property.
                         type: boolean
                       options:
                         description: A list of JVM options
@@ -7099,7 +7100,8 @@ spec:
                         type: object
                         x-kubernetes-preserve-unknown-fields: true
                       enabled:
-                        description: 'Deprecated: no longer in use.'
+                        description: Can be used to enable or disable a trait. All
+                          traits share this common property.
                         type: boolean
                       list:
                         description: Comma separated list of Kamelet names to load
diff --git a/helm/camel-k/crds/crd-kamelet-binding.yaml b/helm/camel-k/crds/crd-kamelet-binding.yaml
index d0356a2a4..b40d8c9a8 100644
--- a/helm/camel-k/crds/crd-kamelet-binding.yaml
+++ b/helm/camel-k/crds/crd-kamelet-binding.yaml
@@ -7360,7 +7360,8 @@ spec:
                               the main class is loaded
                             type: boolean
                           enabled:
-                            description: 'Deprecated: no longer in use.'
+                            description: Can be used to enable or disable a trait.
+                              All traits share this common property.
                             type: boolean
                           options:
                             description: A list of JVM options
@@ -7385,7 +7386,8 @@ spec:
                             type: object
                             x-kubernetes-preserve-unknown-fields: true
                           enabled:
-                            description: 'Deprecated: no longer in use.'
+                            description: Can be used to enable or disable a trait.
+                              All traits share this common property.
                             type: boolean
                           list:
                             description: Comma separated list of Kamelet names to
diff --git a/helm/camel-k/crds/crd-pipe.yaml b/helm/camel-k/crds/crd-pipe.yaml
index 804c1667d..ca6c71c0e 100644
--- a/helm/camel-k/crds/crd-pipe.yaml
+++ b/helm/camel-k/crds/crd-pipe.yaml
@@ -7358,7 +7358,8 @@ spec:
                               the main class is loaded
                             type: boolean
                           enabled:
-                            description: 'Deprecated: no longer in use.'
+                            description: Can be used to enable or disable a trait.
+                              All traits share this common property.
                             type: boolean
                           options:
                             description: A list of JVM options
@@ -7383,7 +7384,8 @@ spec:
                             type: object
                             x-kubernetes-preserve-unknown-fields: true
                           enabled:
-                            description: 'Deprecated: no longer in use.'
+                            description: Can be used to enable or disable a trait.
+                              All traits share this common property.
                             type: boolean
                           list:
                             description: Comma separated list of Kamelet names to
diff --git a/pkg/apis/camel/v1/trait/jvm.go b/pkg/apis/camel/v1/trait/jvm.go
index 8d35f1ac2..70bb3b7de 100644
--- a/pkg/apis/camel/v1/trait/jvm.go
+++ b/pkg/apis/camel/v1/trait/jvm.go
@@ -21,7 +21,7 @@ package trait
 //
 // +camel-k:trait=jvm.
 type JVMTrait struct {
-	PlatformBaseTrait `property:",squash" json:",inline"`
+	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
diff --git a/pkg/apis/camel/v1/trait/kamelets.go b/pkg/apis/camel/v1/trait/kamelets.go
index ba0650da3..9467b4883 100644
--- a/pkg/apis/camel/v1/trait/kamelets.go
+++ b/pkg/apis/camel/v1/trait/kamelets.go
@@ -21,7 +21,7 @@ package trait
 //
 // +camel-k:trait=kamelets.
 type KameletsTrait struct {
-	PlatformBaseTrait `property:",squash" json:",inline"`
+	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
diff --git a/pkg/apis/camel/v1/trait/zz_generated.deepcopy.go b/pkg/apis/camel/v1/trait/zz_generated.deepcopy.go
index 00e477ef7..5cfb02958 100644
--- a/pkg/apis/camel/v1/trait/zz_generated.deepcopy.go
+++ b/pkg/apis/camel/v1/trait/zz_generated.deepcopy.go
@@ -443,7 +443,7 @@ func (in *IstioTrait) DeepCopy() *IstioTrait {
 // 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.PlatformBaseTrait.DeepCopyInto(&out.PlatformBaseTrait)
+	in.Trait.DeepCopyInto(&out.Trait)
 	if in.Debug != nil {
 		in, out := &in.Debug, &out.Debug
 		*out = new(bool)
@@ -545,7 +545,7 @@ func (in *JolokiaTrait) DeepCopy() *JolokiaTrait {
 // 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.PlatformBaseTrait.DeepCopyInto(&out.PlatformBaseTrait)
+	in.Trait.DeepCopyInto(&out.Trait)
 	if in.Auto != nil {
 		in, out := &in.Auto, &out.Auto
 		*out = new(bool)
diff --git a/pkg/trait/jvm.go b/pkg/trait/jvm.go
index 5cc60c844..720d22f64 100644
--- a/pkg/trait/jvm.go
+++ b/pkg/trait/jvm.go
@@ -41,13 +41,13 @@ import (
 )
 
 type jvmTrait struct {
-	BasePlatformTrait
+	BaseTrait
 	traitv1.JVMTrait `property:",squash"`
 }
 
 func newJvmTrait() Trait {
 	return &jvmTrait{
-		BasePlatformTrait: NewBasePlatformTrait("jvm", 2000),
+		BaseTrait: NewBaseTrait("jvm", 2000),
 		JVMTrait: traitv1.JVMTrait{
 			DebugAddress: "*:5005",
 			PrintCommand: pointer.Bool(true),
@@ -56,6 +56,10 @@ func newJvmTrait() Trait {
 }
 
 func (t *jvmTrait) Configure(e *Environment) (bool, error) {
+	if !pointer.BoolDeref(t.Enabled, true) {
+		return false, nil
+	}
+
 	if !e.IntegrationKitInPhase(v1.IntegrationKitPhaseReady) || !e.IntegrationInRunningPhases() {
 		return false, nil
 	}
diff --git a/pkg/trait/kamelets.go b/pkg/trait/kamelets.go
index 7f72a6a2b..b2c410a59 100644
--- a/pkg/trait/kamelets.go
+++ b/pkg/trait/kamelets.go
@@ -60,18 +60,18 @@ func newConfigurationKey(kamelet, configurationID string) configurationKey {
 }
 
 type kameletsTrait struct {
-	BasePlatformTrait
+	BaseTrait
 	traitv1.KameletsTrait `property:",squash"`
 }
 
 func newKameletsTrait() Trait {
 	return &kameletsTrait{
-		BasePlatformTrait: NewBasePlatformTrait("kamelets", 450),
+		BaseTrait: NewBaseTrait("kamelets", 450),
 	}
 }
 
 func (t *kameletsTrait) Configure(e *Environment) (bool, error) {
-	if e.Integration == nil {
+	if e.Integration == nil || !pointer.BoolDeref(t.Enabled, true) {
 		return false, nil
 	}
 
diff --git a/resources/traits.yaml b/resources/traits.yaml
index b92251df0..4489f2040 100755
--- a/resources/traits.yaml
+++ b/resources/traits.yaml
@@ -857,7 +857,7 @@ traits:
     description: A list of additional Jolokia options as defined in https://jolokia.org/reference/html/agents.html#agent-jvm-config[JVM
       agent configuration options]
 - name: jvm
-  platform: true
+  platform: false
   profiles:
   - Kubernetes
   - Knative
@@ -866,7 +866,8 @@ traits:
   properties:
   - name: enabled
     type: bool
-    description: 'Deprecated: no longer in use.'
+    description: Can be used to enable or disable a trait. All traits share this common
+      property.
   - name: debug
     type: bool
     description: Activates remote debugging, so that a debugger can be attached to
@@ -889,7 +890,7 @@ traits:
     type: string
     description: Additional JVM classpath (use `Linux` classpath separator)
 - name: kamelets
-  platform: true
+  platform: false
   profiles:
   - Kubernetes
   - Knative
@@ -899,7 +900,8 @@ traits:
   properties:
   - name: enabled
     type: bool
-    description: 'Deprecated: no longer in use.'
+    description: Can be used to enable or disable a trait. All traits share this common
+      property.
   - name: auto
     type: bool
     description: Automatically inject all referenced Kamelets and their default configuration