You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2024/09/04 07:03:40 UTC
(camel-spring-boot) 01/01: CAMEL-21167 - Camel-Spring-Boot: Kubernetes Secrets Trigger context reloading on update support
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch CAMEL-21167
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot.git
commit 5226f3e4500948294fc50e59232831566de87690
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Sep 4 09:01:54 2024 +0200
CAMEL-21167 - Camel-Spring-Boot: Kubernetes Secrets Trigger context reloading on update support
Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
.../src/main/docs/spring-boot.json | 18 ++++++++
.../vault/KubernetesVaultAutoConfiguration.java | 41 +++++++++++++++++
.../KubernetesVaultConfigurationProperties.java | 51 ++++++++++++++++++++++
...rk.boot.autoconfigure.AutoConfiguration.imports | 1 +
.../vault/KubernetesVaultConfigurationTest.java | 43 ++++++++++++++++++
tooling/camel-spring-boot-dependencies/pom.xml | 5 ---
6 files changed, 154 insertions(+), 5 deletions(-)
diff --git a/core/camel-spring-boot/src/main/docs/spring-boot.json b/core/camel-spring-boot/src/main/docs/spring-boot.json
index 49d5fa990f1..9a87ba22734 100644
--- a/core/camel-spring-boot/src/main/docs/spring-boot.json
+++ b/core/camel-spring-boot/src/main/docs/spring-boot.json
@@ -156,6 +156,11 @@
"type": "org.apache.camel.spring.boot.vault.HashicorpVaultConfigurationProperties",
"sourceType": "org.apache.camel.spring.boot.vault.HashicorpVaultConfigurationProperties"
},
+ {
+ "name": "camel.vault.kubernetes",
+ "type": "org.apache.camel.spring.boot.vault.KubernetesVaultConfigurationProperties",
+ "sourceType": "org.apache.camel.spring.boot.vault.KubernetesVaultConfigurationProperties"
+ },
{
"name": "management.endpoint.camel",
"type": "org.apache.camel.spring.boot.actuate.console.CamelDevConsoleEndpoint",
@@ -1841,6 +1846,19 @@
"description": "The Hashicorp Vault Token for accessing the service",
"sourceType": "org.apache.camel.spring.boot.vault.HashicorpVaultConfigurationProperties"
},
+ {
+ "name": "camel.vault.kubernetes.refresh-enabled",
+ "type": "java.lang.Boolean",
+ "description": "Define if we want to refresh the secrets on update",
+ "sourceType": "org.apache.camel.spring.boot.vault.KubernetesVaultConfigurationProperties",
+ "defaultValue": false
+ },
+ {
+ "name": "camel.vault.kubernetes.secrets",
+ "type": "java.lang.String",
+ "description": "Define the secrets to look at",
+ "sourceType": "org.apache.camel.spring.boot.vault.KubernetesVaultConfigurationProperties"
+ },
{
"name": "management.endpoint.camel.cache.time-to-live",
"type": "java.time.Duration",
diff --git a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/KubernetesVaultAutoConfiguration.java b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/KubernetesVaultAutoConfiguration.java
new file mode 100644
index 00000000000..ed56c48e739
--- /dev/null
+++ b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/KubernetesVaultAutoConfiguration.java
@@ -0,0 +1,41 @@
+/*
+ * 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.spring.boot.vault;
+
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.vault.KubernetesVaultConfiguration;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration(proxyBeanMethods = false)
+@ConditionalOnBean(CamelAutoConfiguration.class)
+@EnableConfigurationProperties(KubernetesVaultConfigurationProperties.class)
+@AutoConfigureAfter(CamelAutoConfiguration.class)
+public class KubernetesVaultAutoConfiguration {
+
+ @Bean
+ public KubernetesVaultConfiguration kubernetesVaultConfiguration(KubernetesVaultConfigurationProperties config) {
+ KubernetesVaultConfiguration answer = new KubernetesVaultConfiguration();
+ answer.setRefreshEnabled(config.isRefreshEnabled());
+ answer.setSecrets(config.getSecrets());
+ return answer;
+ }
+
+}
diff --git a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/KubernetesVaultConfigurationProperties.java b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/KubernetesVaultConfigurationProperties.java
new file mode 100644
index 00000000000..19173c8504f
--- /dev/null
+++ b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/KubernetesVaultConfigurationProperties.java
@@ -0,0 +1,51 @@
+/*
+ * 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.spring.boot.vault;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+@ConfigurationProperties(prefix = "camel.vault.kubernetes")
+public class KubernetesVaultConfigurationProperties {
+
+ /**
+ * Define if we want to refresh the secrets on update
+ */
+ private boolean refreshEnabled;
+
+ /**
+ * Define the secrets to look at
+ */
+ private String secrets;
+
+
+
+ public boolean isRefreshEnabled() {
+ return refreshEnabled;
+ }
+
+ public void setRefreshEnabled(boolean refreshEnabled) {
+ this.refreshEnabled = refreshEnabled;
+ }
+
+ public String getSecrets() {
+ return secrets;
+ }
+
+ public void setSecrets(String secrets) {
+ this.secrets = secrets;
+ }
+}
diff --git a/core/camel-spring-boot/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/core/camel-spring-boot/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
index 30f28a88919..2fb21e7f846 100644
--- a/core/camel-spring-boot/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
+++ b/core/camel-spring-boot/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
@@ -39,3 +39,4 @@ org.apache.camel.spring.boot.vault.AwsVaultAutoConfiguration
org.apache.camel.spring.boot.vault.GcpVaultAutoConfiguration
org.apache.camel.spring.boot.vault.AzureVaultAutoConfiguration
org.apache.camel.spring.boot.vault.HashicorpVaultAutoConfiguration
+org.apache.camel.spring.boot.vault.KubernetesVaultAutoConfiguration
diff --git a/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/vault/KubernetesVaultConfigurationTest.java b/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/vault/KubernetesVaultConfigurationTest.java
new file mode 100644
index 00000000000..2afe3ffdd96
--- /dev/null
+++ b/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/vault/KubernetesVaultConfigurationTest.java
@@ -0,0 +1,43 @@
+/*
+ * 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.spring.boot.vault;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.annotation.DirtiesContext;
+
+@DirtiesContext
+@CamelSpringBootTest
+@EnableAutoConfiguration
+@SpringBootTest(classes = { KubernetesVaultConfigurationTest.class }, properties = {
+ "camel.vault.kubernetes.refreshEnabled=true", "camel.vault.kubernetes.secrets=supersecret" })
+public class KubernetesVaultConfigurationTest {
+
+ @Autowired
+ private CamelContext camelContext;
+
+ @Test
+ public void testKubernetesVault() throws Exception {
+ Assertions.assertEquals(true, camelContext.getVaultConfiguration().kubernetes().isRefreshEnabled());
+ Assertions.assertEquals("supersecret", camelContext.getVaultConfiguration().kubernetes().getSecrets());
+ }
+}
diff --git a/tooling/camel-spring-boot-dependencies/pom.xml b/tooling/camel-spring-boot-dependencies/pom.xml
index 1ee54989164..3ded4ff1d52 100644
--- a/tooling/camel-spring-boot-dependencies/pom.xml
+++ b/tooling/camel-spring-boot-dependencies/pom.xml
@@ -3419,11 +3419,6 @@
<artifactId>camel-langchain4j-tokenizer</artifactId>
<version>4.8.0-SNAPSHOT</version>
</dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-langchain4j-tools</artifactId>
- <version>4.8.0-SNAPSHOT</version>
- </dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-langchain4j-web-search</artifactId>