feat(provider/cf): add metrics links to SG
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
@@ -51,6 +51,7 @@ import static java.util.stream.Collectors.toSet;
public class Applications {
private final String account;
private final String appsManagerUri;
+ private final String metricsUri;
private final ApplicationService api;
private final Spaces spaces;
@@ -221,9 +222,15 @@ public class Applications {
serverGroupAppManagerUri = appsManagerUri + "/organizations/" + space.getOrganization().getId() + "/spaces/" + space.getId() + "/applications/" + application.getGuid();
}
+ String serverGroupMetricsUri = metricsUri;
+ if (StringUtils.isNotEmpty(metricsUri)){
+ serverGroupMetricsUri = metricsUri + "/apps/" + application.getGuid();
+ }
+
return CloudFoundryServerGroup.builder()
.account(account)
.appsManagerUri(serverGroupAppManagerUri)
+ .metricsUri(serverGroupMetricsUri)
.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 appsManagerUri, String apiHost, String user, String password) {
+ public HttpCloudFoundryClient(String account, String appsManagerUri, String metricsUri, 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, appsManagerUri, createService(ApplicationService.class), spaces);
+ this.applications = new Applications(account, appsManagerUri, metricsUri, 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
@@ -47,6 +47,7 @@ public class CloudFoundryConfigurationProperties {
private String name;
private String api;
private String appsManagerUri;
+ private String metricsUri;
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
@@ -57,6 +57,9 @@ public class CloudFoundryServerGroup extends CloudFoundryModel implements Server
@JsonView(Views.Cache.class)
String appsManagerUri;
+ @JsonView(Views.Cache.class)
+ String metricsUri;
+
@JsonView(Views.Cache.class)
String name;
@@ -159,6 +162,7 @@ public class CloudFoundryServerGroup extends CloudFoundryModel implements Server
public Map getBuildInfo() {
return HashMap.<Object, Object>of(
"appsManagerUri", appsManagerUri,
+ "metricsUri", metricsUri,
"droplet", droplet,
"id", id,
"serviceInstances", serviceInstances)

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;
- protected CloudFoundryCredentials(String name, String appsManagerUri, String apiHost, String userName, String password, String environment) {
+ protected CloudFoundryCredentials(String name, String appsManagerUri, String metricsUri, String apiHost, String userName, String password, String environment) {
this.name = name;
this.environment = environment;
- this.credentials = new HttpCloudFoundryClient(name, appsManagerUri, apiHost, userName, password);
+ this.credentials = new HttpCloudFoundryClient(name, appsManagerUri, metricsUri, 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
@@ -66,6 +66,7 @@ public class CloudFoundryCredentialsInitializer implements CredentialsInitialize
CloudFoundryCredentials cloudFoundryAccountCredentials = new CloudFoundryCredentials(
managedAccount.getName(),
managedAccount.getAppsManagerUri(),
+ managedAccount.getMetricsUri(),
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
@@ -45,12 +45,12 @@ 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", "some-apps-man-uri", applicationService, spaces);
+ private Applications apps = new Applications("pws", "some-apps-man-uri", "some-metrics-uri", applicationService, spaces);
@Test
void errorHandling() {
- CloudFoundryClient client = new HttpCloudFoundryClient("pws", "some.api.uri.example.com", "api.run.pivotal.io",
- "baduser", "badpassword");
+ CloudFoundryClient client = new HttpCloudFoundryClient("pws", "some.api.uri.example.com", "some-metrics-uri",
+ "api.run.pivotal.io", "baduser", "badpassword");
assertThatThrownBy(() -> client.getApplications().all())
.isInstanceOf(CloudFoundryApiException.class);
@@ -127,6 +127,7 @@ class ApplicationsTest {
assertThat(cloudFoundryServerGroup.getId()).isEqualTo("some-app-guid");
assertThat(cloudFoundryServerGroup.getName()).isEqualTo("some-app-name");
assertThat(cloudFoundryServerGroup.getAppsManagerUri()).isEqualTo("some-apps-man-uri/organizations/org-id/spaces/space-id/applications/some-app-guid");
+ assertThat(cloudFoundryServerGroup.getMetricsUri()).isEqualTo("some-metrics-uri/apps/some-app-guid");
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 @@ class HttpCloudFoundryClientTest {
fail("Should not happen!");
}
- HttpCloudFoundryClient cloudFoundryClient = new HttpCloudFoundryClient("account", "uri", "host", "user", "password");
+ HttpCloudFoundryClient cloudFoundryClient = new HttpCloudFoundryClient("account", "appsManUri", "metricsUri","host", "user", "password");
Response response = cloudFoundryClient.createRetryInterceptor(chain);
try {
@@ -73,7 +73,7 @@ class HttpCloudFoundryClientTest {
fail("Should not happen!");
}
- HttpCloudFoundryClient cloudFoundryClient = new HttpCloudFoundryClient("account", "uri", "host", "user", "password");
+ HttpCloudFoundryClient cloudFoundryClient = new HttpCloudFoundryClient("account", "appsManUri", "metricsUri", "host", "user", "password");
Response response = cloudFoundryClient.createRetryInterceptor(chain);
try {
@@ -98,7 +98,7 @@ class HttpCloudFoundryClientTest {
fail("Should not happen!");
}
- HttpCloudFoundryClient cloudFoundryClient = new HttpCloudFoundryClient("account", "uri", "host", "user", "password");
+ HttpCloudFoundryClient cloudFoundryClient = new HttpCloudFoundryClient("account", "appsManUri", "metricsUri", "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
@@ -61,7 +61,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/deploy/converters/DeployCloudFoundryServiceAtomicOperationConverterTest.java
clouddriver-cloudfoundry/src/test/java/com/netflix/spinnaker/clouddriver/cloudfoundry/deploy/converters/DeployCloudFoundryServiceAtomicOperationConverterTest.java
@@ -64,7 +64,7 @@ class DeployCloudFoundryServiceAtomicOperationConverterTest {
}
private final CloudFoundryCredentials cloudFoundryCredentials = new CloudFoundryCredentials(
- "test", "", "", "", "", "") {
+ "test", "", "", "", "", "", "") {
public CloudFoundryClient getClient() {
return cloudFoundryClient;
}

MODIFY
clouddriver-cloudfoundry/src/test/java/com/netflix/spinnaker/clouddriver/cloudfoundry/deploy/converters/ScaleCloudFoundryServerGroupAtomicOperationConverterTest.java
clouddriver-cloudfoundry/src/test/java/com/netflix/spinnaker/clouddriver/cloudfoundry/deploy/converters/ScaleCloudFoundryServerGroupAtomicOperationConverterTest.java
@@ -59,7 +59,7 @@ class ScaleCloudFoundryServerGroupAtomicOperationConverterTest {
}
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", "some.uri.example.com", "api.run.pivotal.io", "fakeuser", "fakepasword", "dev");
+ CloudFoundryCredentials creds = new CloudFoundryCredentials("pws", "some.uri.example.com", "some.uri.example.com", "api.run.pivotal.io", "fakeuser", "fakepasword", "dev");
new ObjectMapper().writeValueAsString(creds);
}
}

feat(provider/cf): add metrics links to SG (#3210)