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 2022/03/04 07:48:46 UTC

[camel] 01/06: CAMEL-17739 - Camel Google Secret Manager Properties Source: Support the usage of client default instance

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.git

commit 2929bb7e37906fbc82c8d95f1e382081bca1de30
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Mar 3 18:52:05 2022 +0100

    CAMEL-17739 - Camel Google Secret Manager Properties Source: Support the usage of client default instance
---
 .../java/org/apache/camel/vault/GcpVaultConfiguration.java  | 13 +++++++++++++
 .../main/GcpVaultConfigurationPropertiesConfigurer.java     |  6 ++++++
 .../META-INF/camel-main-configuration-metadata.json         |  3 ++-
 core/camel-main/src/main/docs/main.adoc                     |  3 ++-
 .../apache/camel/main/GcpVaultConfigurationProperties.java  |  8 ++++++++
 .../src/test/java/org/apache/camel/main/MainVaultTest.java  |  4 ++--
 6 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/core/camel-api/src/main/java/org/apache/camel/vault/GcpVaultConfiguration.java b/core/camel-api/src/main/java/org/apache/camel/vault/GcpVaultConfiguration.java
index 205cbe5..bc50bcf 100644
--- a/core/camel-api/src/main/java/org/apache/camel/vault/GcpVaultConfiguration.java
+++ b/core/camel-api/src/main/java/org/apache/camel/vault/GcpVaultConfiguration.java
@@ -27,6 +27,8 @@ public class GcpVaultConfiguration extends VaultConfiguration {
     private String serviceAccountKey;
     @Metadata
     private String projectId;
+    @Metadata
+    private boolean useDefaultInstance;
 
     public String getServiceAccountKey() {
         return serviceAccountKey;
@@ -50,4 +52,15 @@ public class GcpVaultConfiguration extends VaultConfiguration {
         this.projectId = projectId;
     }
 
+    public boolean isUseDefaultInstance() {
+        return useDefaultInstance;
+    }
+
+    /**
+     * Define if we want to use the GCP Client Default Instance or not
+     */
+    public void setUseDefaultInstance(boolean useDefaultInstance) {
+        this.useDefaultInstance = useDefaultInstance;
+    }
+
 }
diff --git a/core/camel-main/src/generated/java/org/apache/camel/main/GcpVaultConfigurationPropertiesConfigurer.java b/core/camel-main/src/generated/java/org/apache/camel/main/GcpVaultConfigurationPropertiesConfigurer.java
index 8f0e826..83b3680 100644
--- a/core/camel-main/src/generated/java/org/apache/camel/main/GcpVaultConfigurationPropertiesConfigurer.java
+++ b/core/camel-main/src/generated/java/org/apache/camel/main/GcpVaultConfigurationPropertiesConfigurer.java
@@ -29,6 +29,8 @@ public class GcpVaultConfigurationPropertiesConfigurer extends org.apache.camel.
         case "ProjectId": target.setProjectId(property(camelContext, java.lang.String.class, value)); return true;
         case "serviceaccountkey":
         case "ServiceAccountKey": target.setServiceAccountKey(property(camelContext, java.lang.String.class, value)); return true;
+        case "usedefaultinstance":
+        case "UseDefaultInstance": target.setUseDefaultInstance(property(camelContext, boolean.class, value)); return true;
         default: return false;
         }
     }
@@ -44,6 +46,8 @@ public class GcpVaultConfigurationPropertiesConfigurer extends org.apache.camel.
         case "ProjectId": return java.lang.String.class;
         case "serviceaccountkey":
         case "ServiceAccountKey": return java.lang.String.class;
+        case "usedefaultinstance":
+        case "UseDefaultInstance": return boolean.class;
         default: return null;
         }
     }
@@ -60,6 +64,8 @@ public class GcpVaultConfigurationPropertiesConfigurer extends org.apache.camel.
         case "ProjectId": return target.getProjectId();
         case "serviceaccountkey":
         case "ServiceAccountKey": return target.getServiceAccountKey();
+        case "usedefaultinstance":
+        case "UseDefaultInstance": return target.isUseDefaultInstance();
         default: return null;
         }
     }
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 19e2c3c..6050deb 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
@@ -232,6 +232,7 @@
     { "name": "camel.vault.aws.region", "description": "The AWS region", "sourceType": "org.apache.camel.vault.AwsVaultConfiguration", "type": "string", "javaType": "java.lang.String" },
     { "name": "camel.vault.aws.secretKey", "description": "The AWS secret key", "sourceType": "org.apache.camel.vault.AwsVaultConfiguration", "type": "string", "javaType": "java.lang.String" },
     { "name": "camel.vault.gcp.projectId", "description": "The GCP Project ID", "sourceType": "org.apache.camel.vault.GcpVaultConfiguration", "type": "string", "javaType": "java.lang.String" },
-    { "name": "camel.vault.gcp.serviceAccountKey", "description": "The Service Account Key location", "sourceType": "org.apache.camel.vault.GcpVaultConfiguration", "type": "string", "javaType": "java.lang.String" }
+    { "name": "camel.vault.gcp.serviceAccountKey", "description": "The Service Account Key location", "sourceType": "org.apache.camel.vault.GcpVaultConfiguration", "type": "string", "javaType": "java.lang.String" },
+    { "name": "camel.vault.gcp.useDefaultInstance", "description": "Define if we want to use the GCP Client Default Instance or not", "sourceType": "org.apache.camel.vault.GcpVaultConfiguration", "type": "boolean", "javaType": "boolean", "defaultValue": "false" }
   ]
 }
diff --git a/core/camel-main/src/main/docs/main.adoc b/core/camel-main/src/main/docs/main.adoc
index 4f8222c..2e83fd0 100644
--- a/core/camel-main/src/main/docs/main.adoc
+++ b/core/camel-main/src/main/docs/main.adoc
@@ -210,13 +210,14 @@ The camel.vault.aws supports 4 options, which are listed below.
 |===
 
 === Camel GCP Vault configurations
-The camel.vault.gcp supports 2 options, which are listed below.
+The camel.vault.gcp supports 3 options, which are listed below.
 
 [width="100%",cols="2,5,^1,2",options="header"]
 |===
 | Name | Description | Default | Type
 | *camel.vault.gcp.projectId* | The GCP Project ID |  | String
 | *camel.vault.gcp.serviceAccount{zwsp}Key* | The Service Account Key location |  | String
+| *camel.vault.gcp.useDefault{zwsp}Instance* | Define if we want to use the GCP Client Default Instance or not | false | boolean
 |===
 
 === Fault Tolerance EIP Circuit Breaker configurations
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/GcpVaultConfigurationProperties.java b/core/camel-main/src/main/java/org/apache/camel/main/GcpVaultConfigurationProperties.java
index 38353bd..f441291 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/GcpVaultConfigurationProperties.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/GcpVaultConfigurationProperties.java
@@ -65,4 +65,12 @@ public class GcpVaultConfigurationProperties extends GcpVaultConfiguration imple
         return this;
     }
 
+    /**
+     * The GCP Project ID
+     */
+    public GcpVaultConfigurationProperties withUseDefaultInstance(boolean useDefaultInstance) {
+        setUseDefaultInstance(useDefaultInstance);
+        return this;
+    }
+
 }
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
index d4c7ac3..cd4bceb 100644
--- 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
@@ -94,7 +94,7 @@ public class MainVaultTest {
 
         Assertions.assertEquals("file:////myKey", cfg.getServiceAccountKey());
         Assertions.assertEquals("gcp-project", cfg.getProjectId());
-
+        Assertions.assertEquals(false, cfg.isUseDefaultInstance());
         main.stop();
     }
 
@@ -116,7 +116,7 @@ public class MainVaultTest {
 
         Assertions.assertEquals("file:////myKey", cfg.getServiceAccountKey());
         Assertions.assertEquals("gcp-project", cfg.getProjectId());
-
+        Assertions.assertEquals(false, cfg.isUseDefaultInstance());
         main.stop();
     }