Claus Ibsen created CAMEL-26409:
-----------------------------------
Summary: camel-jbang - export puts a jkube file given with a path
under src/main/jkube/<its path>, where JKube does not find it
Key: CAMEL-26409
URL: https://issues.apache.org/jira/browse/CAMEL-26409
Project: Camel
Issue Type: Bug
Components: camel-jbang
Reporter: Claus Ibsen
Fix For: 4.24.0
_Claude Code on behalf of davsclaus_
{{camel export}} puts a {{*.jkube.yaml}} / {{*.jkube.yml}} file in
{{src/main/jkube}}, renamed to {{*.yaml}}, so that JKube picks it up as a
resource fragment. That works for a file in the current directory. A file given
with a path keeps the whole path under {{src/main/jkube}}:
{noformat}
camel export k8s/deployment.jkube.yaml route.yaml --gav=org.example:demo:1.0
--dir=demo
{noformat}
exports the fragment as {{demo/src/main/jkube/k8s/deployment.yaml}} instead of
{{demo/src/main/jkube/deployment.yaml}}. JKube reads fragments from
{{src/main/jkube}} itself, and a subdirectory there is an environment
directory, used only when {{jkube.environment}} names it. So the fragment is
silently ignored. The other kinds of files (resources, TLS, scripts) are copied
by their file name.
The cause is in {{ExportBaseCommand}} (main), in the loop that copies the files:
{code:java}
} else if (jkube) {
// file should be renamed and moved into src/main/jkube
f = f.replace(".jkube.yaml", ".yaml");
f = f.replace(".jkube.yml", ".yml");
out = srcCamelResourcesDir.getParent().getParent().resolve("jkube/" + f);
{code}
{{f}} is the path as given, not the file name. With an absolute path the
fragment lands under {{src/main/jkube/<absolute path>}}, and with {{../}} the
file is written outside {{src/main/jkube}}, in {{src/main/...}} of the exported
project.
The fix is to resolve the renamed file name ({{source.getFileName()}}), as the
other branches do. Two fragments with the same name in different directories
would then overwrite each other, as they do for resources today.
The run/export golden tests of CAMEL-24727 (PR #28696) record today's
behaviour: {{golden/expected/mixed.export.txt}} lists
{{src/main/jkube/src/test/resources/golden/mixed/deployment.yaml}}. That
expected file changes with the fix.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)