feat: replace custom kubernetes properties function with those provided by camel-kubernetes
diff --git a/camel-k-core/support/pom.xml b/camel-k-core/support/pom.xml
index cd0caed..b5a046e 100644
--- a/camel-k-core/support/pom.xml
+++ b/camel-k-core/support/pom.xml
@@ -51,6 +51,10 @@
<groupId>org.apache.camel</groupId>
<artifactId>camel-endpointdsl</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-kubernetes</artifactId>
+ </dependency>
<!-- ****************************** -->
<!-- -->
@@ -63,6 +67,12 @@
<artifactId>camel-k-test</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <version>${slf4j-version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
@@ -82,6 +92,7 @@
<root>${project.basedir}</root>
<camel.k.mount-path.configmaps>${project.basedir}/src/test/resources/configmaps</camel.k.mount-path.configmaps>
<camel.k.mount-path.secrets>${project.basedir}/src/test/resources/secrets</camel.k.mount-path.secrets>
+ <camel.kubernetes-config.client-enabled>false</camel.kubernetes-config.client-enabled>
</systemPropertyVariables>
</configuration>
</plugin>
diff --git a/camel-k-core/support/src/main/java/org/apache/camel/k/listener/PropertiesConfigurer.java b/camel-k-core/support/src/main/java/org/apache/camel/k/listener/PropertiesConfigurer.java
deleted file mode 100644
index 2dadca5..0000000
--- a/camel-k-core/support/src/main/java/org/apache/camel/k/listener/PropertiesConfigurer.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * 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 org.apache.camel.k.listener;
-
-import org.apache.camel.Ordered;
-import org.apache.camel.k.Runtime;
-import org.apache.camel.k.support.Constants;
-import org.apache.camel.k.support.KubernetesPropertiesFunction;
-
-public class PropertiesConfigurer extends AbstractPhaseListener {
- public PropertiesConfigurer() {
- super(Runtime.Phase.ConfigureProperties);
- }
-
- @Override
- public int getOrder() {
- return Ordered.HIGHEST;
- }
-
- @Override
- protected void accept(Runtime runtime) {
- //
- // Register properties functions to resolve k8s secrets or config maps like:
- //
- // {{secret:name/key}}
- // {{configmap:name/key}}
- //
-
- //
- // ConfigMap
- //
- String cmPath = System.getProperty(
- Constants.PROPERTY_CAMEL_K_MOUNT_PATH_CONFIGMAPS,
- System.getenv(Constants.ENV_CAMEL_K_MOUNT_PATH_CONFIGMAPS)
- );
-
- if (cmPath != null) {
- runtime.getCamelContext().getPropertiesComponent().addPropertiesFunction(
- new KubernetesPropertiesFunction(cmPath, "configmap")
- );
- }
-
- //
- // Secret
- //
- String secretPath = System.getProperty(
- Constants.PROPERTY_CAMEL_K_MOUNT_PATH_SECRETS,
- System.getenv(Constants.ENV_CAMEL_K_MOUNT_PATH_SECRETS)
- );
-
- if (secretPath != null) {
- runtime.getCamelContext().getPropertiesComponent().addPropertiesFunction(
- new KubernetesPropertiesFunction(secretPath, "secret")
- );
- }
- }
-}
diff --git a/camel-k-core/support/src/main/java/org/apache/camel/k/support/KubernetesPropertiesFunction.java b/camel-k-core/support/src/main/java/org/apache/camel/k/support/KubernetesPropertiesFunction.java
deleted file mode 100644
index 067d5f0..0000000
--- a/camel-k-core/support/src/main/java/org/apache/camel/k/support/KubernetesPropertiesFunction.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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 org.apache.camel.k.support;
-
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Locale;
-
-import org.apache.camel.spi.PropertiesFunction;
-import org.apache.camel.util.StringHelper;
-
-public class KubernetesPropertiesFunction implements PropertiesFunction {
- private final String name;
- private final Path root;
-
- public KubernetesPropertiesFunction(String path, String name) {
- this.root = path != null ? Paths.get(path) : null;
- this.name = name;
- }
-
- @Override
- public String getName() {
- return this.name;
- }
-
- @Override
- public String apply(String remainder) {
- final String defaultValue = StringHelper.after(remainder, ":");
-
- if (this.root == null) {
- return defaultValue;
- }
-
- final String name = StringHelper.before(remainder, "/");
- final String property = StringHelper.after(remainder, "/");
-
- if (name == null || property == null) {
- return defaultValue;
- }
-
- Path file = this.root.resolve(name.toLowerCase(Locale.US)).resolve(property);
- if (Files.exists(file) && !Files.isDirectory(file)) {
- try {
- return Files.readString(file, StandardCharsets.UTF_8);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- return defaultValue;
- }
-}
diff --git a/camel-k-core/support/src/main/resources/META-INF/services/org.apache.camel.k.Runtime$Listener b/camel-k-core/support/src/main/resources/META-INF/services/org.apache.camel.k.Runtime$Listener
index f0c50b7..282d350 100644
--- a/camel-k-core/support/src/main/resources/META-INF/services/org.apache.camel.k.Runtime$Listener
+++ b/camel-k-core/support/src/main/resources/META-INF/services/org.apache.camel.k.Runtime$Listener
@@ -17,4 +17,3 @@
org.apache.camel.k.listener.ContextConfigurer
org.apache.camel.k.listener.SourcesConfigurer
-org.apache.camel.k.listener.PropertiesConfigurer
diff --git a/camel-k-core/support/src/test/java/org/apache/camel/k/listener/PropertiesFunctionsConfigurerTest.java b/camel-k-core/support/src/test/java/org/apache/camel/k/listener/PropertiesFunctionsConfigurerTest.java
index 914b01d..e4175c8 100644
--- a/camel-k-core/support/src/test/java/org/apache/camel/k/listener/PropertiesFunctionsConfigurerTest.java
+++ b/camel-k-core/support/src/test/java/org/apache/camel/k/listener/PropertiesFunctionsConfigurerTest.java
@@ -30,8 +30,6 @@
Runtime runtime = Runtime.on(new DefaultCamelContext());
runtime.setProperties("my.property", "{{secret:my-secret/my-property}}");
- new PropertiesConfigurer().accept(runtime);
-
assertThat(runtime.getCamelContext().resolvePropertyPlaceholders("{{secret:my-secret/my-property}}"))
.isEqualTo("my-secret-property");
assertThat(runtime.getCamelContext().resolvePropertyPlaceholders("{{secret:none/my-property:my-default-secret}}"))
diff --git a/camel-k-runtime/deployment/pom.xml b/camel-k-runtime/deployment/pom.xml
index 8c1c13f..0984518 100644
--- a/camel-k-runtime/deployment/pom.xml
+++ b/camel-k-runtime/deployment/pom.xml
@@ -41,6 +41,14 @@
<artifactId>camel-quarkus-bean-deployment</artifactId>
</dependency>
<dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-kubernetes-deployment</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-support-bouncycastle-deployment</artifactId>
+ </dependency>
+ <dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-logging-json-deployment</artifactId>
</dependency>
diff --git a/camel-k-runtime/runtime/pom.xml b/camel-k-runtime/runtime/pom.xml
index 70bf5e9..0df7279 100644
--- a/camel-k-runtime/runtime/pom.xml
+++ b/camel-k-runtime/runtime/pom.xml
@@ -37,6 +37,14 @@
<artifactId>camel-quarkus-bean</artifactId>
</dependency>
<dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-kubernetes</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-support-bouncycastle</artifactId>
+ </dependency>
+ <dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-logging-json</artifactId>
</dependency>
diff --git a/camel-k-runtime/runtime/src/main/java/org/apache/camel/k/quarkus/ApplicationConfigSourceProvider.java b/camel-k-runtime/runtime/src/main/java/org/apache/camel/k/quarkus/ApplicationConfigSourceProvider.java
index 77fffb2..73da198 100644
--- a/camel-k-runtime/runtime/src/main/java/org/apache/camel/k/quarkus/ApplicationConfigSourceProvider.java
+++ b/camel-k-runtime/runtime/src/main/java/org/apache/camel/k/quarkus/ApplicationConfigSourceProvider.java
@@ -16,10 +16,12 @@
*/
package org.apache.camel.k.quarkus;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import io.smallrye.config.PropertiesConfigSource;
+import org.apache.camel.component.kubernetes.properties.ConfigMapPropertiesFunction;
import org.apache.camel.k.support.RuntimeSupport;
import org.eclipse.microprofile.config.spi.ConfigSource;
import org.eclipse.microprofile.config.spi.ConfigSourceProvider;
@@ -27,10 +29,15 @@
public class ApplicationConfigSourceProvider implements ConfigSourceProvider {
@Override
public Iterable<ConfigSource> getConfigSources(ClassLoader forClassLoader) {
+ final Map<String, String> sysProperties = new HashMap<>();
+ // explicit disable looking up configmap and secret using the KubernetesClient
+ sysProperties.put(ConfigMapPropertiesFunction.CLIENT_ENABLED, "false");
+
final Map<String, String> appProperties = RuntimeSupport.loadApplicationProperties();
final Map<String, String> usrProperties = RuntimeSupport.loadUserProperties();
return List.of(
+ new PropertiesConfigSource(sysProperties, "camel-k-sys", ConfigSource.DEFAULT_ORDINAL + 1000),
new PropertiesConfigSource(appProperties, "camel-k-app", ConfigSource.DEFAULT_ORDINAL),
new PropertiesConfigSource(usrProperties, "camel-k-usr", ConfigSource.DEFAULT_ORDINAL + 1)
);
diff --git a/itests/camel-k-itests-core/pom.xml b/itests/camel-k-itests-core/pom.xml
index 1a6eb94..6916189 100644
--- a/itests/camel-k-itests-core/pom.xml
+++ b/itests/camel-k-itests-core/pom.xml
@@ -46,6 +46,11 @@
<artifactId>quarkus-resteasy-jsonb</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-support-bouncycastle</artifactId>
+ </dependency>
+
<!-- test dependencies -->
<dependency>
<groupId>io.quarkus</groupId>
diff --git a/itests/camel-k-itests-loader-js/pom.xml b/itests/camel-k-itests-loader-js/pom.xml
index 6a5c514..2c5e781 100644
--- a/itests/camel-k-itests-loader-js/pom.xml
+++ b/itests/camel-k-itests-loader-js/pom.xml
@@ -51,6 +51,11 @@
<artifactId>camel-quarkus-bean</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-support-bouncycastle</artifactId>
+ </dependency>
+
<!-- test dependencies -->
<dependency>
<groupId>io.quarkus</groupId>
diff --git a/itests/camel-k-itests-loader-polyglot/pom.xml b/itests/camel-k-itests-loader-polyglot/pom.xml
index 058dfbe..e6cd02f 100644
--- a/itests/camel-k-itests-loader-polyglot/pom.xml
+++ b/itests/camel-k-itests-loader-polyglot/pom.xml
@@ -33,6 +33,11 @@
<artifactId>camel-k-itests-loader-inspector</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-support-bouncycastle</artifactId>
+ </dependency>
+
<!-- camel quarkus -->
<dependency>
<groupId>org.apache.camel</groupId>
diff --git a/itests/camel-k-itests-loader-xml/pom.xml b/itests/camel-k-itests-loader-xml/pom.xml
index 96ca353..f373af4 100644
--- a/itests/camel-k-itests-loader-xml/pom.xml
+++ b/itests/camel-k-itests-loader-xml/pom.xml
@@ -51,6 +51,11 @@
<artifactId>camel-quarkus-bean</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-support-bouncycastle</artifactId>
+ </dependency>
+
<!-- test dependencies -->
<dependency>
<groupId>io.quarkus</groupId>
diff --git a/itests/camel-k-itests-loader-yaml/pom.xml b/itests/camel-k-itests-loader-yaml/pom.xml
index 8a9349b..9d07753 100644
--- a/itests/camel-k-itests-loader-yaml/pom.xml
+++ b/itests/camel-k-itests-loader-yaml/pom.xml
@@ -51,6 +51,11 @@
<artifactId>camel-quarkus-bean</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-support-bouncycastle</artifactId>
+ </dependency>
+
<!-- test dependencies -->
<dependency>
<groupId>io.quarkus</groupId>
diff --git a/itests/camel-k-itests-master/pom.xml b/itests/camel-k-itests-master/pom.xml
index e2cff77..256ceed 100644
--- a/itests/camel-k-itests-master/pom.xml
+++ b/itests/camel-k-itests-master/pom.xml
@@ -73,18 +73,6 @@
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.bouncycastle</groupId>
- <artifactId>bcprov-ext-jdk18on</artifactId>
- <version>${bouncycastle-version}</version>
- </dependency>
- <dependency>
- <groupId>org.bouncycastle</groupId>
- <artifactId>bcpkix-jdk18on</artifactId>
- <version>${bouncycastle-version}</version>
- </dependency>
-
-
<!-- The following dependencies guarantee that this module is built after them. -->
<dependency>
diff --git a/pom.xml b/pom.xml
index 3eea8ea..d0bfd35 100644
--- a/pom.xml
+++ b/pom.xml
@@ -675,6 +675,11 @@
<artifactId>hamcrest-core</artifactId>
<version>${hamcrest-version}</version>
</dependency>
+ <dependency>
+ <groupId>org.bouncycastle</groupId>
+ <artifactId>bcprov-ext-jdk18on</artifactId>
+ <version>${bouncycastle-version}</version>
+ </dependency>
<!-- maven -->
<dependency>
diff --git a/support/camel-k-runtime-bom/pom.xml b/support/camel-k-runtime-bom/pom.xml
index c111767..17668fb 100644
--- a/support/camel-k-runtime-bom/pom.xml
+++ b/support/camel-k-runtime-bom/pom.xml
@@ -23,6 +23,7 @@
<groupId>org.apache</groupId>
<artifactId>apache</artifactId>
<version>27</version>
+ <relativePath/>
</parent>
<modelVersion>4.0.0</modelVersion>