fix(cf): allow results per page to be configurable
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
@@ -62,6 +62,7 @@ public class Applications {
private final String metricsUri;
private final ApplicationService api;
private final Spaces spaces;
+ private final Integer resultsPerPage;
private final LoadingCache<String, CloudFoundryServerGroup> serverGroupCache =
CacheBuilder.newBuilder()
@@ -95,7 +96,7 @@ public class Applications {
public List<CloudFoundryApplication> all() {
List<Application> newCloudFoundryAppList =
- collectPages("applications", page -> api.all(page, 500, null, null));
+ collectPages("applications", page -> api.all(page, resultsPerPage, null, null));
// Evict Records from `cache` that are no longer in the foundation
List<String> availableAppIds =

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
@@ -180,7 +180,8 @@ public class HttpCloudFoundryClient implements CloudFoundryClient {
String apiHost,
String user,
String password,
- boolean skipSslValidation) {
+ boolean skipSslValidation,
+ Integer resultsPerPage) {
this.apiHost = apiHost;
this.user = user;
this.password = password;
@@ -209,7 +210,12 @@ public class HttpCloudFoundryClient implements CloudFoundryClient {
this.spaces = new Spaces(createService(SpaceService.class), organizations);
this.applications =
new Applications(
- account, appsManagerUri, metricsUri, createService(ApplicationService.class), spaces);
+ account,
+ appsManagerUri,
+ metricsUri,
+ createService(ApplicationService.class),
+ spaces,
+ resultsPerPage);
this.domains = new Domains(createService(DomainService.class), organizations);
this.serviceInstances =
new ServiceInstances(
@@ -218,7 +224,13 @@ public class HttpCloudFoundryClient implements CloudFoundryClient {
organizations,
spaces);
this.routes =
- new Routes(account, createService(RouteService.class), applications, domains, spaces);
+ new Routes(
+ account,
+ createService(RouteService.class),
+ applications,
+ domains,
+ spaces,
+ resultsPerPage);
this.serviceKeys = new ServiceKeys(createService(ServiceKeyService.class), spaces);
this.tasks = new Tasks(createService(TaskService.class));

MODIFY
clouddriver-cloudfoundry/src/main/java/com/netflix/spinnaker/clouddriver/cloudfoundry/client/Routes.java
clouddriver-cloudfoundry/src/main/java/com/netflix/spinnaker/clouddriver/cloudfoundry/client/Routes.java
@@ -56,6 +56,7 @@ public class Routes {
private final Applications applications;
private final Domains domains;
private final Spaces spaces;
+ private final Integer resultsPerPage;
private LoadingCache<String, List<RouteMapping>> routeMappings =
CacheBuilder.newBuilder()
@@ -143,7 +144,7 @@ public class Routes {
public List<CloudFoundryLoadBalancer> all() throws CloudFoundryApiException {
List<Resource<Route>> routeResources =
- collectPageResources("routes", pg -> api.all(pg, 500, null));
+ collectPageResources("routes", pg -> api.all(pg, resultsPerPage, null));
List<CloudFoundryLoadBalancer> loadBalancers = new ArrayList<>(routeResources.size());
for (Resource<Route> routeResource : routeResources) {
loadBalancers.add(map(routeResource));

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
@@ -60,5 +60,6 @@ public class CloudFoundryConfigurationProperties implements DisposableBean {
private String password;
private String environment;
private boolean skipSslValidation;
+ private Integer resultsPerPage;
}
}

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
@@ -51,6 +51,8 @@ public class CloudFoundryCredentials implements AccountCredentials<CloudFoundryC
@Deprecated private final List<String> requiredGroupMembership = Collections.emptyList();
private final boolean skipSslValidation;
+ @Nullable private final Integer resultsPerPage;
+
private CloudFoundryClient credentials;
public CloudFoundryCredentials(
@@ -61,7 +63,8 @@ public class CloudFoundryCredentials implements AccountCredentials<CloudFoundryC
String userName,
String password,
String environment,
- boolean skipSslValidation) {
+ boolean skipSslValidation,
+ Integer resultsPerPage) {
this.name = name;
this.appsManagerUri = appsManagerUri;
this.metricsUri = metricsUri;
@@ -70,13 +73,21 @@ public class CloudFoundryCredentials implements AccountCredentials<CloudFoundryC
this.password = password;
this.environment = Optional.ofNullable(environment).orElse("dev");
this.skipSslValidation = skipSslValidation;
+ this.resultsPerPage = Optional.ofNullable(resultsPerPage).orElse(500);
}
public CloudFoundryClient getCredentials() {
if (this.credentials == null) {
this.credentials =
new HttpCloudFoundryClient(
- name, appsManagerUri, metricsUri, apiHost, userName, password, skipSslValidation);
+ name,
+ appsManagerUri,
+ metricsUri,
+ apiHost,
+ userName,
+ password,
+ skipSslValidation,
+ resultsPerPage);
}
return credentials;
}
@@ -109,12 +120,20 @@ public class CloudFoundryCredentials implements AccountCredentials<CloudFoundryC
&& Objects.equals(userName, that.userName)
&& Objects.equals(password, that.password)
&& Objects.equals(environment, that.environment)
- && Objects.equals(skipSslValidation, that.skipSslValidation);
+ && Objects.equals(skipSslValidation, that.skipSslValidation)
+ && Objects.equals(resultsPerPage, that.resultsPerPage);
}
@Override
public int hashCode() {
return Objects.hash(
- name, appsManagerUri, metricsUri, userName, password, environment, skipSslValidation);
+ name,
+ appsManagerUri,
+ metricsUri,
+ userName,
+ password,
+ environment,
+ skipSslValidation,
+ resultsPerPage);
}
}

MODIFY
clouddriver-cloudfoundry/src/main/java/com/netflix/spinnaker/clouddriver/cloudfoundry/security/CloudFoundryCredentialsSynchronizer.java
clouddriver-cloudfoundry/src/main/java/com/netflix/spinnaker/clouddriver/cloudfoundry/security/CloudFoundryCredentialsSynchronizer.java
@@ -86,7 +86,8 @@ public class CloudFoundryCredentialsSynchronizer implements CredentialsInitializ
managedAccount.getUser(),
managedAccount.getPassword(),
managedAccount.getEnvironment(),
- managedAccount.isSkipSslValidation());
+ managedAccount.isSkipSslValidation(),
+ managedAccount.getResultsPerPage());
AccountCredentials existingCredentials =
accountCredentialsRepository.getOne(credentials.getName());

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
@@ -46,7 +46,8 @@ class ApplicationsTest {
private ApplicationService applicationService = mock(ApplicationService.class);
private Spaces spaces = mock(Spaces.class);
private Applications apps =
- new Applications("pws", "some-apps-man-uri", "some-metrics-uri", applicationService, spaces);
+ new Applications(
+ "pws", "some-apps-man-uri", "some-metrics-uri", applicationService, spaces, 500);
private String spaceId = "space-guid";
private CloudFoundrySpace cloudFoundrySpace =
CloudFoundrySpace.builder()
@@ -65,7 +66,8 @@ class ApplicationsTest {
"api.run.pivotal.io",
"baduser",
"badpassword",
- false);
+ false,
+ 500);
assertThatThrownBy(() -> client.getApplications().all())
.isInstanceOf(CloudFoundryApiException.class);

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
@@ -68,7 +68,7 @@ class HttpCloudFoundryClientTest {
HttpCloudFoundryClient cloudFoundryClient =
new HttpCloudFoundryClient(
- "account", "appsManUri", "metricsUri", "host", "user", "password", false);
+ "account", "appsManUri", "metricsUri", "host", "user", "password", false, 500);
Response response = cloudFoundryClient.createRetryInterceptor(chain);
try {
@@ -97,7 +97,7 @@ class HttpCloudFoundryClientTest {
HttpCloudFoundryClient cloudFoundryClient =
new HttpCloudFoundryClient(
- "account", "appsManUri", "metricsUri", "host", "user", "password", false);
+ "account", "appsManUri", "metricsUri", "host", "user", "password", false, 500);
Response response = cloudFoundryClient.createRetryInterceptor(chain);
try {
@@ -126,7 +126,7 @@ class HttpCloudFoundryClientTest {
HttpCloudFoundryClient cloudFoundryClient =
new HttpCloudFoundryClient(
- "account", "appsManUri", "metricsUri", "host", "user", "password", false);
+ "account", "appsManUri", "metricsUri", "host", "user", "password", false, 500);
Response response = cloudFoundryClient.createRetryInterceptor(chain);
try {

MODIFY
clouddriver-cloudfoundry/src/test/java/com/netflix/spinnaker/clouddriver/cloudfoundry/client/RoutesTest.java
clouddriver-cloudfoundry/src/test/java/com/netflix/spinnaker/clouddriver/cloudfoundry/client/RoutesTest.java
@@ -57,7 +57,7 @@ class RoutesTest {
when(routeService.all(any(), any(), any())).thenReturn(Page.singleton(route, "abc123"));
when(routeService.routeMappings(any(), any())).thenReturn(new Page<>());
- Routes routes = new Routes("pws", routeService, null, domains, spaces);
+ Routes routes = new Routes("pws", routeService, null, domains, spaces, 500);
RouteId routeId = routes.toRouteId("demo1-prod.apps.calabasas.cf-app.com/path");
assertThat(routeId).isNotNull();
assertThat(routeId.getHost()).isEqualTo("demo1-prod");
@@ -67,7 +67,7 @@ class RoutesTest {
@Test
void toRouteIdReturnsNullForInvalidRoute() {
- Routes routes = new Routes(null, null, null, null, null);
+ Routes routes = new Routes(null, null, null, null, null, 500);
assertNull(routes.toRouteId("demo1-pro cf-app.com/path"));
}
@@ -127,7 +127,7 @@ class RoutesTest {
when(routeService.all(any(), any(), any())).thenReturn(routePage);
when(routeService.routeMappings(any(), any())).thenReturn(routeMappingPage);
- Routes routes = new Routes("pws", routeService, null, domains, spaces);
+ Routes routes = new Routes("pws", routeService, null, domains, spaces, 500);
CloudFoundryLoadBalancer loadBalancer =
routes.find(new RouteId().setHost("somehost").setDomainGuid("domain-guid"), "space-guid");

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

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

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

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
@@ -69,7 +69,7 @@ class DeployCloudFoundryServerGroupAtomicOperationConverterTest {
.build()));
}
- return new CloudFoundryCredentials(name, "", "", "", "", "", "", false) {
+ return new CloudFoundryCredentials(name, "", "", "", "", "", "", false, 500) {
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
@@ -71,7 +71,7 @@ class DeployCloudFoundryServiceAtomicOperationConverterTest {
}
private final CloudFoundryCredentials cloudFoundryCredentials =
- new CloudFoundryCredentials("test", "", "", "", "", "", "", false) {
+ new CloudFoundryCredentials("test", "", "", "", "", "", "", false, 500) {
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
@@ -60,7 +60,7 @@ class ScaleCloudFoundryServerGroupAtomicOperationConverterTest {
}
private final CloudFoundryCredentials cloudFoundryCredentials =
- new CloudFoundryCredentials("test", "", "", "", "", "", "", false) {
+ new CloudFoundryCredentials("test", "", "", "", "", "", "", false, 500) {
public CloudFoundryClient getClient() {
return cloudFoundryClient;
}

MODIFY
clouddriver-cloudfoundry/src/test/java/com/netflix/spinnaker/clouddriver/cloudfoundry/security/CloudFoundryCredentialsSynchronizerTest.java
clouddriver-cloudfoundry/src/test/java/com/netflix/spinnaker/clouddriver/cloudfoundry/security/CloudFoundryCredentialsSynchronizerTest.java
@@ -149,7 +149,7 @@ class CloudFoundryCredentialsSynchronizerTest {
private CloudFoundryCredentials createCredentials(String name) {
return new CloudFoundryCredentials(
- name, null, null, "api." + name, "user-" + name, "pwd-" + name, null, false);
+ name, null, null, "api." + name, "user-" + name, "pwd-" + name, null, false, 500);
}
private void loadProviderFromRepository() {

fix(cf): allow results per page to be configurable (#4289)