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 f3daadbfed219229875f3ba9dbd1ead7876c1e54 Author: Pasquale Congiusti <pasquale.congiu...@gmail.com> AuthorDate: Mon Oct 31 13:24:10 2022 +0100 fix(trait): Camel trait as IntegrationKit Closes #3758 --- .../bases/camel.apache.org_integrationkits.yaml | 24 ++++++++++++++++++++++ docs/modules/ROOT/partials/apis/camel-k-crds.adoc | 8 ++++++++ helm/camel-k/crds/crd-integration-kit.yaml | 24 ++++++++++++++++++++++ pkg/apis/camel/v1/integrationkit_types.go | 3 ++- pkg/apis/camel/v1/zz_generated.deepcopy.go | 5 +++++ pkg/trait/camel.go | 15 +++++++++----- pkg/trait/quarkus.go | 1 + pkg/trait/trait_test.go | 2 +- 8 files changed, 75 insertions(+), 7 deletions(-) diff --git a/config/crd/bases/camel.apache.org_integrationkits.yaml b/config/crd/bases/camel.apache.org_integrationkits.yaml index 8f642f219..ab614da37 100644 --- a/config/crd/bases/camel.apache.org_integrationkits.yaml +++ b/config/crd/bases/camel.apache.org_integrationkits.yaml @@ -156,6 +156,30 @@ spec: support it (e.g. Kaniko build pod). type: boolean type: object + camel: + description: The Camel trait sets up Camel configuration. + properties: + configuration: + description: 'Legacy trait configuration parameters. Deprecated: + for backward compatibility.' + type: object + x-kubernetes-preserve-unknown-fields: true + enabled: + description: Can be used to enable or disable a trait. All + traits share this common property. + type: boolean + properties: + description: A list of properties to be provided to the Integration + runtime + items: + type: string + type: array + runtimeVersion: + description: The camel-k-runtime version to use for the integration. + It overrides the default version set in the Integration + Platform. + type: string + type: object quarkus: description: 'The Quarkus trait configures the Quarkus runtime. It''s enabled by default. NOTE: Compiling to a native executable, diff --git a/docs/modules/ROOT/partials/apis/camel-k-crds.adoc b/docs/modules/ROOT/partials/apis/camel-k-crds.adoc index a268fd66d..4012be0c0 100644 --- a/docs/modules/ROOT/partials/apis/camel-k-crds.adoc +++ b/docs/modules/ROOT/partials/apis/camel-k-crds.adoc @@ -1595,6 +1595,13 @@ NOTE: Compiling to a native executable, i.e. when using `package-type=native`, i The Registry trait sets up Maven to use the Image registry as a Maven repository. +|`camel` + +*xref:#_camel_apache_org_v1_trait_CamelTrait[CamelTrait]* +| + + +The Camel trait sets up Camel configuration. + |`addons` + *xref:#_camel_apache_org_v1_AddonTrait[map[string\]github.com/apache/camel-k/pkg/apis/camel/v1.AddonTrait]* | @@ -3736,6 +3743,7 @@ A list of properties to be provided to the build task *Appears on:* +* <<#_camel_apache_org_v1_IntegrationKitTraits, IntegrationKitTraits>> * <<#_camel_apache_org_v1_Traits, Traits>> The Camel trait can be used to configure versions of Apache Camel K runtime and related libraries, it cannot be disabled. diff --git a/helm/camel-k/crds/crd-integration-kit.yaml b/helm/camel-k/crds/crd-integration-kit.yaml index 8f642f219..ab614da37 100644 --- a/helm/camel-k/crds/crd-integration-kit.yaml +++ b/helm/camel-k/crds/crd-integration-kit.yaml @@ -156,6 +156,30 @@ spec: support it (e.g. Kaniko build pod). type: boolean type: object + camel: + description: The Camel trait sets up Camel configuration. + properties: + configuration: + description: 'Legacy trait configuration parameters. Deprecated: + for backward compatibility.' + type: object + x-kubernetes-preserve-unknown-fields: true + enabled: + description: Can be used to enable or disable a trait. All + traits share this common property. + type: boolean + properties: + description: A list of properties to be provided to the Integration + runtime + items: + type: string + type: array + runtimeVersion: + description: The camel-k-runtime version to use for the integration. + It overrides the default version set in the Integration + Platform. + type: string + type: object quarkus: description: 'The Quarkus trait configures the Quarkus runtime. It''s enabled by default. NOTE: Compiling to a native executable, diff --git a/pkg/apis/camel/v1/integrationkit_types.go b/pkg/apis/camel/v1/integrationkit_types.go index 79c853863..7b7fb53ab 100644 --- a/pkg/apis/camel/v1/integrationkit_types.go +++ b/pkg/apis/camel/v1/integrationkit_types.go @@ -77,7 +77,8 @@ type IntegrationKitTraits struct { Quarkus *trait.QuarkusTrait `property:"quarkus" json:"quarkus,omitempty"` // The Registry trait sets up Maven to use the Image registry as a Maven repository. Registry *trait.RegistryTrait `property:"registry" json:"registry,omitempty"` - + // The Camel trait sets up Camel configuration. + Camel *trait.CamelTrait `property:"camel" json:"camel,omitempty"` // The collection of addon trait configurations Addons map[string]AddonTrait `json:"addons,omitempty"` } diff --git a/pkg/apis/camel/v1/zz_generated.deepcopy.go b/pkg/apis/camel/v1/zz_generated.deepcopy.go index f93e893ef..d4d0b3e4b 100644 --- a/pkg/apis/camel/v1/zz_generated.deepcopy.go +++ b/pkg/apis/camel/v1/zz_generated.deepcopy.go @@ -838,6 +838,11 @@ func (in *IntegrationKitTraits) DeepCopyInto(out *IntegrationKitTraits) { *out = new(trait.RegistryTrait) (*in).DeepCopyInto(*out) } + if in.Camel != nil { + in, out := &in.Camel, &out.Camel + *out = new(trait.CamelTrait) + (*in).DeepCopyInto(*out) + } if in.Addons != nil { in, out := &in.Addons, &out.Addons *out = make(map[string]AddonTrait, len(*in)) diff --git a/pkg/trait/camel.go b/pkg/trait/camel.go index 82f0e91c2..4b889f381 100644 --- a/pkg/trait/camel.go +++ b/pkg/trait/camel.go @@ -48,6 +48,16 @@ func newCamelTrait() Trait { } } +// IsPlatformTrait overrides base class method. +func (t *camelTrait) IsPlatformTrait() bool { + return true +} + +// InfluencesKit overrides base class method. +func (t *camelTrait) InfluencesKit() bool { + return true +} + func (t *camelTrait) Configure(e *Environment) (bool, error) { if !pointer.BoolDeref(t.Enabled, true) { return false, errors.New("trait camel cannot be disabled") @@ -151,11 +161,6 @@ func (t *camelTrait) loadOrCreateCatalog(e *Environment, runtimeVersion string) return nil } -// IsPlatformTrait overrides base class method. -func (t *camelTrait) IsPlatformTrait() bool { - return true -} - func (t *camelTrait) computeConfigMaps(e *Environment) []ctrl.Object { sources := e.Integration.Sources() maps := make([]ctrl.Object, 0, len(sources)+1) diff --git a/pkg/trait/quarkus.go b/pkg/trait/quarkus.go index 5efa210b1..ff3decb31 100644 --- a/pkg/trait/quarkus.go +++ b/pkg/trait/quarkus.go @@ -223,6 +223,7 @@ func propagateKitTraits(e *Environment) v1.IntegrationKitTraits { traits := e.Integration.Spec.Traits kitTraits := v1.IntegrationKitTraits{ Builder: traits.Builder.DeepCopy(), + Camel: traits.Camel.DeepCopy(), Quarkus: traits.Quarkus.DeepCopy(), Registry: traits.Registry.DeepCopy(), } diff --git a/pkg/trait/trait_test.go b/pkg/trait/trait_test.go index aed180ec1..c04c33bcf 100644 --- a/pkg/trait/trait_test.go +++ b/pkg/trait/trait_test.go @@ -457,7 +457,7 @@ func TestConfigureVolumesAndMountsBinaryAndTextResources(t *testing.T) { func TestOnlySomeTraitsInfluenceBuild(t *testing.T) { c := NewTraitTestCatalog() - buildTraits := []string{"builder", "quarkus", "registry"} + buildTraits := []string{"builder", "quarkus", "registry", "camel"} for _, trait := range c.AllTraits() { if trait.InfluencesKit() {