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


The following commit(s) were added to refs/heads/main by this push:
     new 88a69e6dd feat(api): IntegrationProfile dependencies
88a69e6dd is described below

commit 88a69e6ddf4535363ff07c9460042666762287c8
Author: Pasquale Congiusti <[email protected]>
AuthorDate: Sat Apr 4 10:24:21 2026 +0200

    feat(api): IntegrationProfile dependencies
    
    Closes #6537
---
 docs/modules/ROOT/partials/apis/camel-k-crds.adoc  |  7 +++
 e2e/common/misc/integration_profile_test.go        | 63 ++++++++++++++++++++++
 helm/camel-k/crds/camel-k-crds.yaml                | 10 ++++
 pkg/apis/camel/v1/integrationprofile_types.go      |  2 +
 pkg/apis/camel/v1/zz_generated.deepcopy.go         |  5 ++
 .../camel/v1/integrationprofilespec.go             | 12 +++++
 .../camel/v1/integrationprofilestatus.go           | 10 ++++
 .../camel.apache.org_integrationprofiles.yaml      | 10 ++++
 pkg/trait/dependencies.go                          |  6 +++
 pkg/trait/dependencies_test.go                     | 50 +++++++++++++++++
 10 files changed, 175 insertions(+)

diff --git a/docs/modules/ROOT/partials/apis/camel-k-crds.adoc 
b/docs/modules/ROOT/partials/apis/camel-k-crds.adoc
index d7a74a9ff..7d4d9ba8d 100644
--- a/docs/modules/ROOT/partials/apis/camel-k-crds.adoc
+++ b/docs/modules/ROOT/partials/apis/camel-k-crds.adoc
@@ -3402,6 +3402,13 @@ specify how to build the Integration/IntegrationKits
 
 list of traits to be executed for all the Integration/IntegrationKits built 
from this IntegrationProfile
 
+|`dependencies` +
+[]string
+|
+
+
+a list of dependencies needed by the application
+
 |`kamelet` +
 
*xref:#_camel_apache_org_v1_IntegrationProfileKameletSpec[IntegrationProfileKameletSpec]*
 |
diff --git a/e2e/common/misc/integration_profile_test.go 
b/e2e/common/misc/integration_profile_test.go
new file mode 100644
index 000000000..c9c47ecc9
--- /dev/null
+++ b/e2e/common/misc/integration_profile_test.go
@@ -0,0 +1,63 @@
+//go:build integration
+// +build integration
+
+// To enable compilation of this file in Goland, go to "Settings -> Go -> 
Vendoring & Build Tags -> Custom Tags" and add "integration"
+
+/*
+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 common
+
+import (
+       "context"
+       "testing"
+
+       . "github.com/onsi/gomega"
+
+       corev1 "k8s.io/api/core/v1"
+
+       . "github.com/apache/camel-k/v2/e2e/support"
+       v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
+)
+
+func TestIntegrationProfileDependencies(t *testing.T) {
+       t.Parallel()
+
+       WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) {
+               integrationProfile := v1.NewIntegrationProfile(ns, "my-profile")
+               // Any catalog dependency is good enough for this test as we 
just want to verify that any dependency set in
+               // the profile is also added in the Integration status (which 
means it was added to maven build project).
+               integrationProfile.Spec.Dependencies = []string{"camel:zipfile"}
+
+               g.Expect(CreateIntegrationProfile(t, ctx, 
&integrationProfile)).To(Succeed())
+
+               t.Run("Run sample integration", func(t *testing.T) {
+                       name := RandomizedSuffixName("profile")
+                       g.Expect(KamelRun(t, ctx, ns,
+                               "--name", name,
+                               "--annotation", 
"camel.apache.org/integration-profile.id=my-profile",
+                               "files/yaml.yaml").Execute()).To(Succeed())
+                       g.Eventually(IntegrationConditionStatus(t, ctx, ns, 
name, v1.IntegrationConditionReady), TestTimeoutMedium).
+                               Should(Equal(corev1.ConditionTrue))
+                       g.Eventually(IntegrationPodPhase(t, ctx, ns, name), 
TestTimeoutShort).Should(Equal(corev1.PodRunning))
+                       g.Eventually(IntegrationLogs(t, ctx, ns, name), 
TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+                       g.Eventually(func() []string {
+                               return Integration(t, ctx, ns, 
name)().Status.Dependencies
+                       }, 
TestTimeoutMedium).Should(ContainElement("camel:zipfile"))
+               })
+       })
+}
diff --git a/helm/camel-k/crds/camel-k-crds.yaml 
b/helm/camel-k/crds/camel-k-crds.yaml
index ef6df460d..961561de0 100644
--- a/helm/camel-k/crds/camel-k-crds.yaml
+++ b/helm/camel-k/crds/camel-k-crds.yaml
@@ -8718,6 +8718,11 @@ spec:
                       process
                     type: string
                 type: object
+              dependencies:
+                description: a list of dependencies needed by the application
+                items:
+                  type: string
+                type: array
               kamelet:
                 description: |-
                   configuration to be executed to all Kamelets controlled by 
this IntegrationProfile
@@ -11114,6 +11119,11 @@ spec:
                   - type
                   type: object
                 type: array
+              dependencies:
+                description: a list of dependencies needed by the application
+                items:
+                  type: string
+                type: array
               kamelet:
                 description: |-
                   configuration to be executed to all Kamelets controlled by 
this IntegrationProfile
diff --git a/pkg/apis/camel/v1/integrationprofile_types.go 
b/pkg/apis/camel/v1/integrationprofile_types.go
index 29578afcb..8370c957e 100644
--- a/pkg/apis/camel/v1/integrationprofile_types.go
+++ b/pkg/apis/camel/v1/integrationprofile_types.go
@@ -31,6 +31,8 @@ type IntegrationProfileSpec struct {
        Build IntegrationProfileBuildSpec `json:"build,omitempty"`
        // list of traits to be executed for all the 
Integration/IntegrationKits built from this IntegrationProfile
        Traits Traits `json:"traits,omitempty"`
+       // a list of dependencies needed by the application
+       Dependencies []string `json:"dependencies,omitempty"`
        // configuration to be executed to all Kamelets controlled by this 
IntegrationProfile
        //
        // Deprecated: to be removed in future versions.
diff --git a/pkg/apis/camel/v1/zz_generated.deepcopy.go 
b/pkg/apis/camel/v1/zz_generated.deepcopy.go
index 875c8413e..2d3e8c2a7 100644
--- a/pkg/apis/camel/v1/zz_generated.deepcopy.go
+++ b/pkg/apis/camel/v1/zz_generated.deepcopy.go
@@ -1754,6 +1754,11 @@ func (in *IntegrationProfileSpec) DeepCopyInto(out 
*IntegrationProfileSpec) {
        *out = *in
        in.Build.DeepCopyInto(&out.Build)
        in.Traits.DeepCopyInto(&out.Traits)
+       if in.Dependencies != nil {
+               in, out := &in.Dependencies, &out.Dependencies
+               *out = make([]string, len(*in))
+               copy(*out, *in)
+       }
        in.Kamelet.DeepCopyInto(&out.Kamelet)
 }
 
diff --git 
a/pkg/client/camel/applyconfiguration/camel/v1/integrationprofilespec.go 
b/pkg/client/camel/applyconfiguration/camel/v1/integrationprofilespec.go
index b949d474f..99d5906dc 100644
--- a/pkg/client/camel/applyconfiguration/camel/v1/integrationprofilespec.go
+++ b/pkg/client/camel/applyconfiguration/camel/v1/integrationprofilespec.go
@@ -30,6 +30,8 @@ type IntegrationProfileSpecApplyConfiguration struct {
        Build *IntegrationProfileBuildSpecApplyConfiguration 
`json:"build,omitempty"`
        // list of traits to be executed for all the 
Integration/IntegrationKits built from this IntegrationProfile
        Traits *TraitsApplyConfiguration `json:"traits,omitempty"`
+       // a list of dependencies needed by the application
+       Dependencies []string `json:"dependencies,omitempty"`
        // configuration to be executed to all Kamelets controlled by this 
IntegrationProfile
        //
        // Deprecated: to be removed in future versions.
@@ -58,6 +60,16 @@ func (b *IntegrationProfileSpecApplyConfiguration) 
WithTraits(value *TraitsApply
        return b
 }
 
+// WithDependencies adds the given value to the Dependencies 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 Dependencies field.
+func (b *IntegrationProfileSpecApplyConfiguration) WithDependencies(values 
...string) *IntegrationProfileSpecApplyConfiguration {
+       for i := range values {
+               b.Dependencies = append(b.Dependencies, values[i])
+       }
+       return b
+}
+
 // WithKamelet sets the Kamelet 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 Kamelet field is set to the value of the last 
call.
diff --git 
a/pkg/client/camel/applyconfiguration/camel/v1/integrationprofilestatus.go 
b/pkg/client/camel/applyconfiguration/camel/v1/integrationprofilestatus.go
index 8cf60cd84..bdde2b41e 100644
--- a/pkg/client/camel/applyconfiguration/camel/v1/integrationprofilestatus.go
+++ b/pkg/client/camel/applyconfiguration/camel/v1/integrationprofilestatus.go
@@ -59,6 +59,16 @@ func (b *IntegrationProfileStatusApplyConfiguration) 
WithTraits(value *TraitsApp
        return b
 }
 
+// WithDependencies adds the given value to the Dependencies 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 Dependencies field.
+func (b *IntegrationProfileStatusApplyConfiguration) WithDependencies(values 
...string) *IntegrationProfileStatusApplyConfiguration {
+       for i := range values {
+               b.IntegrationProfileSpecApplyConfiguration.Dependencies = 
append(b.IntegrationProfileSpecApplyConfiguration.Dependencies, values[i])
+       }
+       return b
+}
+
 // WithKamelet sets the Kamelet 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 Kamelet field is set to the value of the last 
call.
diff --git 
a/pkg/resources/config/crd/bases/camel.apache.org_integrationprofiles.yaml 
b/pkg/resources/config/crd/bases/camel.apache.org_integrationprofiles.yaml
index da6ef935f..2cac857c9 100644
--- a/pkg/resources/config/crd/bases/camel.apache.org_integrationprofiles.yaml
+++ b/pkg/resources/config/crd/bases/camel.apache.org_integrationprofiles.yaml
@@ -350,6 +350,11 @@ spec:
                       process
                     type: string
                 type: object
+              dependencies:
+                description: a list of dependencies needed by the application
+                items:
+                  type: string
+                type: array
               kamelet:
                 description: |-
                   configuration to be executed to all Kamelets controlled by 
this IntegrationProfile
@@ -2746,6 +2751,11 @@ spec:
                   - type
                   type: object
                 type: array
+              dependencies:
+                description: a list of dependencies needed by the application
+                items:
+                  type: string
+                type: array
               kamelet:
                 description: |-
                   configuration to be executed to all Kamelets controlled by 
this IntegrationProfile
diff --git a/pkg/trait/dependencies.go b/pkg/trait/dependencies.go
index 367b0cc15..b5641a553 100644
--- a/pkg/trait/dependencies.go
+++ b/pkg/trait/dependencies.go
@@ -94,6 +94,12 @@ func (t *dependenciesTrait) Apply(e *Environment) error {
                return err
        }
 
+       if e.IntegrationProfile != nil {
+               for _, d := range e.IntegrationProfile.Spec.Dependencies {
+                       dependencies.Add(d)
+               }
+       }
+
        // Add dependencies back to integration
        dependencies.Each(func(item string) bool {
                util.StringSliceUniqueAdd(&e.Integration.Status.Dependencies, 
item)
diff --git a/pkg/trait/dependencies_test.go b/pkg/trait/dependencies_test.go
index e3d4aeeba..2cb05e1e4 100644
--- a/pkg/trait/dependencies_test.go
+++ b/pkg/trait/dependencies_test.go
@@ -345,3 +345,53 @@ func TestRestDepsQuarkus(t *testing.T) {
                },
        )
 }
+
+func TestIntegrationProfileDependency(t *testing.T) {
+       catalog, err := camel.QuarkusCatalog()
+       require.NoError(t, err)
+
+       e := &Environment{
+               Catalog:      NewEnvironmentTestCatalog(),
+               CamelCatalog: catalog,
+               Integration: &v1.Integration{
+                       Spec: v1.IntegrationSpec{
+                               Sources: []v1.SourceSpec{
+                                       {
+                                               DataSpec: v1.DataSpec{
+                                                       Name:    "flow.java",
+                                                       Content: 
`rest().route().to("log:bar");`,
+                                               },
+                                               Language: v1.LanguageJavaSource,
+                                       },
+                               },
+                       },
+                       Status: v1.IntegrationStatus{
+                               Phase: v1.IntegrationPhaseInitialization,
+                       },
+               },
+               IntegrationProfile: &v1.IntegrationProfile{
+                       Spec: v1.IntegrationProfileSpec{
+                               Dependencies: []string{
+                                       "profileDependency1", 
"profileDependency2",
+                               },
+                       },
+               },
+       }
+
+       trait := newDependenciesTrait()
+       enabled, condition, err := trait.Configure(e)
+       require.NoError(t, err)
+       assert.Nil(t, condition)
+       assert.True(t, enabled)
+
+       err = trait.Apply(e)
+       require.NoError(t, err)
+       assert.Subset(
+               t,
+               e.Integration.Status.Dependencies,
+               []string{
+                       "profileDependency1",
+                       "profileDependency2",
+               },
+       )
+}

Reply via email to