From 660dabdf9cf3642ee1010baf82b98549a5bbeac1 Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Fri, 29 Apr 2016 13:49:13 +0100 Subject: [PATCH] More detail on credentials for discovery --- docs/src/main/asciidoc/intro.adoc | 4 ++-- docs/src/main/asciidoc/spring-cloud-cloudfoundry.adoc | 5 +++++ .../discovery/CloudFoundryDiscoveryClientConfiguration.java | 3 ++- .../discovery/CloudFoundryDiscoveryProperties.java | 2 ++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/docs/src/main/asciidoc/intro.adoc b/docs/src/main/asciidoc/intro.adoc index 23046cf..96ebf97 100644 --- a/docs/src/main/asciidoc/intro.adoc +++ b/docs/src/main/asciidoc/intro.adoc @@ -16,5 +16,5 @@ implementation of Spring Cloud Commons `DiscoveryClient` so you can `@EnableDiscoveryClient` and provide your credentials as `spring.cloud.cloudfoundry.discovery.[email,password]` and then you can use the `DiscoveryClient` directly or via a `LoadBalancerClient` -(also `*.url` if you are not connecting to [Pivotal Web -Services](https://run.pivotal.io)). \ No newline at end of file +(also `*.url` if you are not connecting to +https://run.pivotal.io[Pivotal Web Services]). \ No newline at end of file diff --git a/docs/src/main/asciidoc/spring-cloud-cloudfoundry.adoc b/docs/src/main/asciidoc/spring-cloud-cloudfoundry.adoc index 9521f42..22d1464 100644 --- a/docs/src/main/asciidoc/spring-cloud-cloudfoundry.adoc +++ b/docs/src/main/asciidoc/spring-cloud-cloudfoundry.adoc @@ -9,6 +9,11 @@ the fact that it has to get an access token from Cloud Foundry. include::quickstart.adoc[] +The `DiscoveryClient` can lists all the apps in a space, according to +the credentials it is authenticated with, where the space defaults to +the one the client is running in (if any). If neither org nor space +are configured, they default per the user's profile in Cloud Foundry. + == Single Sign On NOTE: All of the OAuth2 SSO and resource server features moved to Spring Boot diff --git a/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryDiscoveryClientConfiguration.java b/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryDiscoveryClientConfiguration.java index c9130d9..669673b 100644 --- a/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryDiscoveryClientConfiguration.java +++ b/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryDiscoveryClientConfiguration.java @@ -29,6 +29,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.env.Environment; +import org.springframework.util.StringUtils; /** * @author Josh Long @@ -54,7 +55,7 @@ public class CloudFoundryDiscoveryClientConfiguration { public CloudFoundryClient cloudFoundryClient(CloudCredentials cc) throws MalformedURLException { CloudFoundryClient cloudFoundryClient; - if (this.discovery.getOrg() != null && this.discovery.getSpace() != null) { + if (StringUtils.hasText(this.discovery.getOrg()) && StringUtils.hasText(this.discovery.getSpace())) { cloudFoundryClient = new CloudFoundryClient(cc, URI.create(this.discovery.getUrl()).toURL(), this.discovery.getOrg(), this.discovery.getSpace()); diff --git a/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryDiscoveryProperties.java b/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryDiscoveryProperties.java index 87e0507..69ae0c9 100644 --- a/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryDiscoveryProperties.java +++ b/spring-cloud-cloudfoundry-discovery/src/main/java/org/springframework/cloud/cloudfoundry/discovery/CloudFoundryDiscoveryProperties.java @@ -16,6 +16,7 @@ package org.springframework.cloud.cloudfoundry.discovery; +import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.context.properties.ConfigurationProperties; /** @@ -47,6 +48,7 @@ public class CloudFoundryDiscoveryProperties { /** * Space name to authenticate with (default to user's default). */ + @Value("${vcap.application.space_name:}") private String space; /**