Skip to content

Commit

Permalink
AbstracctEcsAtomicOperations gets the region from description by defa…
Browse files Browse the repository at this point in the history
…ult, or a method can be overwritten. (#99)
  • Loading branch information
dkirillov authored and BrunoCarrier committed Jan 25, 2018
1 parent c51d48a commit deb4b1e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,22 @@ private static Task getTask() {
}

String getCluster(String service, String account) {
String region = description.getRegion();
String region = getRegion();
return containerInformationService.getClusterName(service, account, region);
}

AmazonECS getAmazonEcsClient() {
AWSCredentialsProvider credentialsProvider = getCredentials().getCredentialsProvider();
String region = description.getRegion();
String region = getRegion();
String credentialAccount = description.getCredentialAccount();

return amazonClientProvider.getAmazonEcs(credentialAccount, credentialsProvider, region);
}

protected String getRegion(){
return description.getRegion();
}

AmazonCredentials getCredentials() {
return (AmazonCredentials) accountCredentialsProvider.getCredentials(description.getCredentialAccount());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,9 @@ private String getNextServiceName(String versionString) {
return getFamilyName() + "-" + versionString;
}

private String getRegion() {
@Override
protected String getRegion() {
//CreateServerGroupDescription does not contain a region. Instead it has AvailabilityZones
return description.getAvailabilityZones().keySet().iterator().next();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ public CacheResult loadData(ProviderCache providerCache) {
*/
Set<String> getClusters(AmazonECS ecs, ProviderCache providerCache) {
Set<String> clusters = providerCache.getAll(ECS_CLUSTERS.toString()).stream()
.filter(cacheData -> cacheData.getAttributes().get("region").equals(region))
.filter(cacheData -> cacheData.getAttributes().get("region").equals(region) &&
cacheData.getAttributes().get("account").equals(accountName))
.map(cacheData -> (String) cacheData.getAttributes().get("clusterArn"))
.collect(Collectors.toSet());

Expand Down

0 comments on commit deb4b1e

Please sign in to comment.