Skip to content

Commit

Permalink
Merge pull request #293 from silinternational/feature/keep-proxyConfi…
Browse files Browse the repository at this point in the history
…guration

Keep `proxyConfiguration`, if present
  • Loading branch information
forevermatt authored May 15, 2024
2 parents 0e958ad + 9780172 commit 8f08129
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ecs-deploy
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ function createNewTaskDefJson() {

# Some options in task definition should only be included in new definition if present in
# current definition. If found in current definition, append to JQ filter.
CONDITIONAL_OPTIONS=(networkMode taskRoleArn placementConstraints executionRoleArn runtimePlatform ephemeralStorage)
CONDITIONAL_OPTIONS=(networkMode taskRoleArn placementConstraints executionRoleArn runtimePlatform ephemeralStorage proxyConfiguration)
for i in "${CONDITIONAL_OPTIONS[@]}"; do
re=".*${i}.*"
if [[ "$DEF" =~ $re ]]; then
Expand Down
60 changes: 60 additions & 0 deletions test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -686,3 +686,63 @@ EOF
[ "$output" == "something:tag_123" ]
echo "output = $output" 1>&2
}

@test "test createNewTaskDefJson with existing proxyConfiguration value" {
imageWithoutTag="121212345678.dkr.ecr.us-east-1.amazonaws.com/acct/repo"
useImage="121212345678.dkr.ecr.us-east-1.amazonaws.com/acct/repo:1111111111"
TASK_DEFINITION=$(cat <<EOF
{
"taskDefinition": {
"status": "ACTIVE",
"networkMode": "bridge",
"family": "app-task-def",
"requiresAttributes": [
{
"name": "com.amazonaws.ecs.capability.ecr-auth"
}
],
"volumes": [],
"taskDefinitionArn": "arn:aws:ecs:us-east-1:121212345678:task-definition/app-task-def:123",
"containerDefinitions": [
{
"environment": [
{
"name": "KEY",
"value": "value * "
}
],
"name": "API",
"links": [],
"mountPoints": [],
"image": "121212345678.dkr.ecr.us-east-1.amazonaws.com/acct/repo:1487623908",
"essential": true,
"portMappings": [
{
"protocol": "tcp",
"containerPort": 80,
"hostPort": 10080
}
],
"entryPoint": [],
"memory": 128,
"command": [
"/data/run.sh"
],
"cpu": 200,
"volumesFrom": []
}
],
"placementConstraints": null,
"proxyConfiguration": {
"containerName": "example"
},
"revision": 123
}
}
EOF
)
expected='{ "family": "app-task-def", "volumes": [], "containerDefinitions": [ { "environment": [ { "name": "KEY", "value": "value * " } ], "name": "API", "links": [], "mountPoints": [], "image": "121212345678.dkr.ecr.us-east-1.amazonaws.com/acct/repo:1111111111", "essential": true, "portMappings": [ { "protocol": "tcp", "containerPort": 80, "hostPort": 10080 } ], "entryPoint": [], "memory": 128, "command": [ "/data/run.sh" ], "cpu": 200, "volumesFrom": [] } ], "placementConstraints": null, "networkMode": "bridge", "proxyConfiguration": { "containerName": "example" } }'
run createNewTaskDefJson
[ ! -z $status ]
[ "$(echo "$output" | jq .)" == "$(echo "$expected" | jq .)" ]
}

0 comments on commit 8f08129

Please sign in to comment.