This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch vault
in repository https://gitbox.apache.org/repos/asf/camel.git

commit e310f812b3e52c62af9ec9bf4b20456fbf233438
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Sat Feb 19 08:41:18 2022 +0100

    CAMEL-17644: camel-core - Add VaultConfiguration SPI
---
 .../camel-main-configuration-metadata.json         |  6 +-
 core/camel-main/src/main/docs/main.adoc            | 11 ++++
 .../java/org/apache/camel/main/MainVaultTest.java  | 75 ++++++++++++++++++++++
 .../maven/packaging/PrepareCamelMainMojo.java      | 14 ++++
 4 files changed, 105 insertions(+), 1 deletion(-)

diff --git 
a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
 
b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
index a3fef16..5404d48 100644
--- 
a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
+++ 
b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
@@ -4,6 +4,7 @@
     { "name": "camel.threadpool", "description": "Camel Thread Pool 
configurations", "sourceType": 
"org.apache.camel.main.ThreadPoolConfigurationProperties" },
     { "name": "camel.health", "description": "Camel Health Check 
configurations", "sourceType": 
"org.apache.camel.main.HealthConfigurationProperties" },
     { "name": "camel.rest", "description": "Camel Rest-DSL configurations", 
"sourceType": "org.apache.camel.spi.RestConfiguration" },
+    { "name": "camel.vault", "description": "Camel Vault configurations", 
"sourceType": "org.apache.camel.spi.VaultConfiguration" },
     { "name": "camel.faulttolerance", "description": "Fault Tolerance EIP 
Circuit Breaker configurations", "sourceType": 
"org.apache.camel.main.FaultToleranceConfigurationProperties" },
     { "name": "camel.resilience4j", "description": "Resilience4j EIP Circuit 
Breaker configurations", "sourceType": 
"org.apache.camel.main.Resilience4jConfigurationProperties" },
     { "name": "camel.hystrix", "description": "Hystrix (deprecated) EIP 
Circuit Breaker configurations", "sourceType": 
"org.apache.camel.main.HystrixConfigurationProperties" },
@@ -227,6 +228,9 @@
     { "name": "camel.threadpool.maxQueueSize", "description": "Sets the 
default maximum number of tasks in the work queue. Use -1 or an unbounded 
queue", "sourceType": 
"org.apache.camel.main.ThreadPoolConfigurationProperties", "type": "integer", 
"javaType": "java.lang.Integer" },
     { "name": "camel.threadpool.poolSize", "description": "Sets the default 
core pool size (threads to keep minimum in pool)", "sourceType": 
"org.apache.camel.main.ThreadPoolConfigurationProperties", "type": "integer", 
"javaType": "java.lang.Integer" },
     { "name": "camel.threadpool.rejectedPolicy", "description": "Sets the 
default handler for tasks which cannot be executed by the thread pool.", 
"sourceType": "org.apache.camel.main.ThreadPoolConfigurationProperties", 
"type": "object", "javaType": 
"org.apache.camel.util.concurrent.ThreadPoolRejectedPolicy", "enum": [ "Abort", 
"CallerRuns", "DiscardOldest", "Discard" ] },
-    { "name": "camel.threadpool.timeUnit", "description": "Sets the default 
time unit used for keep alive time", "sourceType": 
"org.apache.camel.main.ThreadPoolConfigurationProperties", "type": "object", 
"javaType": "java.util.concurrent.TimeUnit" }
+    { "name": "camel.threadpool.timeUnit", "description": "Sets the default 
time unit used for keep alive time", "sourceType": 
"org.apache.camel.main.ThreadPoolConfigurationProperties", "type": "object", 
"javaType": "java.util.concurrent.TimeUnit" },
+    { "name": "camel.vault.awsAccessKey", "description": "The AWS access key", 
"sourceType": "org.apache.camel.spi.VaultConfiguration", "type": "string", 
"javaType": "java.lang.String" },
+    { "name": "camel.vault.awsRegion", "description": "The AWS region", 
"sourceType": "org.apache.camel.spi.VaultConfiguration", "type": "string", 
"javaType": "java.lang.String" },
+    { "name": "camel.vault.awsSecretKey", "description": "The AWS secret key", 
"sourceType": "org.apache.camel.spi.VaultConfiguration", "type": "string", 
"javaType": "java.lang.String" }
   ]
 }
diff --git a/core/camel-main/src/main/docs/main.adoc 
b/core/camel-main/src/main/docs/main.adoc
index a29a394..8621ec1 100644
--- a/core/camel-main/src/main/docs/main.adoc
+++ b/core/camel-main/src/main/docs/main.adoc
@@ -200,6 +200,17 @@ The camel.rest supports 28 options, which are listed below.
 | *camel.rest.xmlDataFormat* | Sets a custom xml data format to be used. 
Important: This option is only for setting a custom name of the data format, 
not to refer to an existing data format instance. |  | String
 |===
 
+=== Camel Vault configurations
+The camel.vault supports 3 options, which are listed below.
+
+[width="100%",cols="2,5,^1,2",options="header"]
+|===
+| Name | Description | Default | Type
+| *camel.vault.awsAccessKey* | The AWS access key |  | String
+| *camel.vault.awsRegion* | The AWS region |  | String
+| *camel.vault.awsSecretKey* | The AWS secret key |  | String
+|===
+
 === Fault Tolerance EIP Circuit Breaker configurations
 The camel.faulttolerance supports 13 options, which are listed below.
 
diff --git 
a/core/camel-main/src/test/java/org/apache/camel/main/MainVaultTest.java 
b/core/camel-main/src/test/java/org/apache/camel/main/MainVaultTest.java
new file mode 100644
index 0000000..ac7b43e
--- /dev/null
+++ b/core/camel-main/src/test/java/org/apache/camel/main/MainVaultTest.java
@@ -0,0 +1,75 @@
+/*
+ * 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.main;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.spi.VaultConfiguration;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+public class MainVaultTest {
+
+    @Test
+    public void testMain() throws Exception {
+        Main main = new Main();
+
+        main.addInitialProperty("camel.vault.awsAccessKey", "myKey");
+        main.addInitialProperty("camel.vault.awsSecretKey", "mySecret");
+        main.addInitialProperty("camel.vault.awsRegion", "myRegion");
+
+        main.start();
+
+        CamelContext context = main.getCamelContext();
+        assertNotNull(context);
+
+        VaultConfiguration cfg = context.getVaultConfiguration();
+        assertNotNull(cfg);
+
+        Assertions.assertEquals("myKey", cfg.getAwsAccessKey());
+        Assertions.assertEquals("mySecret", cfg.getAwsSecretKey());
+        Assertions.assertEquals("myRegion", cfg.getAwsRegion());
+
+        main.stop();
+    }
+
+    @Test
+    public void testMainFluent() throws Exception {
+        Main main = new Main();
+        main.configure().vault()
+                .withAwsAccessKey("myKey")
+                .withAwsSecretKey("mySecret")
+                .withAwsRegion("myRegion")
+                .end();
+
+        main.start();
+
+        CamelContext context = main.getCamelContext();
+        assertNotNull(context);
+
+        VaultConfiguration cfg = context.getVaultConfiguration();
+        assertNotNull(cfg);
+
+        Assertions.assertEquals("myKey", cfg.getAwsAccessKey());
+        Assertions.assertEquals("mySecret", cfg.getAwsSecretKey());
+        Assertions.assertEquals("myRegion", cfg.getAwsRegion());
+
+        main.stop();
+    }
+
+}
diff --git 
a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCamelMainMojo.java
 
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCamelMainMojo.java
index 5eedad6..a405f4f 100644
--- 
a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCamelMainMojo.java
+++ 
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCamelMainMojo.java
@@ -195,6 +195,8 @@ public class PrepareCamelMainMojo extends 
AbstractGeneratorMojo {
                     prefix = "camel.faulttolerance.";
                 } else if (file.getName().contains("Rest")) {
                     prefix = "camel.rest.";
+                } else if (file.getName().contains("Vault")) {
+                    prefix = "camel.vault.";
                 } else if (file.getName().contains("Health")) {
                     prefix = "camel.health.";
                 } else if (file.getName().contains("Lra")) {
@@ -225,6 +227,15 @@ public class PrepareCamelMainMojo extends 
AbstractGeneratorMojo {
         } catch (Exception e) {
             throw new MojoFailureException("Error parsing file " + restConfig 
+ " due " + e.getMessage(), e);
         }
+        // include additional vault configuration from camel-api
+        File vaultConfig = new File(camelApiDir, 
"src/main/java/org/apache/camel/spi/VaultConfiguration.java");
+        try {
+            List<MainModel.MainOptionModel> model = 
parseConfigurationSource(vaultConfig);
+            model.forEach(m -> m.setName("camel.vault." + m.getName()));
+            data.addAll(model);
+        } catch (Exception e) {
+            throw new MojoFailureException("Error parsing file " + restConfig 
+ " due " + e.getMessage(), e);
+        }
 
         // lets sort so they are always ordered (but camel.main in top)
         data.sort((o1, o2) -> {
@@ -252,6 +263,9 @@ public class PrepareCamelMainMojo extends 
AbstractGeneratorMojo {
             model.getGroups().add(
                     new MainGroupModel(
                             "camel.rest", "Camel Rest-DSL configurations", 
"org.apache.camel.spi.RestConfiguration"));
+            model.getGroups().add(
+                    new MainGroupModel(
+                            "camel.vault", "Camel Vault configurations", 
"org.apache.camel.spi.VaultConfiguration"));
             model.getGroups()
                     .add(new MainGroupModel(
                             "camel.faulttolerance", "Fault Tolerance EIP 
Circuit Breaker configurations",

Reply via email to