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
The following commit(s) were added to refs/heads/main by this push:
new 9beee642566 CAMEL-21330 - Camel-AWS-Secrets-Manager: Support
Properties Function with Localstack (#16060)
9beee642566 is described below
commit 9beee642566b87b819e01db67e39e36ffe40db2c
Author: Andrea Cosentino <[email protected]>
AuthorDate: Wed Oct 23 11:43:45 2024 +0200
CAMEL-21330 - Camel-AWS-Secrets-Manager: Support Properties Function with
Localstack (#16060)
* CAMEL-21330 - Camel-AWS-Secrets-Manager: Support Properties Function with
Localstack
Signed-off-by: Andrea Cosentino <[email protected]>
* CAMEL-21330 - Camel-AWS-Secrets-Manager: Support Properties Function with
Localstack
Signed-off-by: Andrea Cosentino <[email protected]>
---------
Signed-off-by: Andrea Cosentino <[email protected]>
---
.../main/camel-main-configuration-metadata.json | 2 +
.../SecretsManagerPropertiesFunction.java | 29 +++++++++++
.../integration/AwsSecretsManagerBaseTest.java | 48 ++++++++++++++++++
...etsManagerPropertiesSourceTestLocalstackIT.java | 56 +++++++++++++++++++++
.../apache/camel/vault/AwsVaultConfiguration.java | 27 ++++++++++
.../main/AwsVaultConfigurationConfigurer.java | 12 +++++
.../AwsVaultConfigurationPropertiesConfigurer.java | 14 ++++++
.../camel-main-configuration-metadata.json | 2 +
core/camel-main/src/main/docs/main.adoc | 4 +-
.../main/AwsVaultConfigurationProperties.java | 17 +++++++
.../java/org/apache/camel/main/MainVaultTest.java | 58 ++++++++++++++++++++++
11 files changed, 268 insertions(+), 1 deletion(-)
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
index 908b4a774bd..289eec71365 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
@@ -335,6 +335,7 @@
{ "name": "camel.trace.traceTemplates", "description": "Whether to trace
routes that is created from route templates or kamelets.", "sourceType":
"org.apache.camel.main.TracerConfigurationProperties", "type": "boolean",
"javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.vault.aws.accessKey", "description": "The AWS access
key", "sourceType": "org.apache.camel.vault.AwsVaultConfiguration", "type":
"string", "javaType": "java.lang.String" },
{ "name": "camel.vault.aws.defaultCredentialsProvider", "description":
"Define if we want to use the AWS Default Credentials Provider or not",
"sourceType": "org.apache.camel.vault.AwsVaultConfiguration", "type":
"boolean", "javaType": "boolean", "defaultValue": "false" },
+ { "name": "camel.vault.aws.overrideEndpoint", "description": "Set the need
for overriding the endpoint. This option needs to be used in combination with
the uriEndpointOverride option", "sourceType":
"org.apache.camel.vault.AwsVaultConfiguration", "type": "boolean", "javaType":
"boolean", "defaultValue": "false" },
{ "name": "camel.vault.aws.profileCredentialsProvider", "description":
"Define if we want to use the AWS Profile Credentials Provider or not",
"sourceType": "org.apache.camel.vault.AwsVaultConfiguration", "type":
"boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.vault.aws.profileName", "description": "Define the
profile name to use if Profile Credentials Provider is selected", "sourceType":
"org.apache.camel.vault.AwsVaultConfiguration", "type": "string", "javaType":
"java.lang.String" },
{ "name": "camel.vault.aws.refreshEnabled", "description": "Whether to
automatically reload Camel upon secrets being updated in AWS.", "sourceType":
"org.apache.camel.vault.AwsVaultConfiguration", "type": "boolean", "javaType":
"boolean", "defaultValue": "false" },
@@ -343,6 +344,7 @@
{ "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.aws.secrets", "description": "Specify the secret
names (or pattern) to check for updates. Multiple secrets can be separated by
comma.", "sourceType": "org.apache.camel.vault.AwsVaultConfiguration", "type":
"string", "javaType": "java.lang.String" },
{ "name": "camel.vault.aws.sqsQueueUrl", "description": "In case of usage
of SQS notification this field will specified the Queue URL to use",
"sourceType": "org.apache.camel.vault.AwsVaultConfiguration", "type": "string",
"javaType": "java.lang.String" },
+ { "name": "camel.vault.aws.uriEndpointOverride", "description": "Set the
overriding uri endpoint. This option needs to be used in combination with
overrideEndpoint option", "sourceType":
"org.apache.camel.vault.AwsVaultConfiguration", "type": "string", "javaType":
"java.lang.String" },
{ "name": "camel.vault.aws.useSqsNotification", "description": "Whether to
use AWS SQS for secrets updates notification, this will require setting up
Eventbridge\/Cloudtrail\/SQS communication", "sourceType":
"org.apache.camel.vault.AwsVaultConfiguration", "type": "boolean", "javaType":
"boolean", "defaultValue": "false" },
{ "name": "camel.vault.azure.azureIdentityEnabled", "description":
"Whether the Azure Identity Authentication should be used or not.",
"sourceType": "org.apache.camel.vault.AzureVaultConfiguration", "type":
"boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.vault.azure.blobAccessKey", "description": "The Eventhubs
Blob Access Key for CheckpointStore purpose", "sourceType":
"org.apache.camel.vault.AzureVaultConfiguration", "type": "string", "javaType":
"java.lang.String" },
diff --git
a/components/camel-aws/camel-aws-secrets-manager/src/main/java/org/apache/camel/component/aws/secretsmanager/SecretsManagerPropertiesFunction.java
b/components/camel-aws/camel-aws-secrets-manager/src/main/java/org/apache/camel/component/aws/secretsmanager/SecretsManagerPropertiesFunction.java
index 7ab78ae2d2c..51d0713f158 100644
---
a/components/camel-aws/camel-aws-secrets-manager/src/main/java/org/apache/camel/component/aws/secretsmanager/SecretsManagerPropertiesFunction.java
+++
b/components/camel-aws/camel-aws-secrets-manager/src/main/java/org/apache/camel/component/aws/secretsmanager/SecretsManagerPropertiesFunction.java
@@ -16,6 +16,7 @@
*/
package org.apache.camel.component.aws.secretsmanager;
+import java.net.URI;
import java.util.Base64;
import java.util.HashSet;
import java.util.Set;
@@ -94,6 +95,11 @@ public class SecretsManagerPropertiesFunction extends
ServiceSupport implements
private static final String CAMEL_AWS_VAULT_PROFILE_NAME_ENV
= "CAMEL_AWS_VAULT_PROFILE_NAME";
+ private static final String CAMEL_AWS_VAULT_IS_OVERRIDE_ENDPOINT
+ = "CAMEL_AWS_VAULT_IS_OVERRIDE_ENDPOINT";
+
+ private static final String CAMEL_AWS_VAULT_URI_ENDPOINT_OVERRIDE =
"CAMEL_AWS_VAULT_URI_ENDPOINT_OVERRIDE";
+
private CamelContext camelContext;
private SecretsManagerClient client;
@@ -106,6 +112,10 @@ public class SecretsManagerPropertiesFunction extends
ServiceSupport implements
private String profileName;
+ private boolean isOverrideEndpoint;
+
+ private String uriEndpointOverride;
+
public SecretsManagerPropertiesFunction() {
super();
}
@@ -127,6 +137,8 @@ public class SecretsManagerPropertiesFunction extends
ServiceSupport implements
boolean useProfileCredentialsProvider
=
Boolean.parseBoolean(System.getenv(CAMEL_AWS_VAULT_USE_PROFILE_CREDENTIALS_PROVIDER_ENV));
String profileName = System.getenv(CAMEL_AWS_VAULT_PROFILE_NAME_ENV);
+ boolean isOverrideEndpoint =
Boolean.parseBoolean(System.getenv(CAMEL_AWS_VAULT_IS_OVERRIDE_ENDPOINT));
+ String uriEndpointOverride =
System.getenv(CAMEL_AWS_VAULT_URI_ENDPOINT_OVERRIDE);
if (ObjectHelper.isEmpty(accessKey) && ObjectHelper.isEmpty(secretKey)
&& ObjectHelper.isEmpty(region)) {
AwsVaultConfiguration awsVaultConfiguration =
getCamelContext().getVaultConfiguration().aws();
if (ObjectHelper.isNotEmpty(awsVaultConfiguration)) {
@@ -136,6 +148,8 @@ public class SecretsManagerPropertiesFunction extends
ServiceSupport implements
useDefaultCredentialsProvider =
awsVaultConfiguration.isDefaultCredentialsProvider();
useProfileCredentialsProvider =
awsVaultConfiguration.isProfileCredentialsProvider();
profileName = awsVaultConfiguration.getProfileName();
+ isOverrideEndpoint =
awsVaultConfiguration.isOverrideEndpoint();
+ uriEndpointOverride =
awsVaultConfiguration.getUriEndpointOverride();
}
}
this.region = region;
@@ -144,11 +158,21 @@ public class SecretsManagerPropertiesFunction extends
ServiceSupport implements
AwsBasicCredentials cred = AwsBasicCredentials.create(accessKey,
secretKey);
clientBuilder =
clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred));
clientBuilder.region(Region.of(region));
+ if (isOverrideEndpoint) {
+ if (ObjectHelper.isNotEmpty(uriEndpointOverride)) {
+
clientBuilder.endpointOverride(URI.create(uriEndpointOverride));
+ }
+ }
client = clientBuilder.build();
} else if (useDefaultCredentialsProvider &&
ObjectHelper.isNotEmpty(region)) {
this.defaultCredentialsProvider = true;
SecretsManagerClientBuilder clientBuilder =
SecretsManagerClient.builder();
clientBuilder.region(Region.of(region));
+ if (isOverrideEndpoint) {
+ if (ObjectHelper.isNotEmpty(uriEndpointOverride)) {
+
clientBuilder.endpointOverride(URI.create(uriEndpointOverride));
+ }
+ }
client = clientBuilder.build();
} else if (useProfileCredentialsProvider &&
ObjectHelper.isNotEmpty(profileName)) {
this.profleCredentialsProvider = true;
@@ -156,6 +180,11 @@ public class SecretsManagerPropertiesFunction extends
ServiceSupport implements
SecretsManagerClientBuilder clientBuilder =
SecretsManagerClient.builder();
clientBuilder.credentialsProvider(ProfileCredentialsProvider.create(profileName));
clientBuilder.region(Region.of(region));
+ if (isOverrideEndpoint) {
+ if (ObjectHelper.isNotEmpty(uriEndpointOverride)) {
+
clientBuilder.endpointOverride(URI.create(uriEndpointOverride));
+ }
+ }
client = clientBuilder.build();
} else {
throw new RuntimeCamelException(
diff --git
a/components/camel-aws/camel-aws-secrets-manager/src/test/java/org/apache/camel/component/aws/secretsmanager/integration/AwsSecretsManagerBaseTest.java
b/components/camel-aws/camel-aws-secrets-manager/src/test/java/org/apache/camel/component/aws/secretsmanager/integration/AwsSecretsManagerBaseTest.java
index 02b838f4adc..9effb457490 100644
---
a/components/camel-aws/camel-aws-secrets-manager/src/test/java/org/apache/camel/component/aws/secretsmanager/integration/AwsSecretsManagerBaseTest.java
+++
b/components/camel-aws/camel-aws-secrets-manager/src/test/java/org/apache/camel/component/aws/secretsmanager/integration/AwsSecretsManagerBaseTest.java
@@ -16,6 +16,8 @@
*/
package org.apache.camel.component.aws.secretsmanager.integration;
+import java.net.URI;
+
import org.apache.camel.CamelContext;
import org.apache.camel.component.aws.secretsmanager.SecretsManagerComponent;
import org.apache.camel.test.infra.aws.common.services.AWSService;
@@ -24,6 +26,11 @@ import
org.apache.camel.test.infra.aws2.services.AWSServiceFactory;
import org.apache.camel.test.junit5.CamelTestSupport;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.extension.RegisterExtension;
+import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
+import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
+import software.amazon.awssdk.regions.Region;
+import software.amazon.awssdk.services.secretsmanager.SecretsManagerClient;
+import
software.amazon.awssdk.services.secretsmanager.SecretsManagerClientBuilder;
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public abstract class AwsSecretsManagerBaseTest extends CamelTestSupport {
@@ -37,4 +44,45 @@ public abstract class AwsSecretsManagerBaseTest extends
CamelTestSupport {
smComponent.getConfiguration().setSecretsManagerClient(AWSSDKClientUtils.newSecretsManagerClient());
return context;
}
+
+ // {aws.secret.key=secretkey, aws.region=us-east-1,
aws.access.key=accesskey, aws.host=localhost:32775, aws.protocol=http}
+ public static SecretsManagerClient getSecretManagerClient() {
+ String accessKey =
service.getConnectionProperties().getProperty("aws.access.key");
+ String region =
service.getConnectionProperties().getProperty("aws.region");
+ String secretKey =
service.getConnectionProperties().getProperty("aws.secret.key");
+ String host =
service.getConnectionProperties().getProperty("aws.host");
+ String protocol =
service.getConnectionProperties().getProperty("aws.protocol");
+ SecretsManagerClient client = null;
+ SecretsManagerClientBuilder clientBuilder =
SecretsManagerClient.builder();
+ AwsBasicCredentials cred = AwsBasicCredentials.create(accessKey,
secretKey);
+ clientBuilder =
clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred));
+ clientBuilder = clientBuilder.region(Region.of(region));
+ clientBuilder.endpointOverride(URI.create(protocol + "://" + host));
+ return clientBuilder.build();
+ }
+
+ public String getSecretKey() {
+ return service.getConnectionProperties().getProperty("aws.secret.key");
+ }
+
+ public String getAccessKey() {
+ return service.getConnectionProperties().getProperty("aws.access.key");
+ }
+
+ public String getRegion() {
+ return service.getConnectionProperties().getProperty("aws.region");
+ }
+
+ public String getProtocol() {
+ return service.getConnectionProperties().getProperty("aws.protocol");
+ }
+
+ public String getHost() {
+ return service.getConnectionProperties().getProperty("aws.host");
+ }
+
+ public String getUrlOverride() {
+ return getProtocol() + "://" + getHost();
+ }
+
}
diff --git
a/components/camel-aws/camel-aws-secrets-manager/src/test/java/org/apache/camel/component/aws/secretsmanager/integration/SecretsManagerPropertiesSourceTestLocalstackIT.java
b/components/camel-aws/camel-aws-secrets-manager/src/test/java/org/apache/camel/component/aws/secretsmanager/integration/SecretsManagerPropertiesSourceTestLocalstackIT.java
new file mode 100644
index 00000000000..444af412e0e
--- /dev/null
+++
b/components/camel-aws/camel-aws-secrets-manager/src/test/java/org/apache/camel/component/aws/secretsmanager/integration/SecretsManagerPropertiesSourceTestLocalstackIT.java
@@ -0,0 +1,56 @@
+/*
+ * 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.component.aws.secretsmanager.integration;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import
software.amazon.awssdk.services.secretsmanager.model.CreateSecretRequest;
+
+public class SecretsManagerPropertiesSourceTestLocalstackIT extends
AwsSecretsManagerBaseTest {
+
+ @BeforeAll
+ public static void setup() {
+ CreateSecretRequest.Builder builder = CreateSecretRequest.builder();
+ builder.name("test");
+ builder.secretString("hello");
+ getSecretManagerClient().createSecret(builder.build());
+ }
+
+ @Test
+ public void testFunction() throws Exception {
+ context.getVaultConfiguration().aws().setAccessKey(getAccessKey());
+ context.getVaultConfiguration().aws().setSecretKey(getSecretKey());
+ context.getVaultConfiguration().aws().setRegion(getRegion());
+ context.getVaultConfiguration().aws().setOverrideEndpoint(true);
+
context.getVaultConfiguration().aws().setUriEndpointOverride(getUrlOverride());
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() {
+
from("direct:start").setBody(simple("{{aws:test}}")).to("mock:bar");
+ }
+ });
+ context.start();
+
+ getMockEndpoint("mock:bar").expectedBodiesReceived("hello");
+
+ template.sendBody("direct:start", "Hello World");
+
+ MockEndpoint.assertIsSatisfied(context);
+ }
+}
diff --git
a/core/camel-api/src/main/java/org/apache/camel/vault/AwsVaultConfiguration.java
b/core/camel-api/src/main/java/org/apache/camel/vault/AwsVaultConfiguration.java
index 0423e106ade..ce79dedb7b2 100644
---
a/core/camel-api/src/main/java/org/apache/camel/vault/AwsVaultConfiguration.java
+++
b/core/camel-api/src/main/java/org/apache/camel/vault/AwsVaultConfiguration.java
@@ -45,6 +45,10 @@ public class AwsVaultConfiguration extends
VaultConfiguration {
private boolean useSqsNotification;
@Metadata
private String sqsQueueUrl;
+ @Metadata
+ private boolean overrideEndpoint;
+ @Metadata
+ private String uriEndpointOverride;
public String getAccessKey() {
return accessKey;
@@ -167,4 +171,27 @@ public class AwsVaultConfiguration extends
VaultConfiguration {
public void setSqsQueueUrl(String sqsQueueUrl) {
this.sqsQueueUrl = sqsQueueUrl;
}
+
+ public boolean isOverrideEndpoint() {
+ return overrideEndpoint;
+ }
+
+ /**
+ * Set the need for overriding the endpoint. This option needs to be used
in combination with the
+ * uriEndpointOverride option
+ */
+ public void setOverrideEndpoint(boolean overrideEndpoint) {
+ this.overrideEndpoint = overrideEndpoint;
+ }
+
+ public String getUriEndpointOverride() {
+ return uriEndpointOverride;
+ }
+
+ /**
+ * Set the overriding uri endpoint. This option needs to be used in
combination with overrideEndpoint option
+ */
+ public void setUriEndpointOverride(String uriEndpointOverride) {
+ this.uriEndpointOverride = uriEndpointOverride;
+ }
}
diff --git
a/core/camel-main/src/generated/java/org/apache/camel/main/AwsVaultConfigurationConfigurer.java
b/core/camel-main/src/generated/java/org/apache/camel/main/AwsVaultConfigurationConfigurer.java
index 50136343622..3bd64e971d6 100644
---
a/core/camel-main/src/generated/java/org/apache/camel/main/AwsVaultConfigurationConfigurer.java
+++
b/core/camel-main/src/generated/java/org/apache/camel/main/AwsVaultConfigurationConfigurer.java
@@ -37,6 +37,8 @@ public class AwsVaultConfigurationConfigurer extends
org.apache.camel.support.co
case "hashicorpVaultConfiguration":
target.setHashicorpVaultConfiguration(property(camelContext,
org.apache.camel.vault.HashicorpVaultConfiguration.class, value)); return true;
case "kubernetesvaultconfiguration":
case "kubernetesVaultConfiguration":
target.setKubernetesVaultConfiguration(property(camelContext,
org.apache.camel.vault.KubernetesVaultConfiguration.class, value)); return true;
+ case "overrideendpoint":
+ case "overrideEndpoint":
target.setOverrideEndpoint(property(camelContext, boolean.class, value));
return true;
case "profilecredentialsprovider":
case "profileCredentialsProvider":
target.setProfileCredentialsProvider(property(camelContext, boolean.class,
value)); return true;
case "profilename":
@@ -51,6 +53,8 @@ public class AwsVaultConfigurationConfigurer extends
org.apache.camel.support.co
case "secrets": target.setSecrets(property(camelContext,
java.lang.String.class, value)); return true;
case "sqsqueueurl":
case "sqsQueueUrl": target.setSqsQueueUrl(property(camelContext,
java.lang.String.class, value)); return true;
+ case "uriendpointoverride":
+ case "uriEndpointOverride":
target.setUriEndpointOverride(property(camelContext, java.lang.String.class,
value)); return true;
case "usesqsnotification":
case "useSqsNotification":
target.setUseSqsNotification(property(camelContext, boolean.class, value));
return true;
default: return false;
@@ -74,6 +78,8 @@ public class AwsVaultConfigurationConfigurer extends
org.apache.camel.support.co
case "hashicorpVaultConfiguration": return
org.apache.camel.vault.HashicorpVaultConfiguration.class;
case "kubernetesvaultconfiguration":
case "kubernetesVaultConfiguration": return
org.apache.camel.vault.KubernetesVaultConfiguration.class;
+ case "overrideendpoint":
+ case "overrideEndpoint": return boolean.class;
case "profilecredentialsprovider":
case "profileCredentialsProvider": return boolean.class;
case "profilename":
@@ -88,6 +94,8 @@ public class AwsVaultConfigurationConfigurer extends
org.apache.camel.support.co
case "secrets": return java.lang.String.class;
case "sqsqueueurl":
case "sqsQueueUrl": return java.lang.String.class;
+ case "uriendpointoverride":
+ case "uriEndpointOverride": return java.lang.String.class;
case "usesqsnotification":
case "useSqsNotification": return boolean.class;
default: return null;
@@ -112,6 +120,8 @@ public class AwsVaultConfigurationConfigurer extends
org.apache.camel.support.co
case "hashicorpVaultConfiguration": return
target.getHashicorpVaultConfiguration();
case "kubernetesvaultconfiguration":
case "kubernetesVaultConfiguration": return
target.getKubernetesVaultConfiguration();
+ case "overrideendpoint":
+ case "overrideEndpoint": return target.isOverrideEndpoint();
case "profilecredentialsprovider":
case "profileCredentialsProvider": return
target.isProfileCredentialsProvider();
case "profilename":
@@ -126,6 +136,8 @@ public class AwsVaultConfigurationConfigurer extends
org.apache.camel.support.co
case "secrets": return target.getSecrets();
case "sqsqueueurl":
case "sqsQueueUrl": return target.getSqsQueueUrl();
+ case "uriendpointoverride":
+ case "uriEndpointOverride": return target.getUriEndpointOverride();
case "usesqsnotification":
case "useSqsNotification": return target.isUseSqsNotification();
default: return null;
diff --git
a/core/camel-main/src/generated/java/org/apache/camel/main/AwsVaultConfigurationPropertiesConfigurer.java
b/core/camel-main/src/generated/java/org/apache/camel/main/AwsVaultConfigurationPropertiesConfigurer.java
index 5fe91949794..82b5eb73123 100644
---
a/core/camel-main/src/generated/java/org/apache/camel/main/AwsVaultConfigurationPropertiesConfigurer.java
+++
b/core/camel-main/src/generated/java/org/apache/camel/main/AwsVaultConfigurationPropertiesConfigurer.java
@@ -29,6 +29,7 @@ public class AwsVaultConfigurationPropertiesConfigurer
extends org.apache.camel.
map.put("GcpVaultConfiguration",
org.apache.camel.vault.GcpVaultConfiguration.class);
map.put("HashicorpVaultConfiguration",
org.apache.camel.vault.HashicorpVaultConfiguration.class);
map.put("KubernetesVaultConfiguration",
org.apache.camel.vault.KubernetesVaultConfiguration.class);
+ map.put("OverrideEndpoint", boolean.class);
map.put("ProfileCredentialsProvider", boolean.class);
map.put("ProfileName", java.lang.String.class);
map.put("RefreshEnabled", boolean.class);
@@ -37,6 +38,7 @@ public class AwsVaultConfigurationPropertiesConfigurer
extends org.apache.camel.
map.put("SecretKey", java.lang.String.class);
map.put("Secrets", java.lang.String.class);
map.put("SqsQueueUrl", java.lang.String.class);
+ map.put("UriEndpointOverride", java.lang.String.class);
map.put("UseSqsNotification", boolean.class);
ALL_OPTIONS = map;
ConfigurerStrategy.addBootstrapConfigurerClearer(AwsVaultConfigurationPropertiesConfigurer::clearBootstrapConfigurers);
@@ -60,6 +62,8 @@ public class AwsVaultConfigurationPropertiesConfigurer
extends org.apache.camel.
case "hashicorpVaultConfiguration":
target.setHashicorpVaultConfiguration(property(camelContext,
org.apache.camel.vault.HashicorpVaultConfiguration.class, value)); return true;
case "kubernetesvaultconfiguration":
case "kubernetesVaultConfiguration":
target.setKubernetesVaultConfiguration(property(camelContext,
org.apache.camel.vault.KubernetesVaultConfiguration.class, value)); return true;
+ case "overrideendpoint":
+ case "overrideEndpoint":
target.setOverrideEndpoint(property(camelContext, boolean.class, value));
return true;
case "profilecredentialsprovider":
case "profileCredentialsProvider":
target.setProfileCredentialsProvider(property(camelContext, boolean.class,
value)); return true;
case "profilename":
@@ -74,6 +78,8 @@ public class AwsVaultConfigurationPropertiesConfigurer
extends org.apache.camel.
case "secrets": target.setSecrets(property(camelContext,
java.lang.String.class, value)); return true;
case "sqsqueueurl":
case "sqsQueueUrl": target.setSqsQueueUrl(property(camelContext,
java.lang.String.class, value)); return true;
+ case "uriendpointoverride":
+ case "uriEndpointOverride":
target.setUriEndpointOverride(property(camelContext, java.lang.String.class,
value)); return true;
case "usesqsnotification":
case "useSqsNotification":
target.setUseSqsNotification(property(camelContext, boolean.class, value));
return true;
default: return false;
@@ -106,6 +112,8 @@ public class AwsVaultConfigurationPropertiesConfigurer
extends org.apache.camel.
case "hashicorpVaultConfiguration": return
org.apache.camel.vault.HashicorpVaultConfiguration.class;
case "kubernetesvaultconfiguration":
case "kubernetesVaultConfiguration": return
org.apache.camel.vault.KubernetesVaultConfiguration.class;
+ case "overrideendpoint":
+ case "overrideEndpoint": return boolean.class;
case "profilecredentialsprovider":
case "profileCredentialsProvider": return boolean.class;
case "profilename":
@@ -120,6 +128,8 @@ public class AwsVaultConfigurationPropertiesConfigurer
extends org.apache.camel.
case "secrets": return java.lang.String.class;
case "sqsqueueurl":
case "sqsQueueUrl": return java.lang.String.class;
+ case "uriendpointoverride":
+ case "uriEndpointOverride": return java.lang.String.class;
case "usesqsnotification":
case "useSqsNotification": return boolean.class;
default: return null;
@@ -144,6 +154,8 @@ public class AwsVaultConfigurationPropertiesConfigurer
extends org.apache.camel.
case "hashicorpVaultConfiguration": return
target.getHashicorpVaultConfiguration();
case "kubernetesvaultconfiguration":
case "kubernetesVaultConfiguration": return
target.getKubernetesVaultConfiguration();
+ case "overrideendpoint":
+ case "overrideEndpoint": return target.isOverrideEndpoint();
case "profilecredentialsprovider":
case "profileCredentialsProvider": return
target.isProfileCredentialsProvider();
case "profilename":
@@ -158,6 +170,8 @@ public class AwsVaultConfigurationPropertiesConfigurer
extends org.apache.camel.
case "secrets": return target.getSecrets();
case "sqsqueueurl":
case "sqsQueueUrl": return target.getSqsQueueUrl();
+ case "uriendpointoverride":
+ case "uriEndpointOverride": return target.getUriEndpointOverride();
case "usesqsnotification":
case "useSqsNotification": return target.isUseSqsNotification();
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 908b4a774bd..289eec71365 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
@@ -335,6 +335,7 @@
{ "name": "camel.trace.traceTemplates", "description": "Whether to trace
routes that is created from route templates or kamelets.", "sourceType":
"org.apache.camel.main.TracerConfigurationProperties", "type": "boolean",
"javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.vault.aws.accessKey", "description": "The AWS access
key", "sourceType": "org.apache.camel.vault.AwsVaultConfiguration", "type":
"string", "javaType": "java.lang.String" },
{ "name": "camel.vault.aws.defaultCredentialsProvider", "description":
"Define if we want to use the AWS Default Credentials Provider or not",
"sourceType": "org.apache.camel.vault.AwsVaultConfiguration", "type":
"boolean", "javaType": "boolean", "defaultValue": "false" },
+ { "name": "camel.vault.aws.overrideEndpoint", "description": "Set the need
for overriding the endpoint. This option needs to be used in combination with
the uriEndpointOverride option", "sourceType":
"org.apache.camel.vault.AwsVaultConfiguration", "type": "boolean", "javaType":
"boolean", "defaultValue": "false" },
{ "name": "camel.vault.aws.profileCredentialsProvider", "description":
"Define if we want to use the AWS Profile Credentials Provider or not",
"sourceType": "org.apache.camel.vault.AwsVaultConfiguration", "type":
"boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.vault.aws.profileName", "description": "Define the
profile name to use if Profile Credentials Provider is selected", "sourceType":
"org.apache.camel.vault.AwsVaultConfiguration", "type": "string", "javaType":
"java.lang.String" },
{ "name": "camel.vault.aws.refreshEnabled", "description": "Whether to
automatically reload Camel upon secrets being updated in AWS.", "sourceType":
"org.apache.camel.vault.AwsVaultConfiguration", "type": "boolean", "javaType":
"boolean", "defaultValue": "false" },
@@ -343,6 +344,7 @@
{ "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.aws.secrets", "description": "Specify the secret
names (or pattern) to check for updates. Multiple secrets can be separated by
comma.", "sourceType": "org.apache.camel.vault.AwsVaultConfiguration", "type":
"string", "javaType": "java.lang.String" },
{ "name": "camel.vault.aws.sqsQueueUrl", "description": "In case of usage
of SQS notification this field will specified the Queue URL to use",
"sourceType": "org.apache.camel.vault.AwsVaultConfiguration", "type": "string",
"javaType": "java.lang.String" },
+ { "name": "camel.vault.aws.uriEndpointOverride", "description": "Set the
overriding uri endpoint. This option needs to be used in combination with
overrideEndpoint option", "sourceType":
"org.apache.camel.vault.AwsVaultConfiguration", "type": "string", "javaType":
"java.lang.String" },
{ "name": "camel.vault.aws.useSqsNotification", "description": "Whether to
use AWS SQS for secrets updates notification, this will require setting up
Eventbridge\/Cloudtrail\/SQS communication", "sourceType":
"org.apache.camel.vault.AwsVaultConfiguration", "type": "boolean", "javaType":
"boolean", "defaultValue": "false" },
{ "name": "camel.vault.azure.azureIdentityEnabled", "description":
"Whether the Azure Identity Authentication should be used or not.",
"sourceType": "org.apache.camel.vault.AzureVaultConfiguration", "type":
"boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.vault.azure.blobAccessKey", "description": "The Eventhubs
Blob Access Key for CheckpointStore purpose", "sourceType":
"org.apache.camel.vault.AzureVaultConfiguration", "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 82f9d33882f..e9899e5ae41 100644
--- a/core/camel-main/src/main/docs/main.adoc
+++ b/core/camel-main/src/main/docs/main.adoc
@@ -367,13 +367,14 @@ The camel.rest supports 29 options, which are listed
below.
=== Camel AWS Vault configurations
-The camel.vault.aws supports 11 options, which are listed below.
+The camel.vault.aws supports 13 options, which are listed below.
[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
| *camel.vault.aws.accessKey* | The AWS access key | | String
| *camel.vault.aws.default{zwsp}CredentialsProvider* | Define if we want to
use the AWS Default Credentials Provider or not | false | boolean
+| *camel.vault.aws.override{zwsp}Endpoint* | Set the need for overriding the
endpoint. This option needs to be used in combination with the
uriEndpointOverride option | false | boolean
| *camel.vault.aws.profile{zwsp}CredentialsProvider* | Define if we want to
use the AWS Profile Credentials Provider or not | false | boolean
| *camel.vault.aws.profileName* | Define the profile name to use if Profile
Credentials Provider is selected | | String
| *camel.vault.aws.refreshEnabled* | Whether to automatically reload Camel
upon secrets being updated in AWS. | false | boolean
@@ -382,6 +383,7 @@ The camel.vault.aws supports 11 options, which are listed
below.
| *camel.vault.aws.secretKey* | The AWS secret key | | String
| *camel.vault.aws.secrets* | Specify the secret names (or pattern) to check
for updates. Multiple secrets can be separated by comma. | | String
| *camel.vault.aws.sqsQueueUrl* | In case of usage of SQS notification this
field will specified the Queue URL to use | | String
+| *camel.vault.aws.uriEndpoint{zwsp}Override* | Set the overriding uri
endpoint. This option needs to be used in combination with overrideEndpoint
option | | String
| *camel.vault.aws.useSqs{zwsp}Notification* | Whether to use AWS SQS for
secrets updates notification, this will require setting up
Eventbridge/Cloudtrail/SQS communication | false | boolean
|===
diff --git
a/core/camel-main/src/main/java/org/apache/camel/main/AwsVaultConfigurationProperties.java
b/core/camel-main/src/main/java/org/apache/camel/main/AwsVaultConfigurationProperties.java
index 0ef8f299f14..31abefa851e 100644
---
a/core/camel-main/src/main/java/org/apache/camel/main/AwsVaultConfigurationProperties.java
+++
b/core/camel-main/src/main/java/org/apache/camel/main/AwsVaultConfigurationProperties.java
@@ -138,4 +138,21 @@ public class AwsVaultConfigurationProperties extends
AwsVaultConfiguration imple
return this;
}
+ /**
+ * Set the need for overriding the endpoint. This option needs to be used
in combination with the
+ * uriEndpointOverride option
+ */
+ public AwsVaultConfigurationProperties isOverrideEndpoint(boolean
overrideEndpoint) {
+ setOverrideEndpoint(overrideEndpoint);
+ return this;
+ }
+
+ /**
+ * Set the overriding uri endpoint. This option needs to be used in
combination with overrideEndpoint option
+ */
+ public AwsVaultConfigurationProperties withUriEndpointOverride(String
uriEndpointOverride) {
+ setUriEndpointOverride(uriEndpointOverride);
+ 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 124ee478a77..9105e9fba78 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
@@ -50,6 +50,34 @@ public class MainVaultTest {
main.stop();
}
+ @Test
+ public void testMainOverrideEndpointAws() {
+ Main main = new Main();
+
+ main.addInitialProperty("camel.vault.aws.accessKey", "myKey");
+ main.addInitialProperty("camel.vault.aws.secretKey", "mySecret");
+ main.addInitialProperty("camel.vault.aws.region", "myRegion");
+ main.addInitialProperty("camel.vault.aws.defaultCredentialsProvider",
"false");
+ main.addInitialProperty("camel.vault.aws.overrideEndpoint", "true");
+ main.addInitialProperty("camel.vault.aws.uriEndpointOverride",
"http://localhost:8080");
+
+ main.start();
+
+ CamelContext context = main.getCamelContext();
+ assertNotNull(context);
+
+ AwsVaultConfiguration cfg = context.getVaultConfiguration().aws();
+ assertNotNull(cfg);
+
+ Assertions.assertEquals("myKey", cfg.getAccessKey());
+ Assertions.assertEquals("mySecret", cfg.getSecretKey());
+ Assertions.assertEquals("myRegion", cfg.getRegion());
+ Assertions.assertFalse(cfg.isDefaultCredentialsProvider());
+ Assertions.assertTrue(cfg.isOverrideEndpoint());
+ Assertions.assertEquals("http://localhost:8080",
cfg.getUriEndpointOverride());
+ main.stop();
+ }
+
@Test
public void testMainProfileAws() {
final Main main = getMain();
@@ -108,6 +136,36 @@ public class MainVaultTest {
main.stop();
}
+ @Test
+ public void testMainOverrideEndpointAwsFluent() {
+ Main main = new Main();
+ main.configure().vault().aws()
+ .withAccessKey("myKey")
+ .withSecretKey("mySecret")
+ .withRegion("myRegion")
+ .isOverrideEndpoint(true)
+ .withUriEndpointOverride("http://localhost:8080")
+ .withDefaultCredentialsProvider(false)
+ .end();
+
+ main.start();
+
+ CamelContext context = main.getCamelContext();
+ assertNotNull(context);
+
+ AwsVaultConfiguration cfg = context.getVaultConfiguration().aws();
+ assertNotNull(cfg);
+
+ Assertions.assertEquals("myKey", cfg.getAccessKey());
+ Assertions.assertEquals("mySecret", cfg.getSecretKey());
+ Assertions.assertEquals("myRegion", cfg.getRegion());
+ Assertions.assertFalse(cfg.isDefaultCredentialsProvider());
+ Assertions.assertTrue(cfg.isOverrideEndpoint());
+ Assertions.assertEquals("http://localhost:8080",
cfg.getUriEndpointOverride());
+
+ main.stop();
+ }
+
@Test
public void testMainAwsFluent() {
Main main = new Main();