feat(provider/cf): add apps manager uri to server group model
MODIFY
clouddriver-cloudfoundry/src/main/java/com/netflix/spinnaker/clouddriver/cloudfoundry/client/Applications.java
clouddriver-cloudfoundry/src/main/java/com/netflix/spinnaker/clouddriver/cloudfoundry/client/Applications.java
@@ -50,6 +50,7 @@ import static java.util.stream.Collectors.toSet;
@Slf4j
public class Applications {
private final String account;
+ private final String appsManagerUri;
private final ApplicationService api;
private final Spaces spaces;
@@ -209,6 +210,7 @@ public class Applications {
return CloudFoundryServerGroup.builder()
.account(account)
+ .appsManagerUri(appsManagerUri)
.name(application.getName())
.id(application.getGuid())
.memory(process != null ? process.getMemoryInMb() : null)

MODIFY
clouddriver-cloudfoundry/src/main/java/com/netflix/spinnaker/clouddriver/cloudfoundry/client/HttpCloudFoundryClient.java
clouddriver-cloudfoundry/src/main/java/com/netflix/spinnaker/clouddriver/cloudfoundry/client/HttpCloudFoundryClient.java
@@ -114,7 +114,7 @@ public class HttpCloudFoundryClient implements CloudFoundryClient {
}
}
- public HttpCloudFoundryClient(String account, String apiHost, String user, String password) {
+ public HttpCloudFoundryClient(String account, String appsManagerUri, String apiHost, String user, String password) {
this.apiHost = apiHost;
this.user = user;
this.password = password;
@@ -165,7 +165,7 @@ public class HttpCloudFoundryClient implements CloudFoundryClient {
this.organizations = new Organizations(createService(OrganizationService.class));
this.spaces = new Spaces(createService(SpaceService.class), organizations);
- this.applications = new Applications(account, createService(ApplicationService.class), spaces);
+ this.applications = new Applications(account, appsManagerUri, createService(ApplicationService.class), spaces);
this.domains = new Domains(createService(DomainService.class), organizations);
this.serviceInstances = new ServiceInstances(createService(ServiceInstanceService.class), organizations, spaces);
this.routes = new Routes(account, createService(RouteService.class), applications, domains, spaces);

MODIFY
clouddriver-cloudfoundry/src/main/java/com/netflix/spinnaker/clouddriver/cloudfoundry/config/CloudFoundryConfigurationProperties.java
clouddriver-cloudfoundry/src/main/java/com/netflix/spinnaker/clouddriver/cloudfoundry/config/CloudFoundryConfigurationProperties.java
@@ -46,6 +46,7 @@ public class CloudFoundryConfigurationProperties {
public static class ManagedAccount {
private String name;
private String api;
+ private String appsManagerUri;
private String user;
private String password;
private String environment;

MODIFY
clouddriver-cloudfoundry/src/main/java/com/netflix/spinnaker/clouddriver/cloudfoundry/model/CloudFoundryServerGroup.java
clouddriver-cloudfoundry/src/main/java/com/netflix/spinnaker/clouddriver/cloudfoundry/model/CloudFoundryServerGroup.java
@@ -28,13 +28,13 @@ import com.netflix.spinnaker.clouddriver.model.Image;
import com.netflix.spinnaker.clouddriver.model.ServerGroup;
import com.netflix.spinnaker.clouddriver.names.NamerRegistry;
import com.netflix.spinnaker.moniker.Moniker;
+import io.vavr.collection.HashMap;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Value;
import lombok.experimental.Wither;
import javax.annotation.Nullable;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -54,6 +54,9 @@ public class CloudFoundryServerGroup extends CloudFoundryModel implements Server
@JsonView(Views.Cache.class)
String account;
+ @JsonView(Views.Cache.class)
+ String appsManagerUri;
+
@JsonView(Views.Cache.class)
String name;
@@ -146,11 +149,12 @@ public class CloudFoundryServerGroup extends CloudFoundryModel implements Server
}
public Map getBuildInfo() {
- Map<String, Object> buildInfo = new HashMap<>();
- buildInfo.put("droplet", droplet);
- buildInfo.put("serviceInstances", serviceInstances);
- buildInfo.put("id", id);
- return buildInfo;
+ return HashMap.<Object, Object>of(
+ "appsManagerUri", appsManagerUri,
+ "droplet", droplet,
+ "id", id,
+ "serviceInstances", serviceInstances)
+ .toJavaMap();
}
@Deprecated

MODIFY
clouddriver-cloudfoundry/src/main/java/com/netflix/spinnaker/clouddriver/cloudfoundry/security/CloudFoundryCredentials.java
clouddriver-cloudfoundry/src/main/java/com/netflix/spinnaker/clouddriver/cloudfoundry/security/CloudFoundryCredentials.java
@@ -47,10 +47,10 @@ public class CloudFoundryCredentials implements AccountCredentials<CloudFoundryC
private final CloudFoundryClient credentials;
- public CloudFoundryCredentials(String name, String apiHost, String userName, String password, String environment) {
+ protected CloudFoundryCredentials(String name, String appsManagerUri, String apiHost, String userName, String password, String environment) {
this.name = name;
this.environment = environment;
- this.credentials = new HttpCloudFoundryClient(name, apiHost, userName, password);
+ this.credentials = new HttpCloudFoundryClient(name, appsManagerUri, apiHost, userName, password);
}
public CloudFoundryClient getClient() {

MODIFY
clouddriver-cloudfoundry/src/main/java/com/netflix/spinnaker/clouddriver/cloudfoundry/security/CloudFoundryCredentialsInitializer.java
clouddriver-cloudfoundry/src/main/java/com/netflix/spinnaker/clouddriver/cloudfoundry/security/CloudFoundryCredentialsInitializer.java
@@ -65,6 +65,7 @@ public class CloudFoundryCredentialsInitializer implements CredentialsInitialize
for (CloudFoundryConfigurationProperties.ManagedAccount managedAccount : accountsToAdd) {
CloudFoundryCredentials cloudFoundryAccountCredentials = new CloudFoundryCredentials(
managedAccount.getName(),
+ managedAccount.getAppsManagerUri(),
managedAccount.getApi(),
managedAccount.getUser(),
managedAccount.getPassword(),

MODIFY
clouddriver-cloudfoundry/src/test/java/com/netflix/spinnaker/clouddriver/cloudfoundry/client/ApplicationsTest.java
clouddriver-cloudfoundry/src/test/java/com/netflix/spinnaker/clouddriver/cloudfoundry/client/ApplicationsTest.java
@@ -42,11 +42,11 @@ import static org.mockito.Mockito.*;
class ApplicationsTest {
private ApplicationService applicationService = mock(ApplicationService.class);
private Spaces spaces = mock(Spaces.class);
- private Applications apps = new Applications("pws", applicationService, spaces);
+ private Applications apps = new Applications("pws", "some-apps-man-uri", applicationService, spaces);
@Test
void errorHandling() {
- CloudFoundryClient client = new HttpCloudFoundryClient("pws", "api.run.pivotal.io",
+ CloudFoundryClient client = new HttpCloudFoundryClient("pws", "some.api.uri.example.com", "api.run.pivotal.io",
"baduser", "badpassword");
assertThatThrownBy(() -> client.getApplications().all())
@@ -123,6 +123,7 @@ class ApplicationsTest {
assertThat(cloudFoundryServerGroup).isNotNull();
assertThat(cloudFoundryServerGroup.getId()).isEqualTo("some-app-guid");
assertThat(cloudFoundryServerGroup.getName()).isEqualTo("some-app-name");
+ assertThat(cloudFoundryServerGroup.getAppsManagerUri()).isEqualTo("some-apps-man-uri");
assertThat(cloudFoundryServerGroup.getServiceInstances().size()).isEqualTo(1);
assertThat(cloudFoundryServerGroup.getServiceInstances().get(0).getTags()).containsExactly("tag1", "tag2");
}

MODIFY
clouddriver-cloudfoundry/src/test/java/com/netflix/spinnaker/clouddriver/cloudfoundry/client/HttpCloudFoundryClientTest.java
clouddriver-cloudfoundry/src/test/java/com/netflix/spinnaker/clouddriver/cloudfoundry/client/HttpCloudFoundryClientTest.java
@@ -48,7 +48,7 @@ public class HttpCloudFoundryClientTest {
fail("Should not happen!");
}
- HttpCloudFoundryClient cloudFoundryClient = new HttpCloudFoundryClient("account", "host", "user", "password");
+ HttpCloudFoundryClient cloudFoundryClient = new HttpCloudFoundryClient("account", "uri", "host", "user", "password");
Response response = cloudFoundryClient.createRetryInterceptor(chain);
try {
@@ -73,7 +73,7 @@ public class HttpCloudFoundryClientTest {
fail("Should not happen!");
}
- HttpCloudFoundryClient cloudFoundryClient = new HttpCloudFoundryClient("account", "host", "user", "password");
+ HttpCloudFoundryClient cloudFoundryClient = new HttpCloudFoundryClient("account", "uri", "host", "user", "password");
Response response = cloudFoundryClient.createRetryInterceptor(chain);
try {
@@ -98,7 +98,7 @@ public class HttpCloudFoundryClientTest {
fail("Should not happen!");
}
- HttpCloudFoundryClient cloudFoundryClient = new HttpCloudFoundryClient("account", "host", "user", "password");
+ HttpCloudFoundryClient cloudFoundryClient = new HttpCloudFoundryClient("account", "uri", "host", "user", "password");
Response response = cloudFoundryClient.createRetryInterceptor(chain);
try {

MODIFY
clouddriver-cloudfoundry/src/test/java/com/netflix/spinnaker/clouddriver/cloudfoundry/deploy/converters/DeployCloudFoundryServerGroupAtomicOperationConverterTest.java
clouddriver-cloudfoundry/src/test/java/com/netflix/spinnaker/clouddriver/cloudfoundry/deploy/converters/DeployCloudFoundryServerGroupAtomicOperationConverterTest.java
@@ -62,7 +62,7 @@ class DeployCloudFoundryServerGroupAtomicOperationConverterTest {
}
private final CloudFoundryCredentials cloudFoundryCredentials = new CloudFoundryCredentials(
- "test", "", "", "", "") {
+ "test", "", "", "", "", "") {
public CloudFoundryClient getClient() {
return cloudFoundryClient;
}

MODIFY
clouddriver-cloudfoundry/src/test/java/com/netflix/spinnaker/clouddriver/cloudfoundry/security/CloudFoundryCredentialsTest.java
clouddriver-cloudfoundry/src/test/java/com/netflix/spinnaker/clouddriver/cloudfoundry/security/CloudFoundryCredentialsTest.java
@@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test;
class CloudFoundryCredentialsTest {
@Test
void serialize() throws JsonProcessingException {
- CloudFoundryCredentials creds = new CloudFoundryCredentials("pws", "api.run.pivotal.io", "fakeuser", "fakepasword", "dev");
+ CloudFoundryCredentials creds = new CloudFoundryCredentials("pws", "some.uri.example.com", "api.run.pivotal.io", "fakeuser", "fakepasword", "dev");
new ObjectMapper().writeValueAsString(creds);
}
}

feat(provider/cf): add apps manager uri to server group model

Co-Authored-By: Stu Pollock <spollock@pivotal.io>