Commit 614ec44c by Spencer Gibb

update sidecare enabled property, make eureka portion of config conditional on…

update sidecare enabled property, make eureka portion of config conditional on eureka on classpath so other DiscoveryClient impls can use it.
parent d7898297
......@@ -16,33 +16,43 @@
package org.springframework.cloud.netflix.sidecar;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.netflix.discovery.EurekaClientConfig;
/**
* @author Spencer Gibb
*/
@Configuration
@EnableConfigurationProperties
@ConditionalOnProperty(value = "sidecar.enabled", matchIfMissing = true)
@ConditionalOnProperty(value = "spring.cloud.netflix.sidecar.enabled", matchIfMissing = true)
public class SidecarConfiguration {
@Value("${server.port:${SERVER_PORT:${PORT:8080}}}")
private int serverPort = 8080;
@Bean
public SidecarProperties sidecarProperties() {
return new SidecarProperties();
}
@Configuration
@ConditionalOnClass(EurekaClientConfig.class)
protected static class EurekaInstanceConfigBeanConfiguration {
@Autowired
private SidecarProperties sidecarProperties;
@Value("${server.port:${SERVER_PORT:${PORT:8080}}}")
private int serverPort = 8080;
@Bean
public EurekaInstanceConfigBean eurekaInstanceConfigBean() {
EurekaInstanceConfigBean config = new EurekaInstanceConfigBean();
int port = sidecarProperties().getPort();
int port = sidecarProperties.getPort();
config.setNonSecurePort(port);
String scheme = config.getSecurePortEnabled() ? "https" : "http";
config.setStatusPageUrl(scheme + "://" + config.getHostname() + ":"
......@@ -53,6 +63,7 @@ public class SidecarConfiguration {
+ config.getHomePageUrlPath());
return config;
}
}
@Bean
public LocalApplicationHealthIndicator localApplicationHealthIndicator() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment