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 2019/12/11 11:22:55 UTC
[camel] branch master updated: CAMEL-14284: Configuring endpoint
should set properties on endpoint and not configuration object - aws-eks
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push:
new a3aa6c4 CAMEL-14284: Configuring endpoint should set properties on endpoint and not configuration object - aws-eks
a3aa6c4 is described below
commit a3aa6c4e5ad9ab5d9491788fecd3acf137e25699
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Dec 11 12:22:23 2019 +0100
CAMEL-14284: Configuring endpoint should set properties on endpoint and not configuration object - aws-eks
---
.../camel/component/aws/ecs/ECSComponent.java | 2 +-
.../camel/component/aws/eks/EKSComponent.java | 33 ++++++++--------------
.../aws/eks/EKSComponentClientRegistryTest.java | 4 +--
.../aws/eks/EKSComponentConfigurationTest.java | 6 ++--
4 files changed, 18 insertions(+), 27 deletions(-)
diff --git a/components/camel-aws-ecs/src/main/java/org/apache/camel/component/aws/ecs/ECSComponent.java b/components/camel-aws-ecs/src/main/java/org/apache/camel/component/aws/ecs/ECSComponent.java
index 349ef87..bb2c04f 100644
--- a/components/camel-aws-ecs/src/main/java/org/apache/camel/component/aws/ecs/ECSComponent.java
+++ b/components/camel-aws-ecs/src/main/java/org/apache/camel/component/aws/ecs/ECSComponent.java
@@ -53,7 +53,7 @@ public class ECSComponent extends DefaultComponent {
@Override
protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
- ECSConfiguration configuration = this.configuration != null ? this.configuration.copy() : new ECSConfiguration();
+ ECSConfiguration configuration = this.configuration != null ? this.configuration.copy() : new ECSConfiguration();
ECSEndpoint endpoint = new ECSEndpoint(uri, this, configuration);
endpoint.getConfiguration().setAccessKey(accessKey);
endpoint.getConfiguration().setSecretKey(secretKey);
diff --git a/components/camel-aws-eks/src/main/java/org/apache/camel/component/aws/eks/EKSComponent.java b/components/camel-aws-eks/src/main/java/org/apache/camel/component/aws/eks/EKSComponent.java
index f3710cc..abb9e72 100644
--- a/components/camel-aws-eks/src/main/java/org/apache/camel/component/aws/eks/EKSComponent.java
+++ b/components/camel-aws-eks/src/main/java/org/apache/camel/component/aws/eks/EKSComponent.java
@@ -25,7 +25,6 @@ import org.apache.camel.Endpoint;
import org.apache.camel.spi.Metadata;
import org.apache.camel.spi.annotations.Component;
import org.apache.camel.support.DefaultComponent;
-import org.apache.camel.util.ObjectHelper;
/**
* For working with Amazon EKS.
@@ -49,30 +48,22 @@ public class EKSComponent extends DefaultComponent {
public EKSComponent(CamelContext context) {
super(context);
- this.configuration = new EKSConfiguration();
registerExtension(new EKSComponentVerifierExtension());
}
@Override
protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
- EKSConfiguration configuration = this.configuration.copy();
- setProperties(configuration, parameters);
-
- if (ObjectHelper.isEmpty(configuration.getAccessKey())) {
- setAccessKey(accessKey);
- }
- if (ObjectHelper.isEmpty(configuration.getSecretKey())) {
- setSecretKey(secretKey);
- }
- if (ObjectHelper.isEmpty(configuration.getRegion())) {
- setRegion(region);
- }
+ EKSConfiguration configuration = this.configuration != null ? this.configuration.copy() : new EKSConfiguration();
+ EKSEndpoint endpoint = new EKSEndpoint(uri, this, configuration);
+ endpoint.getConfiguration().setAccessKey(accessKey);
+ endpoint.getConfiguration().setSecretKey(secretKey);
+ endpoint.getConfiguration().setRegion(region);
+ setProperties(endpoint, parameters);
checkAndSetRegistryClient(configuration);
if (configuration.getEksClient() == null && (configuration.getAccessKey() == null || configuration.getSecretKey() == null)) {
throw new IllegalArgumentException("Amazon eks client or accessKey and secretKey must be specified");
}
- EKSEndpoint endpoint = new EKSEndpoint(uri, this, configuration);
return endpoint;
}
@@ -88,36 +79,36 @@ public class EKSComponent extends DefaultComponent {
}
public String getAccessKey() {
- return configuration.getAccessKey();
+ return accessKey;
}
/**
* Amazon AWS Access Key
*/
public void setAccessKey(String accessKey) {
- configuration.setAccessKey(accessKey);
+ this.accessKey = accessKey;
}
public String getSecretKey() {
- return configuration.getSecretKey();
+ return secretKey;
}
/**
* Amazon AWS Secret Key
*/
public void setSecretKey(String secretKey) {
- configuration.setSecretKey(secretKey);
+ this.secretKey = secretKey;
}
public String getRegion() {
- return configuration.getRegion();
+ return region;
}
/**
* The region in which EKS client needs to work
*/
public void setRegion(String region) {
- configuration.setRegion(region);
+ this.region = region;
}
private void checkAndSetRegistryClient(EKSConfiguration configuration) {
diff --git a/components/camel-aws-eks/src/test/java/org/apache/camel/component/aws/eks/EKSComponentClientRegistryTest.java b/components/camel-aws-eks/src/test/java/org/apache/camel/component/aws/eks/EKSComponentClientRegistryTest.java
index 2d07a4d..9b1867d 100644
--- a/components/camel-aws-eks/src/test/java/org/apache/camel/component/aws/eks/EKSComponentClientRegistryTest.java
+++ b/components/camel-aws-eks/src/test/java/org/apache/camel/component/aws/eks/EKSComponentClientRegistryTest.java
@@ -26,7 +26,7 @@ public class EKSComponentClientRegistryTest extends CamelTestSupport {
AmazonEKSClientMock clientMock = new AmazonEKSClientMock();
context.getRegistry().bind("amazonEcsClient", clientMock);
- EKSComponent component = new EKSComponent(context);
+ EKSComponent component = context.getComponent("aws-eks", EKSComponent.class);
EKSEndpoint endpoint = (EKSEndpoint)component.createEndpoint("aws-eks://TestDomain");
assertNotNull(endpoint.getConfiguration().getEksClient());
@@ -35,7 +35,7 @@ public class EKSComponentClientRegistryTest extends CamelTestSupport {
@Test(expected = IllegalArgumentException.class)
public void createEndpointWithMinimalECSClientMisconfiguration() throws Exception {
- EKSComponent component = new EKSComponent(context);
+ EKSComponent component = context.getComponent("aws-eks", EKSComponent.class);
EKSEndpoint endpoint = (EKSEndpoint)component.createEndpoint("aws-eks://TestDomain");
}
}
diff --git a/components/camel-aws-eks/src/test/java/org/apache/camel/component/aws/eks/EKSComponentConfigurationTest.java b/components/camel-aws-eks/src/test/java/org/apache/camel/component/aws/eks/EKSComponentConfigurationTest.java
index 9c82089..3c4c824 100644
--- a/components/camel-aws-eks/src/test/java/org/apache/camel/component/aws/eks/EKSComponentConfigurationTest.java
+++ b/components/camel-aws-eks/src/test/java/org/apache/camel/component/aws/eks/EKSComponentConfigurationTest.java
@@ -26,7 +26,7 @@ public class EKSComponentConfigurationTest extends CamelTestSupport {
@Test
public void createEndpointWithComponentElements() throws Exception {
- EKSComponent component = new EKSComponent(context);
+ EKSComponent component = context.getComponent("aws-eks", EKSComponent.class);
component.setAccessKey("XXX");
component.setSecretKey("YYY");
EKSEndpoint endpoint = (EKSEndpoint)component.createEndpoint("aws-eks://label");
@@ -37,7 +37,7 @@ public class EKSComponentConfigurationTest extends CamelTestSupport {
@Test
public void createEndpointWithComponentAndEndpointElements() throws Exception {
- EKSComponent component = new EKSComponent(context);
+ EKSComponent component = context.getComponent("aws-eks", EKSComponent.class);
component.setAccessKey("XXX");
component.setSecretKey("YYY");
component.setRegion(Regions.US_WEST_1.toString());
@@ -50,7 +50,7 @@ public class EKSComponentConfigurationTest extends CamelTestSupport {
@Test
public void createEndpointWithComponentEndpointElementsAndProxy() throws Exception {
- EKSComponent component = new EKSComponent(context);
+ EKSComponent component = context.getComponent("aws-eks", EKSComponent.class);
component.setAccessKey("XXX");
component.setSecretKey("YYY");
component.setRegion(Regions.US_WEST_1.toString());