Improve Cloud Foundry Java Client auto-configuration.
An organization and space are not required by all CF Java Client operations. Those properties should be optional to the client-autoconfiguration. The CF target URL should default to the CF an application is running on when it is deployed to CF.
This commit is contained in:
@@ -20,7 +20,6 @@ import org.cloudfoundry.operations.CloudFoundryOperations;
|
||||
import org.cloudfoundry.operations.applications.ApplicationDetail;
|
||||
import org.cloudfoundry.operations.applications.ApplicationSummary;
|
||||
import org.cloudfoundry.operations.applications.InstanceDetail;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.client.DefaultServiceInstance;
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
import org.springframework.cloud.client.discovery.DiscoveryClient;
|
||||
@@ -44,10 +43,6 @@ public class CloudFoundryDiscoveryClient implements DiscoveryClient {
|
||||
|
||||
private final String description = "Cloud Foundry " + DiscoveryClient.class.getName() + " implementation";
|
||||
|
||||
@Value("${vcap.application.name:${spring.application.name:application}}")
|
||||
private String vcapApplicationName = "application";
|
||||
|
||||
|
||||
CloudFoundryDiscoveryClient(CloudFoundryOperations cloudFoundryOperations,
|
||||
CloudFoundryService svc) {
|
||||
this.cloudFoundryService = svc;
|
||||
@@ -86,8 +81,7 @@ public class CloudFoundryDiscoveryClient implements DiscoveryClient {
|
||||
|
||||
@Override
|
||||
public List<String> getServices() {
|
||||
return this
|
||||
.cloudFoundryOperations
|
||||
return this.cloudFoundryOperations
|
||||
.applications()
|
||||
.list()
|
||||
.map(ApplicationSummary::getName)
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.springframework.cloud.cloudfoundry.discovery;
|
||||
|
||||
import org.cloudfoundry.operations.CloudFoundryOperations;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
@@ -35,9 +34,6 @@ import org.springframework.context.annotation.Configuration;
|
||||
@EnableConfigurationProperties(CloudFoundryDiscoveryProperties.class)
|
||||
public class CloudFoundryDiscoveryClientConfiguration {
|
||||
|
||||
@Autowired
|
||||
private CloudFoundryDiscoveryProperties discovery;
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(CloudFoundryDiscoveryClient.class)
|
||||
public CloudFoundryDiscoveryClient cloudFoundryDiscoveryClient(
|
||||
|
||||
@@ -30,12 +30,11 @@ import com.netflix.loadbalancer.AbstractServerList;
|
||||
* @author Josh Long
|
||||
*/
|
||||
public class CloudFoundryServerList extends AbstractServerList<CloudFoundryServer> {
|
||||
|
||||
private String serviceId;
|
||||
|
||||
private final CloudFoundryService cloudFoundryService;
|
||||
private final CloudFoundryDiscoveryProperties properties;
|
||||
|
||||
private IClientConfig clientConfig;
|
||||
private String serviceId;
|
||||
|
||||
CloudFoundryServerList(CloudFoundryService svc, CloudFoundryDiscoveryProperties properties) {
|
||||
this.cloudFoundryService = svc;
|
||||
@@ -45,17 +44,17 @@ public class CloudFoundryServerList extends AbstractServerList<CloudFoundryServe
|
||||
@Override
|
||||
public void initWithNiwsConfig(IClientConfig clientConfig) {
|
||||
this.clientConfig = clientConfig;
|
||||
this.serviceId = this.clientConfig.getClientName();
|
||||
this.serviceId = clientConfig.getClientName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CloudFoundryServer> getInitialListOfServers() {
|
||||
return this.cloudFoundryServers();
|
||||
return cloudFoundryServers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CloudFoundryServer> getUpdatedListOfServers() {
|
||||
return this.cloudFoundryServers();
|
||||
return cloudFoundryServers();
|
||||
}
|
||||
|
||||
private List<CloudFoundryServer> cloudFoundryServers() {
|
||||
@@ -69,7 +68,7 @@ public class CloudFoundryServerList extends AbstractServerList<CloudFoundryServe
|
||||
|
||||
final int port;
|
||||
if (secure != null && secure && securePort != null) {
|
||||
port = securePort;
|
||||
port = securePort;
|
||||
} else if (nonSecurePort != null) {
|
||||
port = nonSecurePort;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user