This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-4.8.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-4.8.x by this push:
new d329630ea0c CAMEL-21436: camel-jbang - Export beans with secret
function should work even if k8s is not configured
d329630ea0c is described below
commit d329630ea0c26405afb1e8638179feb1a978f8cb
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed Nov 13 19:53:59 2024 +0100
CAMEL-21436: camel-jbang - Export beans with secret function should work
even if k8s is not configured
---
.../camel/dsl/jbang/core/commands/ExportTest.java | 26 ++++++++++++++++++
.../src/test/resources/k8s-secret-bean.yaml | 31 ++++++++++++++++++++++
2 files changed, 57 insertions(+)
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ExportTest.java
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ExportTest.java
index 3832fad4648..d330036f980 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ExportTest.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ExportTest.java
@@ -308,4 +308,30 @@ class ExportTest {
return d.getGroupId() + ":" + d.getArtifactId() + ":" + d.getVersion();
}
+ @ParameterizedTest
+ @MethodSource("runtimeProvider")
+ public void shouldExportSecretBean(RuntimeType rt) throws Exception {
+ Export command = createCommand(rt,
+ new String[] { "src/test/resources/k8s-secret-bean.yaml" },
+ "--gav=examples:route:1.0.0", "--dir=" + workingDir,
"--quiet");
+ int exit = command.doCall();
+
+ Assertions.assertEquals(0, exit);
+ Model model = readMavenModel();
+ Assertions.assertEquals("examples", model.getGroupId());
+ Assertions.assertEquals("route", model.getArtifactId());
+ Assertions.assertEquals("1.0.0", model.getVersion());
+
+ if (rt == RuntimeType.main) {
+ Assertions.assertTrue(containsDependency(model.getDependencies(),
"org.apache.camel", "camel-kubernetes", null));
+ } else if (rt == RuntimeType.springBoot) {
+ Assertions.assertTrue(
+ containsDependency(model.getDependencies(),
"org.apache.camel.springboot", "camel-kubernetes-starter",
+ null));
+ } else if (rt == RuntimeType.quarkus) {
+ Assertions.assertTrue(
+ containsDependency(model.getDependencies(),
"org.apache.camel.quarkus", "camel-quarkus-kubernetes", null));
+ }
+ }
+
}
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/test/resources/k8s-secret-bean.yaml
b/dsl/camel-jbang/camel-jbang-core/src/test/resources/k8s-secret-bean.yaml
new file mode 100644
index 00000000000..8f18e2f933c
--- /dev/null
+++ b/dsl/camel-jbang/camel-jbang-core/src/test/resources/k8s-secret-bean.yaml
@@ -0,0 +1,31 @@
+#
+# 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.
+#
+
+- beans:
+ - name: DemoDatabase
+ type: "#class:org.apache.commons.dbcp2.BasicDataSource"
+ properties:
+ username: "{{secret:demo/username}}"
+ password: "{{secret:demo/password}}"
+ url: "{{secret:demo/url}}"
+ driverClassName: org.postgresql.Driver
+- from:
+ uri: timer:tick
+ steps:
+ - setBody:
+ constant: "{{secret:custom-secrets/kafka.username}}"
+ - to: log:info