This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot.git
The following commit(s) were added to refs/heads/main by this push:
new 636cf3032f4 CAMEL-21639 - Camel-Hashicorp-Vault-Starter: Support
Hashicorp Cloud deployment in properties function (#1348)
636cf3032f4 is described below
commit 636cf3032f418049ef06dd7b23bbb7de6e4adced
Author: Andrea Cosentino <[email protected]>
AuthorDate: Tue Jan 21 16:37:43 2025 +0100
CAMEL-21639 - Camel-Hashicorp-Vault-Starter: Support Hashicorp Cloud
deployment in properties function (#1348)
Signed-off-by: Andrea Cosentino <[email protected]>
---
.../src/main/docs/spring-boot.json | 13 ++++++
.../vault/HashicorpVaultAutoConfiguration.java | 2 +
.../HashicorpVaultConfigurationProperties.java | 27 ++++++++++++
.../HashicorpVaultCloudConfigurationTest.java | 49 ++++++++++++++++++++++
4 files changed, 91 insertions(+)
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 14ce16f1b95..b6f4835f6b4 100644
--- a/core/camel-spring-boot/src/main/docs/spring-boot.json
+++ b/core/camel-spring-boot/src/main/docs/spring-boot.json
@@ -1891,6 +1891,13 @@
"sourceType":
"org.apache.camel.spring.boot.vault.GcpVaultConfigurationProperties",
"defaultValue": false
},
+ {
+ "name": "camel.vault.hashicorp.cloud",
+ "type": "java.lang.Boolean",
+ "description": "Determine if the Hashicorp Vault is deployed on
Hashicorp Cloud or not",
+ "sourceType":
"org.apache.camel.spring.boot.vault.HashicorpVaultConfigurationProperties",
+ "defaultValue": false
+ },
{
"name": "camel.vault.hashicorp.engine",
"type": "java.lang.String",
@@ -1903,6 +1910,12 @@
"description": "The Hashicorp Vault Host for accessing the service",
"sourceType":
"org.apache.camel.spring.boot.vault.HashicorpVaultConfigurationProperties"
},
+ {
+ "name": "camel.vault.hashicorp.namespace",
+ "type": "java.lang.String",
+ "description": "If the Hashicorp Vault instance is deployed on Hashicorp
Cloud, this field will determine the namespace",
+ "sourceType":
"org.apache.camel.spring.boot.vault.HashicorpVaultConfigurationProperties"
+ },
{
"name": "camel.vault.hashicorp.port",
"type": "java.lang.String",
diff --git
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/HashicorpVaultAutoConfiguration.java
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/HashicorpVaultAutoConfiguration.java
index e3c723bb6e4..2daf4a43447 100644
---
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/HashicorpVaultAutoConfiguration.java
+++
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/HashicorpVaultAutoConfiguration.java
@@ -37,6 +37,8 @@ public class HashicorpVaultAutoConfiguration {
answer.setHost(config.getHost());
answer.setPort(config.getPort());
answer.setScheme(config.getScheme());
+ answer.setCloud(config.isCloud());
+ answer.setNamespace(config.getNamespace());
return answer;
}
diff --git
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/HashicorpVaultConfigurationProperties.java
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/HashicorpVaultConfigurationProperties.java
index 08e61edfc67..8dec145df13 100644
---
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/HashicorpVaultConfigurationProperties.java
+++
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/HashicorpVaultConfigurationProperties.java
@@ -16,6 +16,7 @@
*/
package org.apache.camel.spring.boot.vault;
+import org.apache.camel.spi.Metadata;
import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties(prefix = "camel.vault.hashicorp")
@@ -46,6 +47,16 @@ public class HashicorpVaultConfigurationProperties {
*/
private String scheme;
+ /**
+ * Determine if the Hashicorp Vault is deployed on Hashicorp Cloud or not
+ */
+ private boolean cloud;
+
+ /**
+ * If the Hashicorp Vault instance is deployed on Hashicorp Cloud, this
field will determine the namespace
+ */
+ private String namespace;
+
public String getToken() {
return token;
}
@@ -85,4 +96,20 @@ public class HashicorpVaultConfigurationProperties {
public void setScheme(String scheme) {
this.scheme = scheme;
}
+
+ public boolean isCloud() {
+ return cloud;
+ }
+
+ public void setCloud(boolean cloud) {
+ this.cloud = cloud;
+ }
+
+ public String getNamespace() {
+ return namespace;
+ }
+
+ public void setNamespace(String namespace) {
+ this.namespace = namespace;
+ }
}
diff --git
a/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/vault/HashicorpVaultCloudConfigurationTest.java
b/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/vault/HashicorpVaultCloudConfigurationTest.java
new file mode 100644
index 00000000000..08bd6342723
--- /dev/null
+++
b/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/vault/HashicorpVaultCloudConfigurationTest.java
@@ -0,0 +1,49 @@
+/*
+ * 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 = { HashicorpVaultCloudConfigurationTest.class },
properties = {
+ "camel.vault.hashicorp.token=myToken",
+ "camel.vault.hashicorp.host=myHost",
"camel.vault.hashicorp.port=myPort",
+ "camel.vault.hashicorp.scheme=myScheme",
"camel.vault.hashicorp.cloud=true",
"camel.vault.hashicorp.namespace=namespace"})
+public class HashicorpVaultCloudConfigurationTest {
+
+ @Autowired
+ private CamelContext camelContext;
+
+ @Test
+ public void testAwsVault() throws Exception {
+ Assertions.assertEquals("myToken",
camelContext.getVaultConfiguration().hashicorp().getToken());
+ Assertions.assertEquals("myHost",
camelContext.getVaultConfiguration().hashicorp().getHost());
+ Assertions.assertEquals("myPort",
camelContext.getVaultConfiguration().hashicorp().getPort());
+ Assertions.assertEquals("myScheme",
camelContext.getVaultConfiguration().hashicorp().getScheme());
+
Assertions.assertTrue(camelContext.getVaultConfiguration().hashicorp().isCloud());
+ Assertions.assertEquals("namespace",
camelContext.getVaultConfiguration().hashicorp().getNamespace());
+ }
+}