Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep proxyConfiguration, if present #293

Merged
merged 4 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 .)" ]
}