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

squakez 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 1183a5868 Fix #6830: add the delegate component of master endpoints to 
the dependencies
1183a5868 is described below

commit 1183a58681c5faf41abb73f21c4321fc9464219e
Author: harshilv17 <[email protected]>
AuthorDate: Thu Sep 24 09:01:14 2026 +0530

    Fix #6830: add the delegate component of master endpoints to the 
dependencies
---
 e2e/common/traits/master_test.go              |  3 ---
 pkg/util/source/inspector.go                  |  9 ++++++++
 pkg/util/source/inspector_java_source_test.go | 30 +++++++++++++++++++++++++++
 pkg/util/source/inspector_xml_test.go         | 16 ++++++++++++++
 pkg/util/source/inspector_yaml_test.go        | 16 ++++++++++++++
 5 files changed, 71 insertions(+), 3 deletions(-)

diff --git a/e2e/common/traits/master_test.go b/e2e/common/traits/master_test.go
index 6c7947703..290f2e129 100644
--- a/e2e/common/traits/master_test.go
+++ b/e2e/common/traits/master_test.go
@@ -49,7 +49,6 @@ func TestMasterTrait(t *testing.T) {
                        // Run using Quarkus properties instead of deprecated 
trait
                        g.Expect(KamelRun(t, ctx, ns, "files/Master.java",
                                "-d", "camel:kubernetes",
-                               "-d", "camel:timer",
                                "-d", 
"mvn:org.apache.camel.quarkus:camel-quarkus-kubernetes-cluster-service",
                                "-p", 
fmt.Sprintf("quarkus.camel.cluster.kubernetes.resource-name=%s-lock", name),
                                "-p", 
fmt.Sprintf("quarkus.camel.cluster.kubernetes.labels.\"camel.apache.org/integration\"=%s",
 name),
@@ -69,7 +68,6 @@ func TestMasterTrait(t *testing.T) {
 
                        g.Expect(KamelRun(t, ctx, ns, "files/Master.java", 
"--name", nameFirst,
                                "-d", "camel:kubernetes",
-                               "-d", "camel:timer",
                                "-d", 
"mvn:org.apache.camel.quarkus:camel-quarkus-kubernetes-cluster-service",
                                "--label", "leader-group=same",
                                "-t", "owner.target-labels=leader-group",
@@ -81,7 +79,6 @@ func TestMasterTrait(t *testing.T) {
 
                        g.Expect(KamelRun(t, ctx, ns, "files/Master.java", 
"--name", nameSecond,
                                "-d", "camel:kubernetes",
-                               "-d", "camel:timer",
                                "-d", 
"mvn:org.apache.camel.quarkus:camel-quarkus-kubernetes-cluster-service",
                                "--label", "leader-group=same",
                                "-t", "owner.target-labels=leader-group",
diff --git a/pkg/util/source/inspector.go b/pkg/util/source/inspector.go
index d99864a7d..5212f6bfe 100644
--- a/pkg/util/source/inspector.go
+++ b/pkg/util/source/inspector.go
@@ -400,6 +400,15 @@ func (i *baseInspector) addDependenciesFromURI(uri string, 
scheme *v1.CamelSchem
                meta.AddDependency(df.GetDependencyID())
        }
 
+       if scheme.ID == "master" {
+               // master:namespace:delegateUri[?options]
+               // The delegate endpoint is the one that consumes, so it needs 
its own dependencies.
+               // The master component is consumer only.
+               if parts := strings.SplitN(uri, ":", 3); len(parts) == 3 {
+                       return i.addDependencies(parts[2], meta, true)
+               }
+       }
+
        return nil
 }
 
diff --git a/pkg/util/source/inspector_java_source_test.go 
b/pkg/util/source/inspector_java_source_test.go
index 24f7241b4..8440483b2 100644
--- a/pkg/util/source/inspector_java_source_test.go
+++ b/pkg/util/source/inspector_java_source_test.go
@@ -154,6 +154,36 @@ func TestJavaSourceDataFormat(t *testing.T) {
        }
 }
 
+func TestJavaSourceMasterDelegate(t *testing.T) {
+       tc := []struct {
+               source string
+               deps   []string
+       }{
+               {
+                       source: 
`from("master:lock:timer:tick").to("log:info");`,
+                       deps:   []string{"camel:master", "camel:timer", 
"camel:log"},
+               },
+               {
+                       source: 
`from("master:lock:timer:tick?period=1000").to("log:info");`,
+                       deps:   []string{"camel:master", "camel:timer", 
"camel:log"},
+               },
+               {
+                       source: 
`from("master:lock:{{delegate}}").to("log:info");`,
+                       deps:   []string{"camel:master", "camel:log"},
+               },
+       }
+
+       inspector := newTestJavaSourceInspector(t)
+       for i := range tc {
+               test := tc[i]
+               t.Run(fmt.Sprintf("TestJavaSourceMasterDelegate-%d", i), func(t 
*testing.T) {
+                       assertExtract(t, inspector, test.source, func(meta 
*Metadata) {
+                               assert.ElementsMatch(t, test.deps, 
meta.Dependencies.List())
+                       })
+               })
+       }
+}
+
 func TestJavaReplaceURI(t *testing.T) {
        inspector := newTestJavaSourceInspector(t)
 
diff --git a/pkg/util/source/inspector_xml_test.go 
b/pkg/util/source/inspector_xml_test.go
index 182228851..fec08a53c 100644
--- a/pkg/util/source/inspector_xml_test.go
+++ b/pkg/util/source/inspector_xml_test.go
@@ -232,6 +232,22 @@ func TestXMLDataFormat(t *testing.T) {
        }
 }
 
+const xmlMasterEndpoint = `
+<camelContext xmlns="http://camel.apache.org/schema/spring";>
+  <route>
+    <from uri="master:lock:timer:tick"/>
+    <to uri="log:info"/>
+  </route>
+</camelContext>
+`
+
+func TestXMLMasterDelegate(t *testing.T) {
+       inspector := newTestXMLInspector(t)
+       assertExtract(t, inspector, xmlMasterEndpoint, func(meta *Metadata) {
+               assert.ElementsMatch(t, []string{"camel:master", "camel:timer", 
"camel:log"}, meta.Dependencies.List())
+       })
+}
+
 func TestXMLReplaceURI(t *testing.T) {
        inspector := newTestXMLInspector(t)
 
diff --git a/pkg/util/source/inspector_yaml_test.go 
b/pkg/util/source/inspector_yaml_test.go
index eff3e1d16..c189b9625 100644
--- a/pkg/util/source/inspector_yaml_test.go
+++ b/pkg/util/source/inspector_yaml_test.go
@@ -408,6 +408,22 @@ func TestYAMLDataFormat(t *testing.T) {
        }
 }
 
+const yamlMasterEndpoint = `
+- from:
+    uri: master:lock:timer:tick
+    parameters:
+      period: 1000
+    steps:
+    - to: log:info
+`
+
+func TestYAMLMasterDelegate(t *testing.T) {
+       inspector := newTestYAMLInspector(t)
+       assertExtract(t, inspector, yamlMasterEndpoint, func(meta *Metadata) {
+               assert.ElementsMatch(t, []string{"camel:master", "camel:timer", 
"camel:log"}, meta.Dependencies.List())
+       })
+}
+
 const yamlKameletEipNoID = `
 - from:
     uri: timer:tick

Reply via email to