Commit 94c73da9 by Spencer Gibb

Use new InetUtils bean to determin nic.

Allows for more fine-grained configuration of what to ignore.
parent 03f6d12e
......@@ -41,6 +41,7 @@ import org.springframework.cloud.client.actuator.HasFeatures;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.client.discovery.noop.NoopDiscoveryClientAutoConfiguration;
import org.springframework.cloud.context.scope.refresh.RefreshScope;
import org.springframework.cloud.util.InetUtils;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
......@@ -96,8 +97,8 @@ public class EurekaClientAutoConfiguration {
@Bean
@ConditionalOnMissingBean(value = EurekaInstanceConfig.class, search = SearchStrategy.CURRENT)
public EurekaInstanceConfigBean eurekaInstanceConfigBean() {
EurekaInstanceConfigBean instance = new EurekaInstanceConfigBean();
public EurekaInstanceConfigBean eurekaInstanceConfigBean(InetUtils inetUtils) {
EurekaInstanceConfigBean instance = new EurekaInstanceConfigBean(inetUtils);
instance.setNonSecurePort(this.nonSecurePort);
instance.setInstanceId(getDefaultInstanceId(this.env));
if (this.managementPort != this.nonSecurePort && this.managementPort != 0) {
......
......@@ -21,14 +21,13 @@ import java.util.Map;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.util.InetUtils;
import org.springframework.cloud.util.InetUtils.HostInfo;
import com.netflix.appinfo.DataCenterInfo;
import com.netflix.appinfo.InstanceInfo.InstanceStatus;
import com.netflix.appinfo.MyDataCenterInfo;
import static org.springframework.cloud.util.InetUtils.getFirstNonLoopbackHostInfo;
import lombok.AccessLevel;
import lombok.Data;
import lombok.Getter;
......@@ -44,7 +43,11 @@ public class EurekaInstanceConfigBean implements CloudEurekaInstanceConfig {
@Getter(AccessLevel.PRIVATE)
@Setter(AccessLevel.PRIVATE)
private HostInfo hostInfo = getFirstNonLoopbackHostInfo();
private HostInfo hostInfo;
@Getter(AccessLevel.PRIVATE)
@Setter(AccessLevel.PRIVATE)
private InetUtils inetUtils;
@Value("${spring.application.name:unknown}")
private String appname = "unknown";
......@@ -79,7 +82,7 @@ public class EurekaInstanceConfigBean implements CloudEurekaInstanceConfig {
private DataCenterInfo dataCenterInfo = new MyDataCenterInfo(
DataCenterInfo.Name.MyOwn);
private String ipAddress = this.hostInfo.getIpAddress();
private String ipAddress;
private String statusPageUrlPath = "/info";
......@@ -97,7 +100,7 @@ public class EurekaInstanceConfigBean implements CloudEurekaInstanceConfig {
private String namespace = "eureka";
private String hostname = this.hostInfo.getHostname();
private String hostname;
private boolean preferIpAddress = false;
......@@ -107,6 +110,15 @@ public class EurekaInstanceConfigBean implements CloudEurekaInstanceConfig {
return getHostName(false);
}
private EurekaInstanceConfigBean() {}
public EurekaInstanceConfigBean(InetUtils inetUtils) {
this.inetUtils = inetUtils;
this.hostInfo = this.inetUtils.findFirstNonLoopbackHostInfo();
this.ipAddress = this.hostInfo.getIpAddress();
this.hostname = this.hostInfo.getHostname();
}
@Override
public String getInstanceId() {
if (this.instanceId == null && this.metadataMap != null) {
......@@ -129,7 +141,7 @@ public class EurekaInstanceConfigBean implements CloudEurekaInstanceConfig {
public String getHostName(boolean refresh) {
if (refresh) {
boolean originalOverride = this.hostInfo.override;
this.hostInfo = getFirstNonLoopbackHostInfo();
this.hostInfo = this.inetUtils.findFirstNonLoopbackHostInfo();
this.hostInfo.setOverride(originalOverride);
this.ipAddress = this.hostInfo.getIpAddress();
if (!this.hostInfo.override) {
......
......@@ -24,6 +24,7 @@ import org.springframework.boot.test.EnvironmentTestUtils;
import org.springframework.cloud.config.client.ConfigClientProperties;
import org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration;
import org.springframework.cloud.netflix.eureka.EurekaDiscoveryClientConfiguration;
import org.springframework.cloud.util.UtilAutoConfiguration;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
......@@ -75,7 +76,8 @@ public class DiscoveryClientConfigServiceAutoConfigurationTests {
private void setup(String... env) {
AnnotationConfigApplicationContext parent = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(parent, env);
parent.register(PropertyPlaceholderAutoConfiguration.class,
parent.register(UtilAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class,
DiscoveryClientConfigServiceBootstrapConfiguration.class,
EnvironmentKnobbler.class, ConfigClientProperties.class);
parent.refresh();
......
......@@ -27,6 +27,7 @@ import org.mockito.Mockito;
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.test.EnvironmentTestUtils;
import org.springframework.cloud.config.client.ConfigClientProperties;
import org.springframework.cloud.util.UtilAutoConfiguration;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import com.netflix.appinfo.InstanceInfo;
......@@ -124,7 +125,8 @@ public class DiscoveryClientConfigServiceBootstrapConfigurationTests {
EnvironmentTestUtils.addEnvironment(this.context, env);
this.context.getDefaultListableBeanFactory().registerSingleton(
"eurekaClient", this.client);
this.context.register(PropertyPlaceholderAutoConfiguration.class,
this.context.register(UtilAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class,
DiscoveryClientConfigServiceBootstrapConfiguration.class,
ConfigClientProperties.class);
this.context.refresh();
......
......@@ -23,6 +23,7 @@ import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfigurati
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.EnvironmentTestUtils;
import org.springframework.cloud.autoconfigure.RefreshAutoConfiguration;
import org.springframework.cloud.util.UtilAutoConfiguration;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
......@@ -66,8 +67,8 @@ public class EurekaClientAutoConfigurationTests {
@Test
public void nonSecurePort() {
testNonSecurePort("PORT");
assertEquals("eurekaClient",
this.context.getBeanDefinition("eurekaClient").getFactoryMethodName());
assertEquals("eurekaClient", this.context.getBeanDefinition("eurekaClient")
.getFactoryMethodName());
}
@Test
......@@ -77,8 +78,8 @@ public class EurekaClientAutoConfigurationTests {
setupContext(RefreshAutoConfiguration.class);
EurekaInstanceConfigBean instance = this.context
.getBean(EurekaInstanceConfigBean.class);
assertTrue("Wrong status page: " + instance.getStatusPageUrl(),
instance.getStatusPageUrl().contains("9999"));
assertTrue("Wrong status page: " + instance.getStatusPageUrl(), instance
.getStatusPageUrl().contains("9999"));
}
@Test
......@@ -88,15 +89,15 @@ public class EurekaClientAutoConfigurationTests {
setupContext(RefreshAutoConfiguration.class);
EurekaInstanceConfigBean instance = this.context
.getBean(EurekaInstanceConfigBean.class);
assertTrue("Wrong status page: " + instance.getStatusPageUrl(),
instance.getStatusPageUrl().contains("foo"));
assertTrue("Wrong status page: " + instance.getStatusPageUrl(), instance
.getStatusPageUrl().contains("foo"));
}
@Test
public void refreshScopedBeans() {
setupContext(RefreshAutoConfiguration.class);
assertEquals(ScopedProxyFactoryBean.class.getName(),
this.context.getBeanDefinition("eurekaClient").getBeanClassName());
assertEquals(ScopedProxyFactoryBean.class.getName(), this.context
.getBeanDefinition("eurekaClient").getBeanClassName());
assertEquals(ScopedProxyFactoryBean.class.getName(), this.context
.getBeanDefinition("eurekaApplicationInfoManager").getBeanClassName());
}
......@@ -113,7 +114,7 @@ public class EurekaClientAutoConfigurationTests {
@Configuration
@EnableConfigurationProperties
@Import(EurekaClientAutoConfiguration.class)
@Import({ UtilAutoConfiguration.class, EurekaClientAutoConfiguration.class })
protected static class TestConfiguration {
}
......
......@@ -16,25 +16,28 @@
package org.springframework.cloud.netflix.eureka;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.springframework.boot.test.EnvironmentTestUtils.addEnvironment;
import static org.springframework.cloud.util.InetUtils.getFirstNonLoopbackHostInfo;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.util.InetUtils;
import org.springframework.cloud.util.InetUtilsProperties;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.util.ReflectionTestUtils;
import com.netflix.appinfo.InstanceInfo.InstanceStatus;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.springframework.boot.test.EnvironmentTestUtils.addEnvironment;
/**
* @author Dave Syer
* @author Spencer Gibb
*/
public class EurekaInstanceConfigBeanTests {
......@@ -43,7 +46,8 @@ public class EurekaInstanceConfigBeanTests {
@Before
public void init() {
this.hostName = getFirstNonLoopbackHostInfo().getHostname();
this.hostName = new InetUtils(new InetUtilsProperties())
.findFirstNonLoopbackHostInfo().getHostname();
}
@After
......@@ -148,8 +152,12 @@ public class EurekaInstanceConfigBeanTests {
}
@Configuration
@EnableConfigurationProperties(EurekaInstanceConfigBean.class)
@EnableConfigurationProperties
protected static class TestConfiguration {
@Bean
public EurekaInstanceConfigBean eurekaInstanceConfigBean() {
return new EurekaInstanceConfigBean(new InetUtils(new InetUtilsProperties()));
}
}
......
package org.springframework.cloud.netflix.eureka;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.springframework.boot.test.EnvironmentTestUtils.addEnvironment;
import static org.springframework.cloud.util.InetUtils.getFirstNonLoopbackHostInfo;
import org.junit.Test;
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.util.InetUtils;
import org.springframework.cloud.util.InetUtilsProperties;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.netflix.appinfo.InstanceInfo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.springframework.boot.test.EnvironmentTestUtils.addEnvironment;
public class InstanceInfoFactoryTests {
private AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
@Test
public void instanceIdIsHostNameByDefault() {
InstanceInfo instanceInfo = setupInstance();
assertEquals(getFirstNonLoopbackHostInfo().getHostname(),
instanceInfo.getId());
assertEquals(new InetUtils(new InetUtilsProperties())
.findFirstNonLoopbackHostInfo().getHostname(), instanceInfo.getId());
}
@Test
public void instanceIdIsIpWhenIpPreferred() throws Exception {
InstanceInfo instanceInfo = setupInstance("eureka.instance.preferIpAddress:true");
assertTrue(instanceInfo.getId().matches(
"(\\d+\\.){3}\\d+"));
assertTrue(instanceInfo.getId().matches("(\\d+\\.){3}\\d+"));
}
@Test
......@@ -53,7 +54,11 @@ public class InstanceInfoFactoryTests {
}
@Configuration
@EnableConfigurationProperties(EurekaInstanceConfigBean.class)
@EnableConfigurationProperties
protected static class TestConfiguration {
@Bean
public EurekaInstanceConfigBean eurekaInstanceConfigBean() {
return new EurekaInstanceConfigBean(new InetUtils(new InetUtilsProperties()));
}
}
}
......@@ -27,6 +27,7 @@ import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfigurati
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.cloud.netflix.archaius.ArchaiusAutoConfiguration;
import org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration;
import org.springframework.cloud.util.UtilAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
......@@ -80,7 +81,7 @@ public class RibbonClientPreprocessorOverridesIntegrationTests {
@RibbonClient(name = "foo", configuration = FooConfiguration.class),
@RibbonClient(name = "bar", configuration = BarConfiguration.class)
})
@Import({ PropertyPlaceholderAutoConfiguration.class,
@Import({ UtilAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class,
ArchaiusAutoConfiguration.class, EurekaClientAutoConfiguration.class,
RibbonAutoConfiguration.class})
protected static class TestConfiguration {
......
......@@ -24,6 +24,7 @@ import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.cloud.netflix.archaius.ArchaiusAutoConfiguration;
import org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration;
import org.springframework.cloud.netflix.ribbon.RibbonClientsPreprocessorIntegrationTests.TestConfiguration;
import org.springframework.cloud.util.UtilAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
......@@ -67,7 +68,7 @@ public class RibbonClientsPreprocessorIntegrationTests {
@Configuration
@RibbonClients(@RibbonClient(name = "foo", configuration = FooConfiguration.class))
@Import({ PropertyPlaceholderAutoConfiguration.class,
@Import({ UtilAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class,
ArchaiusAutoConfiguration.class, EurekaClientAutoConfiguration.class,
RibbonAutoConfiguration.class})
protected static class TestConfiguration {
......
......@@ -28,6 +28,8 @@ import org.junit.Test;
import org.springframework.cloud.netflix.eureka.EurekaClientConfigBean;
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean;
import org.springframework.cloud.netflix.ribbon.SpringClientFactory;
import org.springframework.cloud.util.InetUtils;
import org.springframework.cloud.util.InetUtilsProperties;
import com.netflix.config.ConfigurationManager;
import com.netflix.config.DeploymentContext.ContextKey;
......@@ -52,7 +54,7 @@ public class EurekaRibbonClientConfigurationTests {
@Ignore
public void basicConfigurationCreatedForLoadBalancer() {
EurekaClientConfigBean client = new EurekaClientConfigBean();
EurekaInstanceConfigBean configBean = new EurekaInstanceConfigBean();
EurekaInstanceConfigBean configBean = getEurekaInstanceConfigBean();
client.getAvailabilityZones().put(client.getRegion(), "foo");
SpringClientFactory clientFactory = new SpringClientFactory();
EurekaRibbonClientConfiguration clientPreprocessor = new EurekaRibbonClientConfiguration(
......@@ -67,10 +69,14 @@ public class EurekaRibbonClientConfigurationTests {
ConfigurationManager.getDeploymentContext().getValue(ContextKey.zone));
}
private EurekaInstanceConfigBean getEurekaInstanceConfigBean() {
return new EurekaInstanceConfigBean(new InetUtils(new InetUtilsProperties()));
}
@Test
public void testSetProp() {
EurekaClientConfigBean client = new EurekaClientConfigBean();
EurekaInstanceConfigBean configBean = new EurekaInstanceConfigBean();
EurekaInstanceConfigBean configBean = getEurekaInstanceConfigBean();
EurekaRibbonClientConfiguration preprocessor = new EurekaRibbonClientConfiguration(
client, "myService", configBean, false);
String serviceId = "myService";
......@@ -88,7 +94,7 @@ public class EurekaRibbonClientConfigurationTests {
@Test
public void testDefaultZone() {
EurekaClientConfigBean client = new EurekaClientConfigBean();
EurekaInstanceConfigBean configBean = new EurekaInstanceConfigBean();
EurekaInstanceConfigBean configBean = getEurekaInstanceConfigBean();
EurekaRibbonClientConfiguration preprocessor = new EurekaRibbonClientConfiguration(
client, "myService", configBean, false);
preprocessor.preprocess();
......@@ -98,7 +104,7 @@ public class EurekaRibbonClientConfigurationTests {
@Test
public void testApproximateZone() {
EurekaClientConfigBean client = new EurekaClientConfigBean();
EurekaInstanceConfigBean configBean = new EurekaInstanceConfigBean();
EurekaInstanceConfigBean configBean = getEurekaInstanceConfigBean();
configBean.setHostname("this.is.a.test.com");
EurekaRibbonClientConfiguration preprocessor = new EurekaRibbonClientConfiguration(
client, "myService", configBean, true);
......
......@@ -28,6 +28,7 @@ import org.springframework.cloud.netflix.ribbon.RibbonClient;
import org.springframework.cloud.netflix.ribbon.ServerIntrospector;
import org.springframework.cloud.netflix.ribbon.SpringClientFactory;
import org.springframework.cloud.netflix.ribbon.eureka.EurekaRibbonClientPreprocessorIntegrationTests.TestConfiguration;
import org.springframework.cloud.util.UtilAutoConfiguration;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.test.annotation.DirtiesContext;
......@@ -77,7 +78,7 @@ public class EurekaRibbonClientPreprocessorIntegrationTests {
@Configuration
@RibbonClient("foo")
@Import({ PropertyPlaceholderAutoConfiguration.class,
@Import({ UtilAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class,
ArchaiusAutoConfiguration.class, RibbonAutoConfiguration.class,
EurekaClientAutoConfiguration.class, RibbonEurekaAutoConfiguration.class })
protected static class TestConfiguration {
......
......@@ -16,8 +16,6 @@
package org.springframework.cloud.netflix.ribbon.eureka;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -30,6 +28,8 @@ import org.springframework.cloud.netflix.ribbon.RibbonClient;
import org.springframework.cloud.netflix.ribbon.SpringClientFactory;
import org.springframework.cloud.netflix.ribbon.ZonePreferenceServerListFilter;
import org.springframework.cloud.netflix.ribbon.eureka.RibbonClientPreprocessorIntegrationTests.TestConfiguration;
import org.springframework.cloud.util.InetUtils;
import org.springframework.cloud.util.InetUtilsProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
......@@ -40,6 +40,8 @@ import com.netflix.loadbalancer.Server;
import com.netflix.loadbalancer.ZoneAvoidanceRule;
import com.netflix.loadbalancer.ZoneAwareLoadBalancer;
import static org.junit.Assert.assertEquals;
/**
* @author Dave Syer
*/
......@@ -87,7 +89,8 @@ public class RibbonClientPreprocessorIntegrationTests {
@Configuration
@RibbonClient(name = "foo", configuration = FooConfiguration.class)
@Import({ PropertyPlaceholderAutoConfiguration.class,
ArchaiusAutoConfiguration.class, RibbonAutoConfiguration.class, RibbonEurekaAutoConfiguration.class })
ArchaiusAutoConfiguration.class, RibbonAutoConfiguration.class,
RibbonEurekaAutoConfiguration.class })
protected static class TestConfiguration {
}
......@@ -102,7 +105,8 @@ public class RibbonClientPreprocessorIntegrationTests {
@Bean
public EurekaInstanceConfigBean getEurekaInstanceConfigBean() {
EurekaInstanceConfigBean bean = new EurekaInstanceConfigBean();
EurekaInstanceConfigBean bean = new EurekaInstanceConfigBean(new InetUtils(
new InetUtilsProperties()));
return bean;
}
}
......
......@@ -16,32 +16,34 @@
package org.springframework.cloud.netflix.ribbon.test;
import com.netflix.client.config.IClientConfig;
import com.netflix.loadbalancer.BestAvailableRule;
import com.netflix.loadbalancer.ConfigurationBasedServerList;
import com.netflix.loadbalancer.IPing;
import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.PingUrl;
import com.netflix.loadbalancer.Server;
import com.netflix.loadbalancer.ServerList;
import com.netflix.loadbalancer.ServerListSubsetFilter;
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
import org.springframework.cloud.netflix.archaius.ArchaiusAutoConfiguration;
import org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration;
import org.springframework.cloud.netflix.ribbon.RibbonAutoConfiguration;
import org.springframework.cloud.netflix.ribbon.RibbonClients;
import org.springframework.cloud.netflix.ribbon.eureka.RibbonEurekaAutoConfiguration;
import org.springframework.cloud.util.UtilAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import com.netflix.client.config.IClientConfig;
import com.netflix.loadbalancer.BestAvailableRule;
import com.netflix.loadbalancer.ConfigurationBasedServerList;
import com.netflix.loadbalancer.IPing;
import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.PingUrl;
import com.netflix.loadbalancer.Server;
import com.netflix.loadbalancer.ServerList;
import com.netflix.loadbalancer.ServerListSubsetFilter;
/**
* @author Spencer Gibb
*/
@Configuration
@Import({ PropertyPlaceholderAutoConfiguration.class,
ArchaiusAutoConfiguration.class, EurekaClientAutoConfiguration.class,
RibbonAutoConfiguration.class, RibbonEurekaAutoConfiguration.class})
@Import({ PropertyPlaceholderAutoConfiguration.class, ArchaiusAutoConfiguration.class,
UtilAutoConfiguration.class, EurekaClientAutoConfiguration.class,
RibbonAutoConfiguration.class, RibbonEurekaAutoConfiguration.class })
@RibbonClients(defaultConfiguration = DefaultRibbonConfig.class)
public class RibbonClientDefaultConfigurationTestsConfig {
......@@ -52,7 +54,6 @@ public class RibbonClientDefaultConfigurationTestsConfig {
}
}
@Configuration
class DefaultRibbonConfig {
......
......@@ -23,6 +23,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.client.actuator.HasFeatures;
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean;
import org.springframework.cloud.util.InetUtils;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
......@@ -53,6 +54,9 @@ public class SidecarConfiguration {
@Autowired
private SidecarProperties sidecarProperties;
@Autowired
private InetUtils inetUtils;
@Value("${server.port:${SERVER_PORT:${PORT:8080}}}")
private int serverPort = 8080;
......@@ -61,7 +65,7 @@ public class SidecarConfiguration {
@Bean
public EurekaInstanceConfigBean eurekaInstanceConfigBean() {
EurekaInstanceConfigBean config = new EurekaInstanceConfigBean();
EurekaInstanceConfigBean config = new EurekaInstanceConfigBean(inetUtils);
int port = this.sidecarProperties.getPort();
config.setNonSecurePort(port);
String scheme = config.getSecurePortEnabled() ? "https" : "http";
......
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