diff --git a/config/crd/bases/camel.apache.org_builds.yaml b/config/crd/bases/camel.apache.org_builds.yaml index dea33d7179..d5fff8964e 100644 --- a/config/crd/bases/camel.apache.org_builds.yaml +++ b/config/crd/bases/camel.apache.org_builds.yaml @@ -310,50 +310,53 @@ spec: localRepository: description: The path of the local Maven repository. type: string - profile: + profiles: description: A reference to the ConfigMap or Secret key that contains the Maven profile. - properties: - configMapKeyRef: - description: Selects a key of a ConfigMap. - properties: - key: - description: The key to select. - type: string - name: - description: 'Name of the referent. More info: - https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, - kind, uid?' - type: string - optional: - description: Specify whether the ConfigMap or - its key must be defined - type: boolean - required: - - key - type: object - secretKeyRef: - description: Selects a key of a secret. - properties: - key: - description: The key of the secret to select - from. Must be a valid secret key. - type: string - name: - description: 'Name of the referent. More info: - https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, - kind, uid?' - type: string - optional: - description: Specify whether the Secret or its - key must be defined - type: boolean - required: - - key - type: object - type: object + items: + description: ValueSource -- + properties: + configMapKeyRef: + description: Selects a key of a ConfigMap. + properties: + key: + description: The key to select. + type: string + name: + description: 'Name of the referent. More info: + https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, + kind, uid?' + type: string + optional: + description: Specify whether the ConfigMap + or its key must be defined + type: boolean + required: + - key + type: object + secretKeyRef: + description: Selects a key of a secret. + properties: + key: + description: The key of the secret to select + from. Must be a valid secret key. + type: string + name: + description: 'Name of the referent. More info: + https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, + kind, uid?' + type: string + optional: + description: Specify whether the Secret or + its key must be defined + type: boolean + required: + - key + type: object + type: object + type: array properties: additionalProperties: type: string diff --git a/config/crd/bases/camel.apache.org_integrationkits.yaml b/config/crd/bases/camel.apache.org_integrationkits.yaml index d34ca382cb..d286bf52f1 100644 --- a/config/crd/bases/camel.apache.org_integrationkits.yaml +++ b/config/crd/bases/camel.apache.org_integrationkits.yaml @@ -211,16 +211,18 @@ spec: description: When using `pod` strategy, the maximum amount of memory required by the pod builder. type: string - mavenProfile: - description: 'A reference pointing to a configmap/secret that - contains a maven profile. The content of the maven profile - is expected to be a text containing a valid maven profile - starting with `` and ending with `` that - will be integrated as an inline profile in the POM. Syntax: - [configmap|secret]:name[/key], where name represents the - resource name, key optionally represents the resource key - to be filtered (default key value = profile.xml).' - type: string + mavenProfiles: + description: 'A list of references pointing to configmaps/secrets + that contains a maven profile. The content of the maven + profile is expected to be a text containing a valid maven + profile starting with `` and ending with `` + that will be integrated as an inline profile in the POM. + Syntax: [configmap|secret]:name[/key], where name represents + the resource name, key optionally represents the resource + key to be filtered (default key value = profile.xml).' + items: + type: string + type: array orderStrategy: description: The build order strategy to use, either `dependencies`, `fifo` or `sequential` (default sequential) diff --git a/config/crd/bases/camel.apache.org_integrationplatforms.yaml b/config/crd/bases/camel.apache.org_integrationplatforms.yaml index 15b266e547..9bd66b9174 100644 --- a/config/crd/bases/camel.apache.org_integrationplatforms.yaml +++ b/config/crd/bases/camel.apache.org_integrationplatforms.yaml @@ -202,48 +202,51 @@ spec: localRepository: description: The path of the local Maven repository. type: string - profile: + profiles: description: A reference to the ConfigMap or Secret key that contains the Maven profile. - properties: - configMapKeyRef: - description: Selects a key of a ConfigMap. - properties: - key: - description: The key to select. - type: string - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, - uid?' - type: string - optional: - description: Specify whether the ConfigMap or its - key must be defined - type: boolean - required: - - key - type: object - secretKeyRef: - description: Selects a key of a secret. - properties: - key: - description: The key of the secret to select from. Must - be a valid secret key. - type: string - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, - uid?' - type: string - optional: - description: Specify whether the Secret or its key - must be defined - type: boolean - required: - - key - type: object - type: object + items: + description: ValueSource -- + properties: + configMapKeyRef: + description: Selects a key of a ConfigMap. + properties: + key: + description: The key to select. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the ConfigMap or its + key must be defined + type: boolean + required: + - key + type: object + secretKeyRef: + description: Selects a key of a secret. + properties: + key: + description: The key of the secret to select from. Must + be a valid secret key. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the Secret or its key + must be defined + type: boolean + required: + - key + type: object + type: object + type: array properties: additionalProperties: type: string @@ -511,16 +514,18 @@ spec: description: When using `pod` strategy, the maximum amount of memory required by the pod builder. type: string - mavenProfile: - description: 'A reference pointing to a configmap/secret that - contains a maven profile. The content of the maven profile - is expected to be a text containing a valid maven profile - starting with `` and ending with `` that - will be integrated as an inline profile in the POM. Syntax: - [configmap|secret]:name[/key], where name represents the - resource name, key optionally represents the resource key - to be filtered (default key value = profile.xml).' - type: string + mavenProfiles: + description: 'A list of references pointing to configmaps/secrets + that contains a maven profile. The content of the maven + profile is expected to be a text containing a valid maven + profile starting with `` and ending with `` + that will be integrated as an inline profile in the POM. + Syntax: [configmap|secret]:name[/key], where name represents + the resource name, key optionally represents the resource + key to be filtered (default key value = profile.xml).' + items: + type: string + type: array orderStrategy: description: The build order strategy to use, either `dependencies`, `fifo` or `sequential` (default sequential) @@ -1914,48 +1919,51 @@ spec: localRepository: description: The path of the local Maven repository. type: string - profile: + profiles: description: A reference to the ConfigMap or Secret key that contains the Maven profile. - properties: - configMapKeyRef: - description: Selects a key of a ConfigMap. - properties: - key: - description: The key to select. - type: string - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, - uid?' - type: string - optional: - description: Specify whether the ConfigMap or its - key must be defined - type: boolean - required: - - key - type: object - secretKeyRef: - description: Selects a key of a secret. - properties: - key: - description: The key of the secret to select from. Must - be a valid secret key. - type: string - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, - uid?' - type: string - optional: - description: Specify whether the Secret or its key - must be defined - type: boolean - required: - - key - type: object - type: object + items: + description: ValueSource -- + properties: + configMapKeyRef: + description: Selects a key of a ConfigMap. + properties: + key: + description: The key to select. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the ConfigMap or its + key must be defined + type: boolean + required: + - key + type: object + secretKeyRef: + description: Selects a key of a secret. + properties: + key: + description: The key of the secret to select from. Must + be a valid secret key. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the Secret or its key + must be defined + type: boolean + required: + - key + type: object + type: object + type: array properties: additionalProperties: type: string @@ -2271,16 +2279,18 @@ spec: description: When using `pod` strategy, the maximum amount of memory required by the pod builder. type: string - mavenProfile: - description: 'A reference pointing to a configmap/secret that - contains a maven profile. The content of the maven profile - is expected to be a text containing a valid maven profile - starting with `` and ending with `` that - will be integrated as an inline profile in the POM. Syntax: - [configmap|secret]:name[/key], where name represents the - resource name, key optionally represents the resource key - to be filtered (default key value = profile.xml).' - type: string + mavenProfiles: + description: 'A list of references pointing to configmaps/secrets + that contains a maven profile. The content of the maven + profile is expected to be a text containing a valid maven + profile starting with `` and ending with `` + that will be integrated as an inline profile in the POM. + Syntax: [configmap|secret]:name[/key], where name represents + the resource name, key optionally represents the resource + key to be filtered (default key value = profile.xml).' + items: + type: string + type: array orderStrategy: description: The build order strategy to use, either `dependencies`, `fifo` or `sequential` (default sequential) diff --git a/config/crd/bases/camel.apache.org_integrations.yaml b/config/crd/bases/camel.apache.org_integrations.yaml index efdff886e1..c9ff396736 100644 --- a/config/crd/bases/camel.apache.org_integrations.yaml +++ b/config/crd/bases/camel.apache.org_integrations.yaml @@ -6194,16 +6194,18 @@ spec: description: When using `pod` strategy, the maximum amount of memory required by the pod builder. type: string - mavenProfile: - description: 'A reference pointing to a configmap/secret that - contains a maven profile. The content of the maven profile - is expected to be a text containing a valid maven profile - starting with `` and ending with `` that - will be integrated as an inline profile in the POM. Syntax: - [configmap|secret]:name[/key], where name represents the - resource name, key optionally represents the resource key - to be filtered (default key value = profile.xml).' - type: string + mavenProfiles: + description: 'A list of references pointing to configmaps/secrets + that contains a maven profile. The content of the maven + profile is expected to be a text containing a valid maven + profile starting with `` and ending with `` + that will be integrated as an inline profile in the POM. + Syntax: [configmap|secret]:name[/key], where name represents + the resource name, key optionally represents the resource + key to be filtered (default key value = profile.xml).' + items: + type: string + type: array orderStrategy: description: The build order strategy to use, either `dependencies`, `fifo` or `sequential` (default sequential) diff --git a/config/crd/bases/camel.apache.org_kameletbindings.yaml b/config/crd/bases/camel.apache.org_kameletbindings.yaml index fc14f54afc..69c4fecb81 100644 --- a/config/crd/bases/camel.apache.org_kameletbindings.yaml +++ b/config/crd/bases/camel.apache.org_kameletbindings.yaml @@ -6469,8 +6469,8 @@ spec: description: When using `pod` strategy, the maximum amount of memory required by the pod builder. type: string - mavenProfile: - description: 'A reference pointing to a configmap/secret + mavenProfiles: + description: 'A list of references pointing to configmaps/secrets that contains a maven profile. The content of the maven profile is expected to be a text containing a valid maven profile starting with `` and ending with @@ -6479,7 +6479,9 @@ spec: name represents the resource name, key optionally represents the resource key to be filtered (default key value = profile.xml).' - type: string + items: + type: string + type: array orderStrategy: description: The build order strategy to use, either `dependencies`, `fifo` or `sequential` (default sequential) diff --git a/config/crd/bases/camel.apache.org_pipes.yaml b/config/crd/bases/camel.apache.org_pipes.yaml index 9ceecf4736..165d7dcd01 100644 --- a/config/crd/bases/camel.apache.org_pipes.yaml +++ b/config/crd/bases/camel.apache.org_pipes.yaml @@ -6466,8 +6466,8 @@ spec: description: When using `pod` strategy, the maximum amount of memory required by the pod builder. type: string - mavenProfile: - description: 'A reference pointing to a configmap/secret + mavenProfiles: + description: 'A list of references pointing to configmaps/secrets that contains a maven profile. The content of the maven profile is expected to be a text containing a valid maven profile starting with `` and ending with @@ -6476,7 +6476,9 @@ spec: name represents the resource name, key optionally represents the resource key to be filtered (default key value = profile.xml).' - type: string + items: + type: string + type: array orderStrategy: description: The build order strategy to use, either `dependencies`, `fifo` or `sequential` (default sequential) diff --git a/docs/modules/ROOT/partials/apis/camel-k-crds.adoc b/docs/modules/ROOT/partials/apis/camel-k-crds.adoc index 5eb016eec0..1db2f63eab 100644 --- a/docs/modules/ROOT/partials/apis/camel-k-crds.adoc +++ b/docs/modules/ROOT/partials/apis/camel-k-crds.adoc @@ -3837,8 +3837,8 @@ map[string]string The Maven properties. -|`profile` + -*xref:#_camel_apache_org_v1_ValueSource[ValueSource]* +|`profiles` + +*xref:#_camel_apache_org_v1_ValueSource[[\]ValueSource]* | @@ -5451,12 +5451,12 @@ string When using `pod` strategy, the maximum amount of memory required by the pod builder. -|`mavenProfile` + -string +|`mavenProfiles` + +[]string | -A reference pointing to a configmap/secret that contains a maven profile. +A list of references pointing to configmaps/secrets that contains a maven profile. The content of the maven profile is expected to be a text containing a valid maven profile starting with `` and ending with `` that will be integrated as an inline profile in the POM. Syntax: [configmap{vbar}secret]:name[/key], where name represents the resource name, key optionally represents the resource key to be filtered (default key value = profile.xml). diff --git a/docs/modules/traits/pages/builder.adoc b/docs/modules/traits/pages/builder.adoc index b9d9edf599..891bd196df 100755 --- a/docs/modules/traits/pages/builder.adoc +++ b/docs/modules/traits/pages/builder.adoc @@ -60,9 +60,9 @@ The following configuration options are available: | string | When using `pod` strategy, the maximum amount of memory required by the pod builder. -| builder.maven-profile -| string -| A reference pointing to a configmap/secret that contains a maven profile. +| builder.maven-profiles +| []string +| A list of references pointing to configmaps/secrets that contains a maven profile. The content of the maven profile is expected to be a text containing a valid maven profile starting with `` and ending with `` that will be integrated as an inline profile in the POM. Syntax: [configmap\|secret]:name[/key], where name represents the resource name, key optionally represents the resource key to be filtered (default key value = profile.xml). diff --git a/e2e/common/traits/builder_test.go b/e2e/common/traits/builder_test.go index c1e9ed492a..795b2abd33 100644 --- a/e2e/common/traits/builder_test.go +++ b/e2e/common/traits/builder_test.go @@ -229,12 +229,15 @@ func TestBuilderTrait(t *testing.T) { t.Run("Run maven profile", func(t *testing.T) { name := "java-maven-profile" - mavenProfileCm := newMavenProfileConfigMap(ns, "maven-profile", "owasp-profile") - Expect(TestClient().Create(TestContext, mavenProfileCm)).To(Succeed()) + mavenProfile1Cm := newMavenProfileConfigMap(ns, "maven-profile-owasp", "owasp-profile") + Expect(TestClient().Create(TestContext, mavenProfile1Cm)).To(Succeed()) + mavenProfile2Cm := newMavenProfileConfigMap(ns, "maven-profile-dependency", "dependency-profile") + Expect(TestClient().Create(TestContext, mavenProfile2Cm)).To(Succeed()) Expect(KamelRunWithID(operatorID, ns, "files/Java.java", "--name", name, - "-t", "builder.maven-profile=configmap:maven-profile/owasp-profile", + "-t", "builder.maven-profiles=configmap:maven-profile-owasp/owasp-profile", + "-t", "builder.maven-profiles=configmap:maven-profile-dependency/dependency-profile", "-t", "builder.tasks=custom1;alpine;cat maven/pom.xml", "-t", "builder.strategy=pod", ).Execute()).To(Succeed()) @@ -260,10 +263,12 @@ func TestBuilderTrait(t *testing.T) { TestTimeoutShort).Should(ContainSubstring("")) // Check logs - Eventually(Logs(ns, builderKitName, corev1.PodLogOptions{Container: "custom1"})).Should(ContainSubstring(`owasp-dependency-check`)) + Eventually(Logs(ns, builderKitName, corev1.PodLogOptions{Container: "custom1"})).Should(ContainSubstring(`owasp-profile`)) + Eventually(Logs(ns, builderKitName, corev1.PodLogOptions{Container: "custom1"})).Should(ContainSubstring(`dependency-profile`)) Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed()) - Expect(TestClient().Delete(TestContext, mavenProfileCm)).To(Succeed()) + Expect(TestClient().Delete(TestContext, mavenProfile1Cm)).To(Succeed()) + Expect(TestClient().Delete(TestContext, mavenProfile2Cm)).To(Succeed()) }) } @@ -280,7 +285,7 @@ func newMavenProfileConfigMap(ns, name, key string) *corev1.ConfigMap { Data: map[string]string{ key: fmt.Sprintf(` - owasp-dependency-check + ` + key + ` diff --git a/helm/camel-k/crds/crd-build.yaml b/helm/camel-k/crds/crd-build.yaml index dea33d7179..d5fff8964e 100644 --- a/helm/camel-k/crds/crd-build.yaml +++ b/helm/camel-k/crds/crd-build.yaml @@ -310,50 +310,53 @@ spec: localRepository: description: The path of the local Maven repository. type: string - profile: + profiles: description: A reference to the ConfigMap or Secret key that contains the Maven profile. - properties: - configMapKeyRef: - description: Selects a key of a ConfigMap. - properties: - key: - description: The key to select. - type: string - name: - description: 'Name of the referent. More info: - https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, - kind, uid?' - type: string - optional: - description: Specify whether the ConfigMap or - its key must be defined - type: boolean - required: - - key - type: object - secretKeyRef: - description: Selects a key of a secret. - properties: - key: - description: The key of the secret to select - from. Must be a valid secret key. - type: string - name: - description: 'Name of the referent. More info: - https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, - kind, uid?' - type: string - optional: - description: Specify whether the Secret or its - key must be defined - type: boolean - required: - - key - type: object - type: object + items: + description: ValueSource -- + properties: + configMapKeyRef: + description: Selects a key of a ConfigMap. + properties: + key: + description: The key to select. + type: string + name: + description: 'Name of the referent. More info: + https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, + kind, uid?' + type: string + optional: + description: Specify whether the ConfigMap + or its key must be defined + type: boolean + required: + - key + type: object + secretKeyRef: + description: Selects a key of a secret. + properties: + key: + description: The key of the secret to select + from. Must be a valid secret key. + type: string + name: + description: 'Name of the referent. More info: + https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, + kind, uid?' + type: string + optional: + description: Specify whether the Secret or + its key must be defined + type: boolean + required: + - key + type: object + type: object + type: array properties: additionalProperties: type: string diff --git a/helm/camel-k/crds/crd-integration-kit.yaml b/helm/camel-k/crds/crd-integration-kit.yaml index d34ca382cb..d286bf52f1 100644 --- a/helm/camel-k/crds/crd-integration-kit.yaml +++ b/helm/camel-k/crds/crd-integration-kit.yaml @@ -211,16 +211,18 @@ spec: description: When using `pod` strategy, the maximum amount of memory required by the pod builder. type: string - mavenProfile: - description: 'A reference pointing to a configmap/secret that - contains a maven profile. The content of the maven profile - is expected to be a text containing a valid maven profile - starting with `` and ending with `` that - will be integrated as an inline profile in the POM. Syntax: - [configmap|secret]:name[/key], where name represents the - resource name, key optionally represents the resource key - to be filtered (default key value = profile.xml).' - type: string + mavenProfiles: + description: 'A list of references pointing to configmaps/secrets + that contains a maven profile. The content of the maven + profile is expected to be a text containing a valid maven + profile starting with `` and ending with `` + that will be integrated as an inline profile in the POM. + Syntax: [configmap|secret]:name[/key], where name represents + the resource name, key optionally represents the resource + key to be filtered (default key value = profile.xml).' + items: + type: string + type: array orderStrategy: description: The build order strategy to use, either `dependencies`, `fifo` or `sequential` (default sequential) diff --git a/helm/camel-k/crds/crd-integration-platform.yaml b/helm/camel-k/crds/crd-integration-platform.yaml index 15b266e547..9bd66b9174 100644 --- a/helm/camel-k/crds/crd-integration-platform.yaml +++ b/helm/camel-k/crds/crd-integration-platform.yaml @@ -202,48 +202,51 @@ spec: localRepository: description: The path of the local Maven repository. type: string - profile: + profiles: description: A reference to the ConfigMap or Secret key that contains the Maven profile. - properties: - configMapKeyRef: - description: Selects a key of a ConfigMap. - properties: - key: - description: The key to select. - type: string - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, - uid?' - type: string - optional: - description: Specify whether the ConfigMap or its - key must be defined - type: boolean - required: - - key - type: object - secretKeyRef: - description: Selects a key of a secret. - properties: - key: - description: The key of the secret to select from. Must - be a valid secret key. - type: string - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, - uid?' - type: string - optional: - description: Specify whether the Secret or its key - must be defined - type: boolean - required: - - key - type: object - type: object + items: + description: ValueSource -- + properties: + configMapKeyRef: + description: Selects a key of a ConfigMap. + properties: + key: + description: The key to select. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the ConfigMap or its + key must be defined + type: boolean + required: + - key + type: object + secretKeyRef: + description: Selects a key of a secret. + properties: + key: + description: The key of the secret to select from. Must + be a valid secret key. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the Secret or its key + must be defined + type: boolean + required: + - key + type: object + type: object + type: array properties: additionalProperties: type: string @@ -511,16 +514,18 @@ spec: description: When using `pod` strategy, the maximum amount of memory required by the pod builder. type: string - mavenProfile: - description: 'A reference pointing to a configmap/secret that - contains a maven profile. The content of the maven profile - is expected to be a text containing a valid maven profile - starting with `` and ending with `` that - will be integrated as an inline profile in the POM. Syntax: - [configmap|secret]:name[/key], where name represents the - resource name, key optionally represents the resource key - to be filtered (default key value = profile.xml).' - type: string + mavenProfiles: + description: 'A list of references pointing to configmaps/secrets + that contains a maven profile. The content of the maven + profile is expected to be a text containing a valid maven + profile starting with `` and ending with `` + that will be integrated as an inline profile in the POM. + Syntax: [configmap|secret]:name[/key], where name represents + the resource name, key optionally represents the resource + key to be filtered (default key value = profile.xml).' + items: + type: string + type: array orderStrategy: description: The build order strategy to use, either `dependencies`, `fifo` or `sequential` (default sequential) @@ -1914,48 +1919,51 @@ spec: localRepository: description: The path of the local Maven repository. type: string - profile: + profiles: description: A reference to the ConfigMap or Secret key that contains the Maven profile. - properties: - configMapKeyRef: - description: Selects a key of a ConfigMap. - properties: - key: - description: The key to select. - type: string - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, - uid?' - type: string - optional: - description: Specify whether the ConfigMap or its - key must be defined - type: boolean - required: - - key - type: object - secretKeyRef: - description: Selects a key of a secret. - properties: - key: - description: The key of the secret to select from. Must - be a valid secret key. - type: string - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, - uid?' - type: string - optional: - description: Specify whether the Secret or its key - must be defined - type: boolean - required: - - key - type: object - type: object + items: + description: ValueSource -- + properties: + configMapKeyRef: + description: Selects a key of a ConfigMap. + properties: + key: + description: The key to select. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the ConfigMap or its + key must be defined + type: boolean + required: + - key + type: object + secretKeyRef: + description: Selects a key of a secret. + properties: + key: + description: The key of the secret to select from. Must + be a valid secret key. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the Secret or its key + must be defined + type: boolean + required: + - key + type: object + type: object + type: array properties: additionalProperties: type: string @@ -2271,16 +2279,18 @@ spec: description: When using `pod` strategy, the maximum amount of memory required by the pod builder. type: string - mavenProfile: - description: 'A reference pointing to a configmap/secret that - contains a maven profile. The content of the maven profile - is expected to be a text containing a valid maven profile - starting with `` and ending with `` that - will be integrated as an inline profile in the POM. Syntax: - [configmap|secret]:name[/key], where name represents the - resource name, key optionally represents the resource key - to be filtered (default key value = profile.xml).' - type: string + mavenProfiles: + description: 'A list of references pointing to configmaps/secrets + that contains a maven profile. The content of the maven + profile is expected to be a text containing a valid maven + profile starting with `` and ending with `` + that will be integrated as an inline profile in the POM. + Syntax: [configmap|secret]:name[/key], where name represents + the resource name, key optionally represents the resource + key to be filtered (default key value = profile.xml).' + items: + type: string + type: array orderStrategy: description: The build order strategy to use, either `dependencies`, `fifo` or `sequential` (default sequential) diff --git a/helm/camel-k/crds/crd-integration.yaml b/helm/camel-k/crds/crd-integration.yaml index efdff886e1..c9ff396736 100644 --- a/helm/camel-k/crds/crd-integration.yaml +++ b/helm/camel-k/crds/crd-integration.yaml @@ -6194,16 +6194,18 @@ spec: description: When using `pod` strategy, the maximum amount of memory required by the pod builder. type: string - mavenProfile: - description: 'A reference pointing to a configmap/secret that - contains a maven profile. The content of the maven profile - is expected to be a text containing a valid maven profile - starting with `` and ending with `` that - will be integrated as an inline profile in the POM. Syntax: - [configmap|secret]:name[/key], where name represents the - resource name, key optionally represents the resource key - to be filtered (default key value = profile.xml).' - type: string + mavenProfiles: + description: 'A list of references pointing to configmaps/secrets + that contains a maven profile. The content of the maven + profile is expected to be a text containing a valid maven + profile starting with `` and ending with `` + that will be integrated as an inline profile in the POM. + Syntax: [configmap|secret]:name[/key], where name represents + the resource name, key optionally represents the resource + key to be filtered (default key value = profile.xml).' + items: + type: string + type: array orderStrategy: description: The build order strategy to use, either `dependencies`, `fifo` or `sequential` (default sequential) diff --git a/helm/camel-k/crds/crd-kamelet-binding.yaml b/helm/camel-k/crds/crd-kamelet-binding.yaml index fc14f54afc..69c4fecb81 100644 --- a/helm/camel-k/crds/crd-kamelet-binding.yaml +++ b/helm/camel-k/crds/crd-kamelet-binding.yaml @@ -6469,8 +6469,8 @@ spec: description: When using `pod` strategy, the maximum amount of memory required by the pod builder. type: string - mavenProfile: - description: 'A reference pointing to a configmap/secret + mavenProfiles: + description: 'A list of references pointing to configmaps/secrets that contains a maven profile. The content of the maven profile is expected to be a text containing a valid maven profile starting with `` and ending with @@ -6479,7 +6479,9 @@ spec: name represents the resource name, key optionally represents the resource key to be filtered (default key value = profile.xml).' - type: string + items: + type: string + type: array orderStrategy: description: The build order strategy to use, either `dependencies`, `fifo` or `sequential` (default sequential) diff --git a/helm/camel-k/crds/crd-pipe.yaml b/helm/camel-k/crds/crd-pipe.yaml index 9ceecf4736..165d7dcd01 100644 --- a/helm/camel-k/crds/crd-pipe.yaml +++ b/helm/camel-k/crds/crd-pipe.yaml @@ -6466,8 +6466,8 @@ spec: description: When using `pod` strategy, the maximum amount of memory required by the pod builder. type: string - mavenProfile: - description: 'A reference pointing to a configmap/secret + mavenProfiles: + description: 'A list of references pointing to configmaps/secrets that contains a maven profile. The content of the maven profile is expected to be a text containing a valid maven profile starting with `` and ending with @@ -6476,7 +6476,9 @@ spec: name represents the resource name, key optionally represents the resource key to be filtered (default key value = profile.xml).' - type: string + items: + type: string + type: array orderStrategy: description: The build order strategy to use, either `dependencies`, `fifo` or `sequential` (default sequential) diff --git a/pkg/apis/camel/v1/maven_types.go b/pkg/apis/camel/v1/maven_types.go index 66101d2026..0650279e3e 100644 --- a/pkg/apis/camel/v1/maven_types.go +++ b/pkg/apis/camel/v1/maven_types.go @@ -31,7 +31,7 @@ type MavenSpec struct { Properties map[string]string `json:"properties,omitempty"` // A reference to the ConfigMap or Secret key that contains // the Maven profile. - Profile ValueSource `json:"profile,omitempty"` + Profiles []ValueSource `json:"profiles,omitempty"` // A reference to the ConfigMap or Secret key that contains // the Maven settings. Settings ValueSource `json:"settings,omitempty"` diff --git a/pkg/apis/camel/v1/trait/builder.go b/pkg/apis/camel/v1/trait/builder.go index dd4fa05c7e..166975c3bb 100644 --- a/pkg/apis/camel/v1/trait/builder.go +++ b/pkg/apis/camel/v1/trait/builder.go @@ -39,10 +39,10 @@ type BuilderTrait struct { LimitCPU string `property:"limit-cpu" json:"limitCPU,omitempty"` // When using `pod` strategy, the maximum amount of memory required by the pod builder. LimitMemory string `property:"limit-memory" json:"limitMemory,omitempty"` - // A reference pointing to a configmap/secret that contains a maven profile. + // A list of references pointing to configmaps/secrets that contains a maven profile. // The content of the maven profile is expected to be a text containing a valid maven profile starting with `` and ending with `` that will be integrated as an inline profile in the POM. // Syntax: [configmap|secret]:name[/key], where name represents the resource name, key optionally represents the resource key to be filtered (default key value = profile.xml). - MavenProfile string `property:"maven-profile" json:"mavenProfile,omitempty"` + MavenProfiles []string `property:"maven-profiles" json:"mavenProfiles,omitempty"` // A list of tasks to be executed (available only when using `pod` strategy) with format ;; Tasks []string `property:"tasks" json:"tasks,omitempty"` } diff --git a/pkg/apis/camel/v1/trait/zz_generated.deepcopy.go b/pkg/apis/camel/v1/trait/zz_generated.deepcopy.go index bad665a54c..0371733701 100644 --- a/pkg/apis/camel/v1/trait/zz_generated.deepcopy.go +++ b/pkg/apis/camel/v1/trait/zz_generated.deepcopy.go @@ -64,6 +64,11 @@ func (in *BuilderTrait) DeepCopyInto(out *BuilderTrait) { *out = make([]string, len(*in)) copy(*out, *in) } + if in.MavenProfiles != nil { + in, out := &in.MavenProfiles, &out.MavenProfiles + *out = make([]string, len(*in)) + copy(*out, *in) + } if in.Tasks != nil { in, out := &in.Tasks, &out.Tasks *out = make([]string, len(*in)) diff --git a/pkg/apis/camel/v1/zz_generated.deepcopy.go b/pkg/apis/camel/v1/zz_generated.deepcopy.go index e1e5783895..cc0853d904 100644 --- a/pkg/apis/camel/v1/zz_generated.deepcopy.go +++ b/pkg/apis/camel/v1/zz_generated.deepcopy.go @@ -2000,7 +2000,13 @@ func (in *MavenSpec) DeepCopyInto(out *MavenSpec) { (*out)[key] = val } } - in.Profile.DeepCopyInto(&out.Profile) + if in.Profiles != nil { + in, out := &in.Profiles, &out.Profiles + *out = make([]ValueSource, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } in.Settings.DeepCopyInto(&out.Settings) in.SettingsSecurity.DeepCopyInto(&out.SettingsSecurity) if in.CASecrets != nil { diff --git a/pkg/builder/project.go b/pkg/builder/project.go index ab6c8baf78..e31e25a56b 100644 --- a/pkg/builder/project.go +++ b/pkg/builder/project.go @@ -41,7 +41,7 @@ func init() { Project.GenerateProjectSettings, Project.InjectDependencies, Project.SanitizeDependencies, - Project.InjectProfile, + Project.InjectProfiles, } } @@ -51,7 +51,7 @@ type projectSteps struct { GenerateProjectSettings Step InjectDependencies Step SanitizeDependencies Step - InjectProfile Step + InjectProfiles Step CommonSteps []Step } @@ -62,7 +62,7 @@ var Project = projectSteps{ GenerateProjectSettings: NewStep(ProjectGenerationPhase+1, generateProjectSettings), InjectDependencies: NewStep(ProjectGenerationPhase+2, injectDependencies), SanitizeDependencies: NewStep(ProjectGenerationPhase+3, sanitizeDependencies), - InjectProfile: NewStep(ProjectGenerationPhase+4, injectProfile), + InjectProfiles: NewStep(ProjectGenerationPhase+4, injectProfiles), } func cleanUpBuildDir(ctx *builderContext) error { @@ -195,13 +195,19 @@ func sanitizeDependencies(ctx *builderContext) error { return camel.SanitizeIntegrationDependencies(ctx.Maven.Project.Dependencies) } -func injectProfile(ctx *builderContext) error { - val, err := kubernetes.ResolveValueSource(ctx.C, ctx.Client, ctx.Namespace, &ctx.Build.Maven.Profile) - if err != nil { - return err - } - if val != "" { - ctx.Maven.Project.AddProfile(val) +func injectProfiles(ctx *builderContext) error { + if ctx.Build.Maven.Profiles != nil { + profiles := "" + for _, profile := range ctx.Build.Maven.Profiles { + val, err := kubernetes.ResolveValueSource(ctx.C, ctx.Client, ctx.Namespace, &profile) + if err != nil { + return err + } + if val != "" { + profiles += val + } + } + ctx.Maven.Project.AddProfiles(profiles) } return nil } diff --git a/pkg/client/camel/applyconfiguration/camel/v1/mavenbuildspec.go b/pkg/client/camel/applyconfiguration/camel/v1/mavenbuildspec.go index 52528bcf87..6fec4f0205 100644 --- a/pkg/client/camel/applyconfiguration/camel/v1/mavenbuildspec.go +++ b/pkg/client/camel/applyconfiguration/camel/v1/mavenbuildspec.go @@ -59,11 +59,16 @@ func (b *MavenBuildSpecApplyConfiguration) WithProperties(entries map[string]str return b } -// WithProfile sets the Profile field in the declarative configuration to the given value -// and returns the receiver, so that objects can be built by chaining "With" function invocations. -// If called multiple times, the Profile field is set to the value of the last call. -func (b *MavenBuildSpecApplyConfiguration) WithProfile(value *ValueSourceApplyConfiguration) *MavenBuildSpecApplyConfiguration { - b.Profile = value +// WithProfiles adds the given value to the Profiles field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Profiles field. +func (b *MavenBuildSpecApplyConfiguration) WithProfiles(values ...*ValueSourceApplyConfiguration) *MavenBuildSpecApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithProfiles") + } + b.Profiles = append(b.Profiles, *values[i]) + } return b } diff --git a/pkg/client/camel/applyconfiguration/camel/v1/mavenspec.go b/pkg/client/camel/applyconfiguration/camel/v1/mavenspec.go index b73c97f279..c8e833f5c0 100644 --- a/pkg/client/camel/applyconfiguration/camel/v1/mavenspec.go +++ b/pkg/client/camel/applyconfiguration/camel/v1/mavenspec.go @@ -28,7 +28,7 @@ import ( type MavenSpecApplyConfiguration struct { LocalRepository *string `json:"localRepository,omitempty"` Properties map[string]string `json:"properties,omitempty"` - Profile *ValueSourceApplyConfiguration `json:"profile,omitempty"` + Profiles []ValueSourceApplyConfiguration `json:"profiles,omitempty"` Settings *ValueSourceApplyConfiguration `json:"settings,omitempty"` SettingsSecurity *ValueSourceApplyConfiguration `json:"settingsSecurity,omitempty"` CASecrets []corev1.SecretKeySelector `json:"caSecrets,omitempty"` @@ -64,11 +64,16 @@ func (b *MavenSpecApplyConfiguration) WithProperties(entries map[string]string) return b } -// WithProfile sets the Profile field in the declarative configuration to the given value -// and returns the receiver, so that objects can be built by chaining "With" function invocations. -// If called multiple times, the Profile field is set to the value of the last call. -func (b *MavenSpecApplyConfiguration) WithProfile(value *ValueSourceApplyConfiguration) *MavenSpecApplyConfiguration { - b.Profile = value +// WithProfiles adds the given value to the Profiles field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Profiles field. +func (b *MavenSpecApplyConfiguration) WithProfiles(values ...*ValueSourceApplyConfiguration) *MavenSpecApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithProfiles") + } + b.Profiles = append(b.Profiles, *values[i]) + } return b } diff --git a/pkg/trait/builder.go b/pkg/trait/builder.go index c9fc315c2b..16bc17cd54 100644 --- a/pkg/trait/builder.go +++ b/pkg/trait/builder.go @@ -285,14 +285,25 @@ func (t *builderTrait) builderTask(e *Environment) (*v1.BuilderTask, error) { } // User provides a maven profile - if t.MavenProfile != "" { - mavenProfile, err := v1.DecodeValueSource(t.MavenProfile, "profile.xml", - "illegal profile definition, syntax: configmap|secret:resource-name[/profile path]") - if err != nil { - return nil, fmt.Errorf("invalid maven profile: %s: %w. ", t.MavenProfile, err) + if t.MavenProfiles != nil { + mavenProfiles := make([]v1.ValueSource, 0) + for _, v := range t.MavenProfiles { + if v != "" { + // TODO parametrize message with input + mavenProfile, err := v1.DecodeValueSource(v, "profile.xml", + "illegal profile definition, syntax: configmap|secret:resource-name[/profile path]") + if err != nil { + return nil, fmt.Errorf("invalid maven profile: %s: %w. ", v, err) + } + mavenProfiles = append(mavenProfiles, mavenProfile) + } } - task.Maven.Profile = mavenProfile + task.Maven.Profiles = mavenProfiles } + // add jib profile + /*if e.Platform.Status.Build.PublishStrategy == v1.IntegrationPlatformBuildPublishStrategyJib { + t.L.Info("GFO - You should add jib profile") + }*/ steps := make([]builder.Step, 0) steps = append(steps, builder.Project.CommonSteps...) diff --git a/pkg/trait/builder_test.go b/pkg/trait/builder_test.go index 95702bbc80..4ccd434d68 100644 --- a/pkg/trait/builder_test.go +++ b/pkg/trait/builder_test.go @@ -255,10 +255,10 @@ func findCustomTaskByName(tasks []v1.Task, name string) v1.Task { return v1.Task{} } -func TestMavenProfileBuilderTrait(t *testing.T) { +func TestMavenProfilesBuilderTrait(t *testing.T) { env := createBuilderTestEnv(v1.IntegrationPlatformClusterKubernetes, v1.IntegrationPlatformBuildPublishStrategyKaniko, v1.BuildStrategyRoutine) builderTrait := createNominalBuilderTraitTest() - builderTrait.MavenProfile = "configmap:maven-profile/owasp-profile.xml" + builderTrait.MavenProfiles = []string{"configmap:maven-profile/owasp-profile.xml", "secret:maven-profile-secret"} err := builderTrait.Apply(env) @@ -271,5 +271,24 @@ func TestMavenProfileBuilderTrait(t *testing.T) { }, Key: "owasp-profile.xml", }, - }, env.Pipeline[0].Builder.Maven.MavenSpec.Profile) + }, env.Pipeline[0].Builder.Maven.MavenSpec.Profiles[0]) + assert.Equal(t, v1.ValueSource{ + SecretKeyRef: &corev1.SecretKeySelector{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: "maven-profile-secret", + }, + Key: "profile.xml", + }, + }, env.Pipeline[0].Builder.Maven.MavenSpec.Profiles[1]) +} + +func TestInvalidMavenProfilesBuilderTrait(t *testing.T) { + env := createBuilderTestEnv(v1.IntegrationPlatformClusterKubernetes, v1.IntegrationPlatformBuildPublishStrategyKaniko, v1.BuildStrategyRoutine) + builderTrait := createNominalBuilderTraitTest() + builderTrait.MavenProfiles = []string{"fakeprofile"} + + err := builderTrait.Apply(env) + + assert.NotNil(t, err) + } diff --git a/pkg/util/maven/maven_project.go b/pkg/util/maven/maven_project.go index 4a75003f4f..7eba8f0d08 100644 --- a/pkg/util/maven/maven_project.go +++ b/pkg/util/maven/maven_project.go @@ -152,8 +152,8 @@ func (p *Project) AddEncodedDependencyExclusion(gav string, exclusion Exclusion) } } -func (p *Project) AddProfile(profile string) { - p.Profiles = ProfilesContent{InnerXML: profile} +func (p *Project) AddProfiles(profiles string) { + p.Profiles = ProfilesContent{InnerXML: profiles} } // NewDependency creates an new dependency from the given GAV. diff --git a/resources/traits.yaml b/resources/traits.yaml index 6e57c10c65..64b2a0e0e6 100755 --- a/resources/traits.yaml +++ b/resources/traits.yaml @@ -232,10 +232,10 @@ traits: type: string description: When using `pod` strategy, the maximum amount of memory required by the pod builder. - - name: maven-profile - type: string - description: 'A reference pointing to a configmap/secret that contains a maven - profile. The content of the maven profile is expected to be a text containing + - name: maven-profiles + type: '[]string' + description: 'A list of references pointing to configmaps/secrets that contains + a maven profile. The content of the maven profile is expected to be a text containing a valid maven profile starting with `` and ending with `` that will be integrated as an inline profile in the POM. Syntax: [configmap|secret]:name[/key], where name represents the resource name, key optionally represents the resource