From 838f1753d4bbc34985ce9d56e05946d689befeea Mon Sep 17 00:00:00 2001 From: kakakakakku Date: Thu, 6 Dec 2018 22:12:25 +0900 Subject: [PATCH 01/12] Updated Alpine Linux version --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 9c0f6ab..70416ae 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:3.5 +FROM alpine:3.8 # Install packges needed RUN apk --no-cache add ca-certificates curl bash jq py2-pip && \ From 8d3af47865f64d3b7b58299428e12849eb870741 Mon Sep 17 00:00:00 2001 From: kakakakakku Date: Thu, 6 Dec 2018 22:14:39 +0900 Subject: [PATCH 02/12] Fixed Bash syntax correctly --- test.bats | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test.bats b/test.bats index 6fd9fec..8467e38 100755 --- a/test.bats +++ b/test.bats @@ -279,7 +279,7 @@ 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" }' run createNewTaskDefJson [ ! -z $status ] - [ $(echo "$output" | jq) == $(echo "$expected" | jq) ] + [ "$(echo "$output" | jq .)" == "$(echo "$expected" | jq .)" ] } @test "test createNewTaskDefJson with single container in definition for AWS Fargate" { @@ -345,7 +345,7 @@ 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": "awsvpc", "executionRoleArn": "arn:aws:iam::121212345678:role/ecsTaskExecutionRole", "requiresCompatibilities": [ "FARGATE" ], "cpu": "256", "memory": "512" }' run createNewTaskDefJson [ ! -z $status ] - [ $(echo "$output" | jq) == $(echo "$expected" | jq) ] + [ "$(echo "$output" | jq .)" == "$(echo "$expected" | jq .)" ] } @test "test createNewTaskDefJson with multiple containers in definition" { @@ -429,7 +429,7 @@ 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": [] }, { "environment": [ { "name": "KEY", "value": "value" } ], "name": "cache", "links": [], "mountPoints": [], "image": "redis:latest", "essential": true, "portMappings": [ { "protocol": "tcp", "containerPort": 6376, "hostPort": 10376 } ], "entryPoint": [], "memory": 128, "command": [ "/data/run.sh" ], "cpu": 200, "volumesFrom": [] } ], "placementConstraints": null, "networkMode": "bridge" }' run createNewTaskDefJson [ ! -z $status ] - [ $(echo "$output" | jq) == $(echo "$expected" | jq) ] + [ "$(echo "$output" | jq .)" == "$(echo "$expected" | jq .)" ] } @test "test parseImageName with tagonly option" { @@ -441,7 +441,7 @@ EOF run parseImageName [ ! -z $status ] - [ $(echo "$output" | jq) == $(echo "$expected" | jq) ] + [ "$(echo "$output" | jq .)" == "$(echo "$expected" | jq .)" ] } @test "test createNewTaskDefJson with multiple containers in definition and replace only tags" { @@ -527,5 +527,5 @@ EOF run createNewTaskDefJson echo $output [ ! -z $status ] - [ $(echo "$output" | jq) == $(echo "$expected" | jq) ] + [ "$(echo "$output" | jq .)" == "$(echo "$expected" | jq .)" ] } From 174e0b91347c6261d7a14769a7dc1377dfd2a39c Mon Sep 17 00:00:00 2001 From: bobdoah Date: Thu, 17 Jan 2019 15:30:59 +0000 Subject: [PATCH 03/12] Fixes #171: Add an guard against the unbound port variable --- ecs-deploy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ecs-deploy b/ecs-deploy index 36925af..4cbcbf2 100755 --- a/ecs-deploy +++ b/ecs-deploy @@ -241,7 +241,7 @@ function parseImageName() { if [[ ! -z ${domain+undefined-guard} ]]; then useImage="$domain" fi - if [[ ! -z ${port} ]]; then + if [[ ! -z ${port+undefined-guard} ]]; then useImage="$useImage:$port" fi if [[ ! -z ${repo+undefined-guard} ]]; then From 28cc2e00cdd4c9e7baaefe06375dc43c2654b7f1 Mon Sep 17 00:00:00 2001 From: bobdoah Date: Thu, 17 Jan 2019 15:37:55 +0000 Subject: [PATCH 04/12] Use an undefined guard on the useImage variable, which may not have been declared at this point. After this I was able to get the task definition updated successfully --- ecs-deploy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ecs-deploy b/ecs-deploy index 4cbcbf2..ffbe063 100755 --- a/ecs-deploy +++ b/ecs-deploy @@ -250,7 +250,7 @@ function parseImageName() { fi fi if [[ ! -z ${img+undefined-guard} ]]; then - if [[ "x$useImage" == "x" ]]; then + if [[ "x${useImage+undefined-guard}" == "x" ]]; then useImage="$img" else useImage="$useImage/$img" From 6719e58fef190575df41f9047ee721004178531d Mon Sep 17 00:00:00 2001 From: taka011239 Date: Mon, 25 Mar 2019 11:55:47 +0900 Subject: [PATCH 05/12] Support requires compatibilities both ec2 and fargate --- ecs-deploy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ecs-deploy b/ecs-deploy index 36925af..3fc6425 100755 --- a/ecs-deploy +++ b/ecs-deploy @@ -323,7 +323,7 @@ function createNewTaskDefJson() { # Updated jq filters for AWS Fargate REQUIRES_COMPATIBILITIES=$(echo "${DEF}" | jq -r '. | select(.requiresCompatibilities != null) | .requiresCompatibilities[]') - if [[ "${REQUIRES_COMPATIBILITIES}" == 'FARGATE' ]]; then + if `echo ${REQUIRES_COMPATIBILITIES[@]} | grep -q "FARGATE"`; then FARGATE_JQ_FILTER='executionRoleArn: .executionRoleArn, requiresCompatibilities: .requiresCompatibilities, cpu: .cpu, memory: .memory' NEW_DEF_JQ_FILTER="${NEW_DEF_JQ_FILTER}, ${FARGATE_JQ_FILTER}" fi From f3f8058ceb09dab731168d2fbfb458c8705d612c Mon Sep 17 00:00:00 2001 From: Yuki Yamashita Date: Wed, 10 Apr 2019 19:03:49 +0900 Subject: [PATCH 06/12] add executionRoleArn into NEW_DEF_JQ_FILTER --- ecs-deploy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ecs-deploy b/ecs-deploy index 36925af..a7af34e 100755 --- a/ecs-deploy +++ b/ecs-deploy @@ -309,7 +309,7 @@ function createNewTaskDefJson() { fi # Default JQ filter for new task definition - NEW_DEF_JQ_FILTER="family: .family, volumes: .volumes, containerDefinitions: .containerDefinitions, placementConstraints: .placementConstraints" + NEW_DEF_JQ_FILTER="executionRoleArn: .executionRoleArn, ffamily: .family, volumes: .volumes, containerDefinitions: .containerDefinitions, placementConstraints: .placementConstraints" # 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. From 670c37278acd0362ae8962c086a9810167d69990 Mon Sep 17 00:00:00 2001 From: Yuki Yamashita Date: Wed, 10 Apr 2019 19:11:04 +0900 Subject: [PATCH 07/12] fix typo --- ecs-deploy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ecs-deploy b/ecs-deploy index a7af34e..a921a3c 100755 --- a/ecs-deploy +++ b/ecs-deploy @@ -309,7 +309,7 @@ function createNewTaskDefJson() { fi # Default JQ filter for new task definition - NEW_DEF_JQ_FILTER="executionRoleArn: .executionRoleArn, ffamily: .family, volumes: .volumes, containerDefinitions: .containerDefinitions, placementConstraints: .placementConstraints" + NEW_DEF_JQ_FILTER="executionRoleArn: .executionRoleArn, family: .family, volumes: .volumes, containerDefinitions: .containerDefinitions, placementConstraints: .placementConstraints" # 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. From d68ef8a18184ab46be178e6e7c7610eae71bec12 Mon Sep 17 00:00:00 2001 From: Yuki Yamashita Date: Mon, 15 Apr 2019 20:03:18 +0900 Subject: [PATCH 08/12] add executionRoleArn into CONDITIONAL_OPTIONS variable --- ecs-deploy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ecs-deploy b/ecs-deploy index a921a3c..1468c0f 100755 --- a/ecs-deploy +++ b/ecs-deploy @@ -313,7 +313,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) + CONDITIONAL_OPTIONS=(networkMode taskRoleArn placementConstraints executionRoleArn) for i in "${CONDITIONAL_OPTIONS[@]}"; do re=".*${i}.*" if [[ "$DEF" =~ $re ]]; then From e7a6a5d693e2befb66aa16b8fd0dae7afed1bf39 Mon Sep 17 00:00:00 2001 From: Phillip Date: Wed, 28 Aug 2019 11:25:41 -0400 Subject: [PATCH 09/12] remove executionRoleArn from default JQ filter as it causes errors if the task def doesnt have an execution role --- ecs-deploy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ecs-deploy b/ecs-deploy index 1468c0f..9a9a728 100755 --- a/ecs-deploy +++ b/ecs-deploy @@ -309,7 +309,7 @@ function createNewTaskDefJson() { fi # Default JQ filter for new task definition - NEW_DEF_JQ_FILTER="executionRoleArn: .executionRoleArn, family: .family, volumes: .volumes, containerDefinitions: .containerDefinitions, placementConstraints: .placementConstraints" + NEW_DEF_JQ_FILTER="family: .family, volumes: .volumes, containerDefinitions: .containerDefinitions, placementConstraints: .placementConstraints" # 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. From 23ac38985a3f794bc7c807b14e89c4e7843ee5f5 Mon Sep 17 00:00:00 2001 From: Phillip Date: Wed, 28 Aug 2019 16:16:16 -0400 Subject: [PATCH 10/12] changing comparisons to avoid unbound errors and problems caused by undefined-guard --- ecs-deploy | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/ecs-deploy b/ecs-deploy index 3919638..8c3b3d2 100755 --- a/ecs-deploy +++ b/ecs-deploy @@ -217,6 +217,12 @@ function parseImageName() { exit 12 fi tag=${BASH_REMATCH[2]} + + # for root level repo, initialize unused variables for checks when rebuilding image below + domain="" + port="" + repo="" + else echo "Unable to parse image name: $IMAGE, check the format and try again" exit 13 @@ -236,28 +242,27 @@ function parseImageName() { fi # Reassemble image name + useImage="" if [[ "x$TAGONLY" == "x" ]]; then - if [[ ! -z ${domain+undefined-guard} ]]; then + if [[ ! -z "$domain" ]]; then useImage="$domain" fi - if [[ ! -z ${port+undefined-guard} ]]; then + if [[ ! -z "$port" ]]; then useImage="$useImage:$port" fi - if [[ ! -z ${repo+undefined-guard} ]]; then - if [[ ! "x$repo" == "x" ]]; then + if [[ ! -z "$repo" ]]; then useImage="$useImage/$repo" - fi fi - if [[ ! -z ${img+undefined-guard} ]]; then - if [[ "x${useImage+undefined-guard}" == "x" ]]; then + if [[ ! -z "$img" ]]; then + if [[ -z "$useImage" ]]; then useImage="$img" else useImage="$useImage/$img" fi fi imageWithoutTag="$useImage" - if [[ ! -z ${tag+undefined-guard} ]]; then + if [[ ! -z "$tag" ]]; then useImage="$useImage:$tag" fi From 9aa12443414c49df00db99cda5576ada1a989649 Mon Sep 17 00:00:00 2001 From: Phillip Date: Fri, 30 Aug 2019 10:43:50 -0400 Subject: [PATCH 11/12] initialize variables where not otherwise initialized --- ecs-deploy | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ecs-deploy b/ecs-deploy index 8c3b3d2..dba39d5 100755 --- a/ecs-deploy +++ b/ecs-deploy @@ -206,6 +206,10 @@ function parseImageName() { fi else tag=${BASH_REMATCH[1]} + domain="" + port="" + repo="" + img="" fi else # check if using root level repo with format like mariadb or mariadb:latest From 91934c9b1fc96aecc6c014d860751ef6dd96f1c9 Mon Sep 17 00:00:00 2001 From: Phillip Date: Fri, 30 Aug 2019 10:46:21 -0400 Subject: [PATCH 12/12] bump version to 3.7.0 --- ecs-deploy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ecs-deploy b/ecs-deploy index d2e59d3..142f5bd 100755 --- a/ecs-deploy +++ b/ecs-deploy @@ -1,7 +1,7 @@ #!/usr/bin/env bash # Setup default values for variables -VERSION="3.4.0" +VERSION="3.7.0" CLUSTER=false SERVICE=false TASK_DEFINITION=false