Skip to content

Commit

Permalink
fix(cf): regions must be associated with accounts (#3760)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jammy Louie committed Jun 6, 2019
1 parent 900a257 commit aebb1b0
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@

package com.netflix.spinnaker.clouddriver.cloudfoundry.security;

import static java.util.Collections.emptyList;
import static java.util.Collections.singletonMap;
import static java.util.stream.Collectors.toList;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.netflix.spinnaker.clouddriver.cloudfoundry.client.CloudFoundryApiException;
import com.netflix.spinnaker.clouddriver.cloudfoundry.client.CloudFoundryClient;
import com.netflix.spinnaker.clouddriver.cloudfoundry.client.HttpCloudFoundryClient;
import com.netflix.spinnaker.clouddriver.security.AccountCredentials;
Expand Down Expand Up @@ -80,6 +85,17 @@ public CloudFoundryClient getClient() {
return getCredentials();
}

public Collection<Map<String, String>> getRegions() {
try {
return getCredentials().getSpaces().all().stream()
.map(space -> singletonMap("name", space.getRegion()))
.collect(toList());
} catch (CloudFoundryApiException e) {
log.warn("Unable to determine regions for Cloud Foundry account " + name, e);
return emptyList();
}
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand Down

0 comments on commit aebb1b0

Please sign in to comment.