You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2017/03/28 15:07:30 UTC
[4/5] camel git commit: CAMEL-11085: camel-kubernetes : make it easy
to configure components and service-discovery in spring-boot
CAMEL-11085: camel-kubernetes : make it easy to configure components and service-discovery in spring-boot
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/9bab0d08
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/9bab0d08
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/9bab0d08
Branch: refs/heads/master
Commit: 9bab0d088c4930c1e2aec58745e59f56d9df8d61
Parents: 46dc46b
Author: lburgazzoli <lb...@gmail.com>
Authored: Tue Mar 28 16:46:30 2017 +0200
Committer: lburgazzoli <lb...@gmail.com>
Committed: Tue Mar 28 17:06:48 2017 +0200
----------------------------------------------------------------------
...CallServiceDiscoveryConfigurationCommon.java | 256 +++++++++++++++++++
...ServiceDiscoveryConfigurationProperties.java | 48 ++++
.../cloud/KubernetesCloudAutoConfiguration.java | 15 +-
.../cloud/KubernetesCloudConfiguration.java | 62 -----
.../KubernetesServiceDiscoveryDisabledTest.java | 64 +++++
.../KubernetesServiceDiscoveryEnabledTest.java | 65 +++++
.../src/test/resources/logback.xml | 39 +++
.../SpringBootAutoConfigurationMojo.java | 14 +-
8 files changed, 492 insertions(+), 71 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/9bab0d08/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/model/cloud/springboot/KubernetesServiceCallServiceDiscoveryConfigurationCommon.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/model/cloud/springboot/KubernetesServiceCallServiceDiscoveryConfigurationCommon.java b/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/model/cloud/springboot/KubernetesServiceCallServiceDiscoveryConfigurationCommon.java
new file mode 100644
index 0000000..9763c5b
--- /dev/null
+++ b/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/model/cloud/springboot/KubernetesServiceCallServiceDiscoveryConfigurationCommon.java
@@ -0,0 +1,256 @@
+/**
+ * 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.model.cloud.springboot;
+
+import java.util.List;
+import org.apache.camel.model.PropertyDefinition;
+
+/**
+ * Generated by camel-package-maven-plugin - do not edit this file!
+ */
+public class KubernetesServiceCallServiceDiscoveryConfigurationCommon {
+
+ /**
+ * How to perform service lookup. Possible values: client dns environment.
+ * When using client then the client queries the kubernetes master to obtain
+ * a list of active pods that provides the service and then random (or round
+ * robin) select a pod. When using dns the service name is resolved as
+ * name.namespace.service.dnsDomain. When using environment then environment
+ * variables are used to lookup the service. By default environment is used.
+ */
+ private String lookup = "environment";
+ /**
+ * Sets the DNS domain to use for DNS lookup.
+ */
+ private String dnsDomain;
+ /**
+ * Sets the namespace to use. Will by default use namespace from the ENV
+ * variable KUBERNETES_MASTER.
+ */
+ private String namespace;
+ /**
+ * Sets the API version when using client lookup
+ */
+ private String apiVersion;
+ /**
+ * Sets the URL to the master when using client lookup
+ */
+ private String masterUrl;
+ /**
+ * Sets the username for authentication when using client lookup
+ */
+ private String username;
+ /**
+ * Sets the password for authentication when using client lookup
+ */
+ private String password;
+ /**
+ * Sets the OAUTH token for authentication (instead of username/password)
+ * when using client lookup
+ */
+ private String oauthToken;
+ /**
+ * Sets the Certificate Authority data when using client lookup
+ */
+ private String caCertData;
+ /**
+ * Sets the Certificate Authority data that are loaded from the file when
+ * using client lookup
+ */
+ private String caCertFile;
+ /**
+ * Sets the Client Certificate data when using client lookup
+ */
+ private String clientCertData;
+ /**
+ * Sets the Client Certificate data that are loaded from the file when using
+ * client lookup
+ */
+ private String clientCertFile;
+ /**
+ * Sets the Client Keystore algorithm such as RSA when using client lookup
+ */
+ private String clientKeyAlgo;
+ /**
+ * Sets the Client Keystore data when using client lookup
+ */
+ private String clientKeyData;
+ /**
+ * Sets the Client Keystore data that are loaded from the file when using
+ * client lookup
+ */
+ private String clientKeyFile;
+ /**
+ * Sets the Client Keystore passphrase when using client lookup
+ */
+ private String clientKeyPassphrase;
+ /**
+ * Sets whether to turn on trust certificate check when using client lookup
+ */
+ private Boolean trustCerts = false;
+ /**
+ * Set client properties to use. These properties are specific to what
+ * service call implementation are in use. For example if using ribbon then
+ * the client properties are define in
+ * com.netflix.client.config.CommonClientConfigKey.
+ */
+ private List<PropertyDefinition> properties;
+
+ public String getLookup() {
+ return lookup;
+ }
+
+ public void setLookup(String lookup) {
+ this.lookup = lookup;
+ }
+
+ public String getDnsDomain() {
+ return dnsDomain;
+ }
+
+ public void setDnsDomain(String dnsDomain) {
+ this.dnsDomain = dnsDomain;
+ }
+
+ public String getNamespace() {
+ return namespace;
+ }
+
+ public void setNamespace(String namespace) {
+ this.namespace = namespace;
+ }
+
+ public String getApiVersion() {
+ return apiVersion;
+ }
+
+ public void setApiVersion(String apiVersion) {
+ this.apiVersion = apiVersion;
+ }
+
+ public String getMasterUrl() {
+ return masterUrl;
+ }
+
+ public void setMasterUrl(String masterUrl) {
+ this.masterUrl = masterUrl;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public String getOauthToken() {
+ return oauthToken;
+ }
+
+ public void setOauthToken(String oauthToken) {
+ this.oauthToken = oauthToken;
+ }
+
+ public String getCaCertData() {
+ return caCertData;
+ }
+
+ public void setCaCertData(String caCertData) {
+ this.caCertData = caCertData;
+ }
+
+ public String getCaCertFile() {
+ return caCertFile;
+ }
+
+ public void setCaCertFile(String caCertFile) {
+ this.caCertFile = caCertFile;
+ }
+
+ public String getClientCertData() {
+ return clientCertData;
+ }
+
+ public void setClientCertData(String clientCertData) {
+ this.clientCertData = clientCertData;
+ }
+
+ public String getClientCertFile() {
+ return clientCertFile;
+ }
+
+ public void setClientCertFile(String clientCertFile) {
+ this.clientCertFile = clientCertFile;
+ }
+
+ public String getClientKeyAlgo() {
+ return clientKeyAlgo;
+ }
+
+ public void setClientKeyAlgo(String clientKeyAlgo) {
+ this.clientKeyAlgo = clientKeyAlgo;
+ }
+
+ public String getClientKeyData() {
+ return clientKeyData;
+ }
+
+ public void setClientKeyData(String clientKeyData) {
+ this.clientKeyData = clientKeyData;
+ }
+
+ public String getClientKeyFile() {
+ return clientKeyFile;
+ }
+
+ public void setClientKeyFile(String clientKeyFile) {
+ this.clientKeyFile = clientKeyFile;
+ }
+
+ public String getClientKeyPassphrase() {
+ return clientKeyPassphrase;
+ }
+
+ public void setClientKeyPassphrase(String clientKeyPassphrase) {
+ this.clientKeyPassphrase = clientKeyPassphrase;
+ }
+
+ public Boolean getTrustCerts() {
+ return trustCerts;
+ }
+
+ public void setTrustCerts(Boolean trustCerts) {
+ this.trustCerts = trustCerts;
+ }
+
+ public List<PropertyDefinition> getProperties() {
+ return properties;
+ }
+
+ public void setProperties(List<PropertyDefinition> properties) {
+ this.properties = properties;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/9bab0d08/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/model/cloud/springboot/KubernetesServiceCallServiceDiscoveryConfigurationProperties.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/model/cloud/springboot/KubernetesServiceCallServiceDiscoveryConfigurationProperties.java b/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/model/cloud/springboot/KubernetesServiceCallServiceDiscoveryConfigurationProperties.java
new file mode 100644
index 0000000..4807d33
--- /dev/null
+++ b/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/model/cloud/springboot/KubernetesServiceCallServiceDiscoveryConfigurationProperties.java
@@ -0,0 +1,48 @@
+/**
+ * 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.model.cloud.springboot;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+@ConfigurationProperties(prefix = "camel.cloud.kubernetes.service-discovery")
+public class KubernetesServiceCallServiceDiscoveryConfigurationProperties
+ extends
+ KubernetesServiceCallServiceDiscoveryConfigurationCommon {
+
+ /**
+ * Enable the component
+ */
+ private boolean enabled = true;
+ /**
+ * Define additional configuration definitions
+ */
+ private Map<String, KubernetesServiceCallServiceDiscoveryConfigurationCommon> configurations = new HashMap<>();
+
+ public Map<String, KubernetesServiceCallServiceDiscoveryConfigurationCommon> getConfigurations() {
+ return configurations;
+ }
+
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/9bab0d08/platforms/spring-boot/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/springboot/cloud/KubernetesCloudAutoConfiguration.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/springboot/cloud/KubernetesCloudAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/springboot/cloud/KubernetesCloudAutoConfiguration.java
index b3ced3e..0124e32 100644
--- a/platforms/spring-boot/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/springboot/cloud/KubernetesCloudAutoConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/springboot/cloud/KubernetesCloudAutoConfiguration.java
@@ -18,13 +18,13 @@ package org.apache.camel.component.kubernetes.springboot.cloud;
import java.util.HashMap;
import java.util.Map;
-
import javax.annotation.PostConstruct;
import org.apache.camel.CamelContext;
import org.apache.camel.cloud.ServiceDiscovery;
-import org.apache.camel.component.kubernetes.KubernetesConfiguration;
import org.apache.camel.component.kubernetes.cloud.KubernetesServiceDiscoveryFactory;
+import org.apache.camel.model.cloud.springboot.KubernetesServiceCallServiceDiscoveryConfigurationCommon;
+import org.apache.camel.model.cloud.springboot.KubernetesServiceCallServiceDiscoveryConfigurationProperties;
import org.apache.camel.spring.boot.CamelAutoConfiguration;
import org.apache.camel.spring.boot.util.GroupCondition;
import org.apache.camel.util.IntrospectionSupport;
@@ -44,12 +44,12 @@ import org.springframework.context.annotation.Lazy;
@ConditionalOnBean(CamelAutoConfiguration.class)
@Conditional(KubernetesCloudAutoConfiguration.Condition.class)
@AutoConfigureAfter(CamelAutoConfiguration.class)
-@EnableConfigurationProperties(KubernetesCloudConfiguration.class)
+@EnableConfigurationProperties(KubernetesServiceCallServiceDiscoveryConfigurationProperties.class)
public class KubernetesCloudAutoConfiguration {
@Autowired
private CamelContext camelContext;
@Autowired
- private KubernetesCloudConfiguration configuration;
+ private KubernetesServiceCallServiceDiscoveryConfigurationProperties configuration;
@Autowired
private ConfigurableBeanFactory beanFactory;
@@ -71,10 +71,9 @@ public class KubernetesCloudAutoConfiguration {
@PostConstruct
public void postConstruct() {
if (beanFactory != null) {
- KubernetesCloudConfiguration.ServiceDiscoveryConfiguration discovery = configuration.getServiceDiscovery();
Map<String, Object> parameters = new HashMap<>();
- for (Map.Entry<String, KubernetesConfiguration> entry : discovery.getConfigurations().entrySet()) {
+ for (Map.Entry<String, KubernetesServiceCallServiceDiscoveryConfigurationCommon> entry : configuration.getConfigurations().entrySet()) {
// clean up params
parameters.clear();
@@ -100,8 +99,8 @@ public class KubernetesCloudAutoConfiguration {
public static class Condition extends GroupCondition {
public Condition() {
super(
- "camel.cloud",
- "camel.cloud.kubernetes"
+ "camel.cloud.kubernetes",
+ "camel.cloud.kubernetes.service-discovery"
);
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/9bab0d08/platforms/spring-boot/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/springboot/cloud/KubernetesCloudConfiguration.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/springboot/cloud/KubernetesCloudConfiguration.java b/platforms/spring-boot/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/springboot/cloud/KubernetesCloudConfiguration.java
deleted file mode 100644
index 832b0e7..0000000
--- a/platforms/spring-boot/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/springboot/cloud/KubernetesCloudConfiguration.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- * 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.kubernetes.springboot.cloud;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.camel.component.kubernetes.KubernetesConfiguration;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-
-@ConfigurationProperties(prefix = "camel.cloud.kubernetes")
-public class KubernetesCloudConfiguration {
- private boolean enabled = true;
- private ServiceDiscoveryConfiguration serviceDiscovery = new ServiceDiscoveryConfiguration();
-
- public boolean isEnabled() {
- return enabled;
- }
-
- public void setEnabled(boolean enabled) {
- this.enabled = enabled;
- }
-
- public ServiceDiscoveryConfiguration getServiceDiscovery() {
- return serviceDiscovery;
- }
-
- // *************************************************************************
- //
- // *************************************************************************
-
- public class ServiceDiscoveryConfiguration extends KubernetesConfiguration {
- private final Map<String, KubernetesConfiguration> configurations = new HashMap<>();
- private String lookup;
-
- public String getLookup() {
- return lookup;
- }
-
- public void setLookup(String lookup) {
- this.lookup = lookup;
- }
-
- public Map<String, KubernetesConfiguration> getConfigurations() {
- return configurations;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/9bab0d08/platforms/spring-boot/components-starter/camel-kubernetes-starter/src/test/java/org/apache/camel/component/kubernetes/springboot/cloud/KubernetesServiceDiscoveryDisabledTest.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-kubernetes-starter/src/test/java/org/apache/camel/component/kubernetes/springboot/cloud/KubernetesServiceDiscoveryDisabledTest.java b/platforms/spring-boot/components-starter/camel-kubernetes-starter/src/test/java/org/apache/camel/component/kubernetes/springboot/cloud/KubernetesServiceDiscoveryDisabledTest.java
new file mode 100644
index 0000000..79f7a84
--- /dev/null
+++ b/platforms/spring-boot/components-starter/camel-kubernetes-starter/src/test/java/org/apache/camel/component/kubernetes/springboot/cloud/KubernetesServiceDiscoveryDisabledTest.java
@@ -0,0 +1,64 @@
+/**
+ * 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.kubernetes.springboot.cloud;
+
+import java.util.Map;
+
+import org.apache.camel.cloud.ServiceDiscovery;
+import org.apache.camel.model.cloud.springboot.KubernetesServiceCallServiceDiscoveryConfigurationProperties;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@DirtiesContext
+@SpringBootApplication
+@SpringBootTest(
+ classes = {
+ KubernetesServiceDiscoveryEnabledTest.TestConfiguration.class
+ },
+ properties = {
+ "debug=false",
+ "camel.cloud.kubernetes.service-discovery.enabled=false"
+})
+public class KubernetesServiceDiscoveryDisabledTest {
+ @Autowired
+ ApplicationContext context;
+
+ @Test
+ public void testConfiguration() throws Exception {
+ Map<String, ?> beans;
+
+ beans = context.getBeansOfType(KubernetesServiceCallServiceDiscoveryConfigurationProperties.class);
+ Assert.assertTrue(beans.isEmpty());
+
+ beans = context.getBeansOfType(ServiceDiscovery.class);
+ Assert.assertFalse(beans.isEmpty());
+ Assert.assertFalse(beans.containsKey("kubernetes-service-discovery"));
+ }
+
+ @Configuration
+ public static class TestConfiguration {
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/9bab0d08/platforms/spring-boot/components-starter/camel-kubernetes-starter/src/test/java/org/apache/camel/component/kubernetes/springboot/cloud/KubernetesServiceDiscoveryEnabledTest.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-kubernetes-starter/src/test/java/org/apache/camel/component/kubernetes/springboot/cloud/KubernetesServiceDiscoveryEnabledTest.java b/platforms/spring-boot/components-starter/camel-kubernetes-starter/src/test/java/org/apache/camel/component/kubernetes/springboot/cloud/KubernetesServiceDiscoveryEnabledTest.java
new file mode 100644
index 0000000..19e4c80
--- /dev/null
+++ b/platforms/spring-boot/components-starter/camel-kubernetes-starter/src/test/java/org/apache/camel/component/kubernetes/springboot/cloud/KubernetesServiceDiscoveryEnabledTest.java
@@ -0,0 +1,65 @@
+/**
+ * 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.kubernetes.springboot.cloud;
+
+import java.util.Map;
+
+import org.apache.camel.cloud.ServiceDiscovery;
+import org.apache.camel.model.cloud.springboot.KubernetesServiceCallServiceDiscoveryConfigurationProperties;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@DirtiesContext
+@SpringBootApplication
+@SpringBootTest(
+ classes = {
+ KubernetesServiceDiscoveryEnabledTest.TestConfiguration.class
+ },
+ properties = {
+ "debug=false",
+ "camel.cloud.kubernetes.service-discovery.enabled=true"
+})
+public class KubernetesServiceDiscoveryEnabledTest {
+ @Autowired
+ ApplicationContext context;
+
+ @Test
+ public void testConfiguration() throws Exception {
+ Map<String, ?> beans;
+
+ beans = context.getBeansOfType(KubernetesServiceCallServiceDiscoveryConfigurationProperties.class);
+ Assert.assertFalse(beans.isEmpty());
+ Assert.assertEquals(1, beans.size());
+
+ beans = context.getBeansOfType(ServiceDiscovery.class);
+ Assert.assertFalse(beans.isEmpty());
+ Assert.assertTrue(beans.containsKey("kubernetes-service-discovery"));
+ }
+
+ @Configuration
+ public static class TestConfiguration {
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/9bab0d08/platforms/spring-boot/components-starter/camel-kubernetes-starter/src/test/resources/logback.xml
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-kubernetes-starter/src/test/resources/logback.xml b/platforms/spring-boot/components-starter/camel-kubernetes-starter/src/test/resources/logback.xml
new file mode 100644
index 0000000..a6fb347
--- /dev/null
+++ b/platforms/spring-boot/components-starter/camel-kubernetes-starter/src/test/resources/logback.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+<configuration>
+
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <!-- encoders are assigned the type
+ ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
+ <encoder>
+ <pattern>%d{HH:mm:ss.SSS} [%-15.15thread] %-5level %-30.30logger - %msg%n</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="FILE" class="ch.qos.logback.core.FileAppender">
+ <encoder>
+ <pattern>%d{HH:mm:ss.SSS} [%-15.15thread] %-5level %-30.30logger - %msg%n</pattern>
+ </encoder>
+ <file>target/camel-kubernetes-starter-test.log</file>
+ </appender>
+
+ <root level="INFO">
+ <appender-ref ref="FILE"/>
+ </root>
+
+</configuration>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/9bab0d08/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootAutoConfigurationMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootAutoConfigurationMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootAutoConfigurationMojo.java
index e31d1ba..76c1057 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootAutoConfigurationMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootAutoConfigurationMojo.java
@@ -230,7 +230,7 @@ public class SpringBootAutoConfigurationMojo extends AbstractMojo {
int pos = model.getJavaType().lastIndexOf(".");
String pkg = model.getJavaType().substring(0, pos) + ".springboot";
- // Generate properties, auto-configuration happens in camel-consul-starter
+ // Generate properties, auto-configuration happens in camel-dns-starter
createOtherModelConfigurationSource(pkg, model, "camel.cloud.dns.service-discovery");
}
@@ -245,6 +245,18 @@ public class SpringBootAutoConfigurationMojo extends AbstractMojo {
// Generate properties, auto-configuration happens in camel-etcd-starter
createOtherModelConfigurationSource(pkg, model, "camel.cloud.etcd.service-discovery");
}
+
+ // Kubernetes
+ json = loadModelJson(files, "kubernetesServiceDiscovery");
+ if (json != null) {
+ OtherModel model = generateOtherModel(json);
+
+ int pos = model.getJavaType().lastIndexOf(".");
+ String pkg = model.getJavaType().substring(0, pos) + ".springboot";
+
+ // Generate properties, auto-configuration happens in camel-kubernetes-starter
+ createOtherModelConfigurationSource(pkg, model, "camel.cloud.kubernetes.service-discovery");
+ }
}
private void createOtherModelConfigurationSource(String packageName, OtherModel model, String propertiesPrefix) throws MojoFailureException {