Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ private void replacePlaceholders() throws Exception {

public abstract Integer doCall() throws Exception;

protected static String getScheme(String name) {
int pos = name.indexOf(":");
if (pos != -1) {
return name.substring(0, pos);
}
return null;
}

public Path getStatusFile(String pid) {
return CommandLineHelper.getCamelDir().resolve(pid + "-status.json");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,12 @@ protected Integer export() throws Exception {
// special if user type: camel run . or camel run dirName
if (files != null && files.size() == 1) {
String name = FileUtil.stripTrailingSeparator(files.get(0));
Path first = Path.of(name);
if (Files.isDirectory(first)) {
exportBaseDir = first;
RunHelper.dirToFiles(name, files);
if (getScheme(name) == null) {
Path first = Path.of(name);
if (Files.isDirectory(first)) {
exportBaseDir = first;
RunHelper.dirToFiles(name, files);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,12 @@ protected Integer doExport() throws Exception {
// special if user type: camel run . or camel run dirName
if (files != null && files.size() == 1) {
String name = FileUtil.stripTrailingSeparator(files.get(0));
Path first = Path.of(name);
if (Files.isDirectory(first)) {
baseDir = first;
RunHelper.dirToFiles(name, files);
if (getScheme(name) == null) {
Path first = Path.of(name);
if (Files.isDirectory(first)) {
baseDir = first;
RunHelper.dirToFiles(name, files);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,14 +351,6 @@ protected static String mavenRepositoriesAsPomXml(String repos) {

protected abstract Integer export() throws Exception;

protected static String getScheme(String name) {
int pos = name.indexOf(":");
if (pos != -1) {
return name.substring(0, pos);
}
return null;
}

protected Integer runSilently(boolean ignoreLoadingError, boolean lazyBean, boolean verbose) throws Exception {
Run run = new Run(getMain());
// need to declare the profile to use for run
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,10 +479,12 @@ private int run() throws Exception {
// special if user type: camel run . or camel run dirName
if (sourceDir == null && files != null && files.size() == 1) {
String name = FileUtil.stripTrailingSeparator(files.get(0));
Path first = Path.of(name);
if (Files.isDirectory(first)) {
baseDir = first;
RunHelper.dirToFiles(name, files);
if (getScheme(name) == null) {
Path first = Path.of(name);
if (Files.isDirectory(first)) {
baseDir = first;
RunHelper.dirToFiles(name, files);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,27 +108,24 @@ void testJsonOutput(String testPomXmlFile, String jsonOutput) throws Exception {

private static class TestArguments {
static final String QUARKUS_POM = "pom-xml-files/quarkus-pom.xml";
static final String QUARKUS_POM_OUTPUT = """
Runtime: quarkus
Camel Version: 4.11.0
Camel Quarkus Version: 3.23.0
Quarkus Version: 3.23.0""";
static final String QUARKUS_POM_OUTPUT = "Runtime: quarkus" + System.lineSeparator() +
"Camel Version: 4.11.0" + System.lineSeparator() +
"Camel Quarkus Version: 3.23.0" + System.lineSeparator() +
"Quarkus Version: 3.23.0";
static final String QUARKUS_POM_JSON_OUTPUT
= "{\"runtime\":\"quarkus\",\"camelVersion\":\"4.11.0\",\"camelQuarkusVersion\":\"3.23.0\",\"quarkusVersion\":\"3.23.0\",\"quarkusBomGroupId\":\"io.quarkus.platform\",\"quarkusBomArtifactId\":\"quarkus-bom\",\"camelQuarkusBomGroupId\":\"io.quarkus.platform\",\"camelQuarkusBomArtifactId\":\"quarkus-camel-bom\"}";

static final String SPRING_BOOT_POM = "pom-xml-files/springboot-pom.xml";
static final String SPRING_BOOT_POM_OUTPUT = """
Runtime: spring-boot
Camel Version: 4.14.0
Camel Spring Boot Version: 4.14.0
Spring Boot Version: 3.5.3""";
static final String SPRING_BOOT_POM_OUTPUT = "Runtime: spring-boot" + System.lineSeparator() +
"Camel Version: 4.14.0" + System.lineSeparator() +
"Camel Spring Boot Version: 4.14.0" + System.lineSeparator() +
"Spring Boot Version: 3.5.3";
static final String SPRING_BOOT_POM_JSON_OUTPUT
= "{\"runtime\":\"spring-boot\",\"camelVersion\":\"4.14.0\",\"camelSpringBootVersion\":\"4.14.0\",\"springBootVersion\":\"3.5.3\",\"camelSpringBootBomGroupId\":\"org.apache.camel.springboot\",\"camelSpringBootBomArtifactId\":\"camel-spring-boot-bom\"}";

static final String MAIN_POM = "pom-xml-files/main-pom.xml";
static final String MAIN_POM_OUTPUT = """
Runtime: main
Camel Version: 4.14.0""";
static final String MAIN_POM_OUTPUT = "Runtime: main" + System.lineSeparator() +
"Camel Version: 4.14.0";
static final String MAIN_POM_JSON_OUTPUT
= "{\"runtime\":\"main\",\"camelVersion\":\"4.14.0\"}";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,12 @@ public Integer export() throws Exception {
// special if user type: camel run . or camel run dirName
if (files != null && files.size() == 1) {
String name = FileUtil.stripTrailingSeparator(files.get(0));
Path first = Path.of(name);
if (Files.isDirectory(first)) {
exportBaseDir = first;
RunHelper.dirToFiles(name, files);
if (getScheme(name) == null) {
Path first = Path.of(name);
if (Files.isDirectory(first)) {
exportBaseDir = first;
RunHelper.dirToFiles(name, files);
}
}
}
if (exportBaseDir == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,12 @@ public Integer doCall() throws Exception {
Path baseDir = Path.of(".");
if (files.size() == 1) {
String name = FileUtil.stripTrailingSeparator(files.get(0));
Path first = Path.of(name);
if (Files.isDirectory(first)) {
baseDir = first;
RunHelper.dirToFiles(name, files);
if (getScheme(name) == null) {
Path first = Path.of(name);
if (Files.isDirectory(first)) {
baseDir = first;
RunHelper.dirToFiles(name, files);
}
}
}
// merge the properties from files
Expand Down Expand Up @@ -423,7 +425,7 @@ public Integer doCall() throws Exception {
}

private String getIndexedWorkingDir(String projectName) {
var workingDir = RUN_PLATFORM_DIR + "/" + projectName;
var workingDir = RUN_PLATFORM_DIR + File.separator + projectName;
if (devModeReloadCount > 0) {
workingDir += "-%03d".formatted(devModeReloadCount);
}
Expand Down Expand Up @@ -654,7 +656,7 @@ private Integer buildProjectOutput(String workingDir) throws IOException, Interr
args.add("--quiet");
}
args.add("--file");
args.add(workingDir);
args.add(new File(workingDir, "pom.xml").getAbsolutePath());

if (!ObjectHelper.isEmpty(namespace)) {
args.add("-Djkube.namespace=%s".formatted(namespace));
Expand Down Expand Up @@ -717,7 +719,7 @@ private Integer deployProject(String workingDir, boolean reload) throws Exceptio
// suppress maven transfer progress
args.add("-ntp");
args.add("--file");
args.add(workingDir);
args.add(new File(workingDir, "pom.xml").getAbsolutePath());

if (!imageBuild) {
args.add("-Djkube.skip.build=true");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -601,11 +601,13 @@ public void shouldAddVolumes(RuntimeType rt) throws Exception {
Assertions.assertEquals("pvc-foo",
deployment.getSpec().getTemplate().getSpec().getContainers().get(0).getVolumeMounts().get(0).getName());
Assertions.assertEquals("/container/path/foo",
deployment.getSpec().getTemplate().getSpec().getContainers().get(0).getVolumeMounts().get(0).getMountPath());
deployment.getSpec().getTemplate().getSpec().getContainers().get(0).getVolumeMounts().get(0).getMountPath()
.replace('\\', '/'));
Assertions.assertEquals("pvc-bar",
deployment.getSpec().getTemplate().getSpec().getContainers().get(0).getVolumeMounts().get(1).getName());
Assertions.assertEquals("/container/path/bar",
deployment.getSpec().getTemplate().getSpec().getContainers().get(0).getVolumeMounts().get(1).getMountPath());
deployment.getSpec().getTemplate().getSpec().getContainers().get(0).getVolumeMounts().get(1).getMountPath()
.replace('\\', '/'));
Assertions.assertEquals(2, deployment.getSpec().getTemplate().getSpec().getVolumes().size());
Assertions.assertEquals("pvc-foo", deployment.getSpec().getTemplate().getSpec().getVolumes().get(0).getName());
Assertions.assertEquals("pvc-foo",
Expand Down Expand Up @@ -691,27 +693,30 @@ public void shouldAddConfigs() throws Exception {
Assertions.assertEquals(5, volumeMounts.size());
// secret:foo
Assertions.assertEquals("foo", volumeMounts.get(0).getName());
Assertions.assertEquals("/etc/camel/conf.d/_secrets/foo", volumeMounts.get(0).getMountPath());
Assertions.assertEquals("/etc/camel/conf.d/_secrets/foo", volumeMounts.get(0).getMountPath().replace('\\', '/'));
Assertions.assertTrue(volumeMounts.get(0).getReadOnly());
// secret:foo/key-foo
Assertions.assertEquals("foo", volumeMounts.get(1).getName());
Assertions.assertEquals("/etc/camel/conf.d/_secrets/foo/key-foo", volumeMounts.get(1).getMountPath());
Assertions.assertEquals("/etc/camel/conf.d/_secrets/foo/key-foo",
volumeMounts.get(1).getMountPath().replace('\\', '/'));
Assertions.assertTrue(volumeMounts.get(1).getReadOnly());
Assertions.assertEquals("key-foo", volumes.get(1).getSecret().getItems().get(0).getKey());
Assertions.assertEquals("key-foo", volumes.get(1).getSecret().getItems().get(0).getPath());
// configmap:bar
Assertions.assertEquals("bar", volumeMounts.get(2).getName());
Assertions.assertEquals("/etc/camel/conf.d/_configmaps/bar", volumeMounts.get(2).getMountPath());
Assertions.assertEquals("/etc/camel/conf.d/_configmaps/bar", volumeMounts.get(2).getMountPath().replace('\\', '/'));
Assertions.assertTrue(volumeMounts.get(2).getReadOnly());
// configmap:bar/key-bar
Assertions.assertEquals("bar", volumeMounts.get(3).getName());
Assertions.assertEquals("/etc/camel/conf.d/_configmaps/bar/key-bar", volumeMounts.get(3).getMountPath());
Assertions.assertEquals("/etc/camel/conf.d/_configmaps/bar/key-bar",
volumeMounts.get(3).getMountPath().replace('\\', '/'));
Assertions.assertTrue(volumeMounts.get(3).getReadOnly());
Assertions.assertEquals("key-bar", volumes.get(3).getConfigMap().getItems().get(0).getKey());
Assertions.assertEquals("key-bar", volumes.get(3).getConfigMap().getItems().get(0).getPath());
// configmap:bar2/my.properties
Assertions.assertEquals("bar2", volumeMounts.get(4).getName());
Assertions.assertEquals("/etc/camel/conf.d/_configmaps/bar2/my.properties", volumeMounts.get(4).getMountPath());
Assertions.assertEquals("/etc/camel/conf.d/_configmaps/bar2/my.properties",
volumeMounts.get(4).getMountPath().replace('\\', '/'));
Assertions.assertEquals("my.properties", volumes.get(4).getConfigMap().getItems().get(0).getKey());
Assertions.assertEquals("my.properties", volumes.get(4).getConfigMap().getItems().get(0).getPath());
}
Expand All @@ -734,30 +739,33 @@ public void shouldAddResources() throws Exception {
Assertions.assertEquals(6, volumeMounts.size());
// secret:foo
Assertions.assertEquals("foo", volumeMounts.get(0).getName());
Assertions.assertEquals("/etc/camel/resources.d/_secrets/foo", volumeMounts.get(0).getMountPath());
Assertions.assertEquals("/etc/camel/resources.d/_secrets/foo", volumeMounts.get(0).getMountPath().replace('\\', '/'));
Assertions.assertTrue(volumeMounts.get(0).getReadOnly());
// secret:foo/key-foo
Assertions.assertEquals("foo", volumeMounts.get(1).getName());
Assertions.assertEquals("/etc/camel/resources.d/_secrets/foo/key-foo", volumeMounts.get(1).getMountPath());
Assertions.assertEquals("/etc/camel/resources.d/_secrets/foo/key-foo",
volumeMounts.get(1).getMountPath().replace('\\', '/'));
Assertions.assertEquals("key-foo", volumes.get(1).getSecret().getItems().get(0).getKey());
Assertions.assertEquals("key-foo", volumes.get(1).getSecret().getItems().get(0).getPath());
// secret:foo/key-foo@/etc/foodir/my-file.txt
Assertions.assertEquals("foo", volumeMounts.get(2).getName());
Assertions.assertEquals("/etc/foodir/my-file.txt", volumeMounts.get(2).getMountPath());
Assertions.assertEquals("/etc/foodir/my-file.txt", volumeMounts.get(2).getMountPath().replace('\\', '/'));
Assertions.assertEquals("my-file.txt", volumeMounts.get(2).getSubPath());
Assertions.assertEquals("key-foo", volumes.get(2).getSecret().getItems().get(0).getKey());
Assertions.assertEquals("my-file.txt", volumes.get(2).getSecret().getItems().get(0).getPath());
// configmap:bar
Assertions.assertEquals("bar", volumeMounts.get(3).getName());
Assertions.assertEquals("/etc/camel/resources.d/_configmaps/bar", volumeMounts.get(3).getMountPath());
Assertions.assertEquals("/etc/camel/resources.d/_configmaps/bar",
volumeMounts.get(3).getMountPath().replace('\\', '/'));
// configmap:bar/key-bar
Assertions.assertEquals("bar", volumeMounts.get(4).getName());
Assertions.assertEquals("/etc/camel/resources.d/_configmaps/bar/key-bar", volumeMounts.get(4).getMountPath());
Assertions.assertEquals("/etc/camel/resources.d/_configmaps/bar/key-bar",
volumeMounts.get(4).getMountPath().replace('\\', '/'));
Assertions.assertEquals("key-bar", volumes.get(4).getConfigMap().getItems().get(0).getKey());
Assertions.assertEquals("key-bar", volumes.get(4).getConfigMap().getItems().get(0).getPath());
// configmap:bar2/my.properties@/var/dir1/bar.bin
Assertions.assertEquals("bar2", volumeMounts.get(5).getName());
Assertions.assertEquals("/var/dir1/bar.bin", volumeMounts.get(5).getMountPath());
Assertions.assertEquals("/var/dir1/bar.bin", volumeMounts.get(5).getMountPath().replace('\\', '/'));
Assertions.assertEquals("bar.bin", volumeMounts.get(5).getSubPath());
Assertions.assertEquals("my.properties", volumes.get(5).getConfigMap().getItems().get(0).getKey());
Assertions.assertEquals("bar.bin", volumes.get(5).getConfigMap().getItems().get(0).getPath());
Expand All @@ -777,19 +785,21 @@ public void shouldAddConfigAndResources() throws Exception {

// config configmap:bar1a/my.key1
Assertions.assertEquals("bar1a", volumeMounts.get(0).getName());
Assertions.assertEquals("/etc/camel/conf.d/_configmaps/bar1a/my.key1", volumeMounts.get(0).getMountPath());
Assertions.assertEquals("/etc/camel/conf.d/_configmaps/bar1a/my.key1",
volumeMounts.get(0).getMountPath().replace('\\', '/'));
Assertions.assertEquals("my.key1", volumeMounts.get(0).getSubPath());
Assertions.assertEquals("my.key1", volumes.get(0).getConfigMap().getItems().get(0).getKey());
Assertions.assertEquals("my.key1", volumes.get(0).getConfigMap().getItems().get(0).getPath());
// resources configmap:bar2/key-bar2
Assertions.assertEquals("bar2", volumeMounts.get(1).getName());
Assertions.assertEquals("/etc/camel/resources.d/_configmaps/bar2/key-bar2", volumeMounts.get(1).getMountPath());
Assertions.assertEquals("/etc/camel/resources.d/_configmaps/bar2/key-bar2",
volumeMounts.get(1).getMountPath().replace('\\', '/'));
Assertions.assertEquals("key-bar2", volumeMounts.get(1).getSubPath());
Assertions.assertEquals("key-bar2", volumes.get(1).getConfigMap().getItems().get(0).getKey());
Assertions.assertEquals("key-bar2", volumes.get(1).getConfigMap().getItems().get(0).getPath());
// resources configmap:bar2a/my.key2@/var/dir2/bar.bin
Assertions.assertEquals("bar2a", volumeMounts.get(2).getName());
Assertions.assertEquals("/var/dir2/bar.bin", volumeMounts.get(2).getMountPath());
Assertions.assertEquals("/var/dir2/bar.bin", volumeMounts.get(2).getMountPath().replace('\\', '/'));
Assertions.assertEquals("bar.bin", volumeMounts.get(2).getSubPath());
Assertions.assertEquals("my.key2", volumes.get(2).getConfigMap().getItems().get(0).getKey());
Assertions.assertEquals("bar.bin", volumes.get(2).getConfigMap().getItems().get(0).getPath());
Expand All @@ -812,7 +822,8 @@ public void shouldAddOpenApis(RuntimeType rt) throws Exception {
Assertions.assertEquals("openapi",
deployment.getSpec().getTemplate().getSpec().getContainers().get(0).getVolumeMounts().get(0).getName());
Assertions.assertEquals("/etc/camel/resources.d/_configmaps/openapi/spec.yaml",
deployment.getSpec().getTemplate().getSpec().getContainers().get(0).getVolumeMounts().get(0).getMountPath());
deployment.getSpec().getTemplate().getSpec().getContainers().get(0).getVolumeMounts().get(0).getMountPath()
.replace('\\', '/'));
Assertions.assertEquals("spec.yaml",
deployment.getSpec().getTemplate().getSpec().getContainers().get(0).getVolumeMounts().get(0).getSubPath());
}
Expand Down