Skip to content

Commit

Permalink
fix(ecs): Add validation for loadBalancedContainer when using artifact (
Browse files Browse the repository at this point in the history
  • Loading branch information
spinnakerbot authored and ezimanyi committed Jul 23, 2019
1 parent 97f95e4 commit a4ba5d3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,18 @@ public void validate(List priorDescriptions, Object description, Errors errors)
} else {
rejectValue(errors, "reservedMemory", "not.nullable");
}
} else {
// Verify load balanced services w/ an artifact specify which container to load balance on
boolean hasTargetGroup =
createServerGroupDescription.getTargetGroup() != null
&& !createServerGroupDescription.getTargetGroup().isEmpty();
boolean hasLoadBalancedContainer =
createServerGroupDescription.getLoadBalancedContainer() != null
&& !createServerGroupDescription.getLoadBalancedContainer().isEmpty();

if (hasTargetGroup && !hasLoadBalancedContainer) {
rejectValue(errors, "loadBalancedContainer", "not.nullable");
}
}

if (createServerGroupDescription.getContainerPort() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,19 @@ class EcsCreateServergroupDescriptionValidatorSpec extends AbstractValidatorSpec
0 * errors.rejectValue(_, _)
}

void '(with artifact) should fail when load balancer specified but loadBalanced container missing'() {
given:
def description = getDescription()
description.useTaskDefinitionArtifact = true
def errors = Mock(Errors)

when:
validator.validate([], description, errors)

then:
1 * errors.rejectValue('loadBalancedContainer', "${getDescriptionName()}.loadBalancedContainer.not.nullable")
}

@Override
AbstractECSDescription getNulledDescription() {
def description = (CreateServerGroupDescription) getDescription()
Expand Down

0 comments on commit a4ba5d3

Please sign in to comment.