Skip to content

Commit

Permalink
fix(ecs): set correct key for clusterNames in applications list (#3981)
Browse files Browse the repository at this point in the history
  • Loading branch information
clareliguori authored and ezimanyi committed Aug 30, 2019
1 parent 706333b commit 95ea8e4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,15 @@ private Set<Application> transposeApplicationMapToSet(
private HashMap<String, Application> inferApplicationFromServices(
HashMap<String, Application> applicationHashMap, Service service, boolean expand) {

HashMap<String, String> attributes =
new HashMap<>(); // After POC we'll figure exactly what info we want to put in here
HashMap<String, String> attributes = new HashMap<>();
String appName = service.getApplicationName();
String serviceName = service.getServiceName();
attributes.put("iamRole", service.getRoleArn());
attributes.put("taskDefinition", service.getTaskDefinition());
attributes.put("desiredCount", String.valueOf(service.getDesiredCount()));
String accountName = service.getAccount();
attributes.put("name", service.getApplicationName());

HashMap<String, Set<String>> clusterNames = new HashMap<>();
if (expand) {
clusterNames.put(appName, Sets.newHashSet(serviceName));
clusterNames.put(accountName, Sets.newHashSet(serviceName));
}

EcsApplication application = new EcsApplication(appName, attributes, clusterNames);
Expand All @@ -138,7 +136,7 @@ private HashMap<String, Application> inferApplicationFromServices(
} else {
applicationHashMap.get(appName).getAttributes().putAll(application.getAttributes());
if (expand) {
applicationHashMap.get(appName).getClusterNames().get(appName).add(serviceName);
applicationHashMap.get(appName).getClusterNames().get(accountName).add(serviceName);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,16 @@ class EcsApplicationProviderSpec extends Specification {

def 'should return an application'() {
given:
def credentials = TestCredential.named('test')
def appName = 'test'
def accountName = 'test-account'
def credentials = TestCredential.named(accountName)
def appName = 'testapp'
def serviceName = appName + '-kcats-liated'
Map<String, Set<String>> clusterNames = new HashMap<>()
clusterNames.put(appName, Collections.singleton(serviceName))
clusterNames.put(accountName, Collections.singleton(serviceName))

def givenApp = (Application) new EcsApplication(appName,
[
iamRole : null,
desiredCount : '1',
taskDefinition: null
name: appName
],
clusterNames)

Expand Down

0 comments on commit 95ea8e4

Please sign in to comment.