From 9dab2317c814fd66343daf942ad8cfe41b4c22b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Abete?= Date: Thu, 23 Feb 2017 15:42:23 -0300 Subject: [PATCH 1/7] Support multi level images Like: registry.example.com/repo/image/name:0.1.1 --- ecs-deploy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ecs-deploy b/ecs-deploy index b3a7021..c328841 100755 --- a/ecs-deploy +++ b/ecs-deploy @@ -216,7 +216,7 @@ fi # - image # - tag # If a group is missing it will be an empty string -imageRegex="^([a-zA-Z0-9.\-]+):?([0-9]+)?/([a-zA-Z0-9._-]+)/?([a-zA-Z0-9._-]+)?:?([a-zA-Z0-9\._-]+)?$" +imageRegex="^([a-zA-Z0-9.\-]+):?([0-9]+)?\/([a-zA-Z0-9._-]+)\/?([a-zA-Z0-9._\-\/]+)*:?([a-zA-Z0-9\._-]+)?$" if [[ $IMAGE =~ $imageRegex ]]; then # Define variables from matching groups From c67b349ac0268056980986f8c76596bf5001d9d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Abete?= Date: Thu, 2 Mar 2017 15:20:59 -0300 Subject: [PATCH 2/7] Update regex Common image format (repo:port/repo/image:tag) wasn't supported. --- ecs-deploy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ecs-deploy b/ecs-deploy index c328841..2067aaa 100755 --- a/ecs-deploy +++ b/ecs-deploy @@ -216,7 +216,7 @@ fi # - image # - tag # If a group is missing it will be an empty string -imageRegex="^([a-zA-Z0-9.\-]+):?([0-9]+)?\/([a-zA-Z0-9._-]+)\/?([a-zA-Z0-9._\-\/]+)*:?([a-zA-Z0-9\._-]+)?$" +imageRegex="^([a-zA-Z0-9\.\-]+):?([0-9]+)?/([a-zA-Z0-9\._\-]+)/?([\/a-zA-Z0-9\._\-]+)?:?([a-zA-Z0-9\._\-]+)?$" if [[ $IMAGE =~ $imageRegex ]]; then # Define variables from matching groups From c5c7575d1ef7e8c6a453076d9592c93899c2be41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Abete?= Date: Thu, 30 Mar 2017 12:11:14 -0300 Subject: [PATCH 3/7] Update tests for multi level images --- test.bats | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/test.bats b/test.bats index 22ba3a0..3dc8acf 100755 --- a/test.bats +++ b/test.bats @@ -109,6 +109,22 @@ setup() { [ "$output" == "repo/image:v1.2.3" ] } +@test "test parseImageName repo multilevel image no tag" { + IMAGE="repo/multi/level/image" + TAGVAR=false + run parseImageName + [ ! -z $status ] + [ "$output" == "repo/multi/level/image:latest" ] +} + +@test "test parseImageName repo multilevel image with tag" { + IMAGE="repo/multi/level/image:v1.2.3" + TAGVAR=false + run parseImageName + [ ! -z $status ] + [ "$output" == "repo/multi/level/image:v1.2.3" ] +} + @test "test parseImageName domain plus repo image no tag" { IMAGE="docker.domain.com/repo/image" TAGVAR=false @@ -125,6 +141,22 @@ setup() { [ "$output" == "docker.domain.com/repo/image:1.2.3" ] } +@test "test parseImageName domain plus repo multilevel image no tag" { + IMAGE="docker.domain.com/repo/multi/level/image" + TAGVAR=false + run parseImageName + [ ! -z $status ] + [ "$output" == "docker.domain.com/repo/multi/level/image:latest" ] +} + +@test "test parseImageName domain plus repo multilevel image with tag" { + IMAGE="docker.domain.com/repo/multi/level/image:1.2.3" + TAGVAR=false + run parseImageName + [ ! -z $status ] + [ "$output" == "docker.domain.com/repo/multi/level/image:1.2.3" ] +} + @test "test parseImageName domain plus port plus repo image no tag" { IMAGE="docker.domain.com:8080/repo/image" TAGVAR=false @@ -141,6 +173,22 @@ setup() { [ "$output" == "docker.domain.com:8080/repo/image:1.2.3" ] } +@test "test parseImageName domain plus port plus repo multilevel image no tag" { + IMAGE="docker.domain.com:8080/repo/multi/level/image" + TAGVAR=false + run parseImageName + [ ! -z $status ] + [ "$output" == "docker.domain.com:8080/repo/multi/level/image:latest" ] +} + +@test "test parseImageName domain plus port plus repo multilevel image with tag" { + IMAGE="docker.domain.com:8080/repo/multi/level/image:1.2.3" + TAGVAR=false + run parseImageName + [ ! -z $status ] + [ "$output" == "docker.domain.com:8080/repo/multi/level/image:1.2.3" ] +} + @test "test parseImageName domain plus port plus repo image with tag from var" { IMAGE="docker.domain.com:8080/repo/image" TAGVAR="CI_TIMESTAMP" @@ -150,6 +198,23 @@ setup() { [ "$output" == "docker.domain.com:8080/repo/image:1487623908" ] } +@test "test parseImageName domain plus port plus repo multilevel image with tag from var" { + IMAGE="docker.domain.com:8080/repo/multi/level/image" + TAGVAR="CI_TIMESTAMP" + CI_TIMESTAMP="1487623908" + run parseImageName + [ ! -z $status ] + [ "$output" == "docker.domain.com:8080/repo/multi/level/image:1487623908" ] +} + +@test "test parseImageName using ecr style domain" { + IMAGE="121212345678.dkr.ecr.us-east-1.amazonaws.com/acct/repo" + TAGVAR=false + run parseImageName + [ ! -z $status ] + [ "$output" == "121212345678.dkr.ecr.us-east-1.amazonaws.com/acct/repo:latest" ] +} + @test "test parseImageName using ecr style image name and tag from var" { IMAGE="121212345678.dkr.ecr.us-east-1.amazonaws.com/acct/repo" TAGVAR="CI_TIMESTAMP" From 0c0071a3735bf8a01cfc677406f0928febf4e769 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Abete?= Date: Tue, 2 May 2017 16:12:36 -0300 Subject: [PATCH 4/7] Fix issue with regex string matching for some bash versions https://github.com/silinternational/ecs-deploy/pull/89 --- ecs-deploy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ecs-deploy b/ecs-deploy index b3c6efe..bae9ae5 100755 --- a/ecs-deploy +++ b/ecs-deploy @@ -22,7 +22,7 @@ AWS_ECS="$AWS_CLI --output json ecs" # - image # - tag # If a group is missing it will be an empty string -imageRegex="^([a-zA-Z0-9\.\-]+):?([0-9]+)?/([a-zA-Z0-9\._\-]+)/?([\/a-zA-Z0-9\._\-]+)?:?([a-zA-Z0-9\._\-]+)?$" +imageRegex="^([a-zA-Z0-9\.\-]+):?([0-9]+)?/([a-zA-Z0-9\._\-]+)(/[\/a-zA-Z0-9\._\-]+)?:?([a-zA-Z0-9\._\-]+)?$" function usage() { cat < Date: Thu, 30 Mar 2017 12:11:14 -0300 Subject: [PATCH 5/7] Update tests for multi level images --- test.bats | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/test.bats b/test.bats index 560a995..bd210c5 100755 --- a/test.bats +++ b/test.bats @@ -109,6 +109,22 @@ setup() { [ "$output" == "repo/image:v1.2.3" ] } +@test "test parseImageName repo multilevel image no tag" { + IMAGE="repo/multi/level/image" + TAGVAR=false + run parseImageName + [ ! -z $status ] + [ "$output" == "repo/multi/level/image:latest" ] +} + +@test "test parseImageName repo multilevel image with tag" { + IMAGE="repo/multi/level/image:v1.2.3" + TAGVAR=false + run parseImageName + [ ! -z $status ] + [ "$output" == "repo/multi/level/image:v1.2.3" ] +} + @test "test parseImageName domain plus repo image no tag" { IMAGE="docker.domain.com/repo/image" TAGVAR=false @@ -125,6 +141,22 @@ setup() { [ "$output" == "docker.domain.com/repo/image:1.2.3" ] } +@test "test parseImageName domain plus repo multilevel image no tag" { + IMAGE="docker.domain.com/repo/multi/level/image" + TAGVAR=false + run parseImageName + [ ! -z $status ] + [ "$output" == "docker.domain.com/repo/multi/level/image:latest" ] +} + +@test "test parseImageName domain plus repo multilevel image with tag" { + IMAGE="docker.domain.com/repo/multi/level/image:1.2.3" + TAGVAR=false + run parseImageName + [ ! -z $status ] + [ "$output" == "docker.domain.com/repo/multi/level/image:1.2.3" ] +} + @test "test parseImageName domain plus port plus repo image no tag" { IMAGE="docker.domain.com:8080/repo/image" TAGVAR=false @@ -141,6 +173,22 @@ setup() { [ "$output" == "docker.domain.com:8080/repo/image:1.2.3" ] } +@test "test parseImageName domain plus port plus repo multilevel image no tag" { + IMAGE="docker.domain.com:8080/repo/multi/level/image" + TAGVAR=false + run parseImageName + [ ! -z $status ] + [ "$output" == "docker.domain.com:8080/repo/multi/level/image:latest" ] +} + +@test "test parseImageName domain plus port plus repo multilevel image with tag" { + IMAGE="docker.domain.com:8080/repo/multi/level/image:1.2.3" + TAGVAR=false + run parseImageName + [ ! -z $status ] + [ "$output" == "docker.domain.com:8080/repo/multi/level/image:1.2.3" ] +} + @test "test parseImageName domain plus port plus repo image with tag from var" { IMAGE="docker.domain.com:8080/repo/image" TAGVAR="CI_TIMESTAMP" @@ -150,6 +198,23 @@ setup() { [ "$output" == "docker.domain.com:8080/repo/image:1487623908" ] } +@test "test parseImageName domain plus port plus repo multilevel image with tag from var" { + IMAGE="docker.domain.com:8080/repo/multi/level/image" + TAGVAR="CI_TIMESTAMP" + CI_TIMESTAMP="1487623908" + run parseImageName + [ ! -z $status ] + [ "$output" == "docker.domain.com:8080/repo/multi/level/image:1487623908" ] +} + +@test "test parseImageName using ecr style domain" { + IMAGE="121212345678.dkr.ecr.us-east-1.amazonaws.com/acct/repo" + TAGVAR=false + run parseImageName + [ ! -z $status ] + [ "$output" == "121212345678.dkr.ecr.us-east-1.amazonaws.com/acct/repo:latest" ] +} + @test "test parseImageName using ecr style image name and tag from var" { IMAGE="121212345678.dkr.ecr.us-east-1.amazonaws.com/acct/repo" TAGVAR="CI_TIMESTAMP" From b43184d3d948378931ecc0eb479d65e12bddd35b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Abete?= Date: Tue, 2 May 2017 16:12:36 -0300 Subject: [PATCH 6/7] Fix issue with regex string matching for some bash versions https://github.com/silinternational/ecs-deploy/pull/89 --- ecs-deploy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ecs-deploy b/ecs-deploy index 3070fa9..0ea8b0c 100755 --- a/ecs-deploy +++ b/ecs-deploy @@ -141,7 +141,7 @@ function parseImageName() { # - tag # If a group is missing it will be an empty string if [[ "x$TAGONLY" == "x" ]]; then - imageRegex="^([a-zA-Z0-9.\-]+):?([0-9]+)?/([a-zA-Z0-9._-]+)/?([a-zA-Z0-9._-]+)?:?([a-zA-Z0-9\._-]+)?$" + imageRegex="^([a-zA-Z0-9\.\-]+):?([0-9]+)?/([a-zA-Z0-9\._\-]+)(/[\/a-zA-Z0-9\._\-]+)?:?([a-zA-Z0-9\._\-]+)?$" else imageRegex="^:?([a-zA-Z0-9\._-]+)?$" fi @@ -152,7 +152,7 @@ function parseImageName() { domain=${BASH_REMATCH[1]} port=${BASH_REMATCH[2]} repo=${BASH_REMATCH[3]} - img=${BASH_REMATCH[4]} + img=${BASH_REMATCH[4]/#\//} tag=${BASH_REMATCH[5]} # Validate what we received to make sure we have the pieces needed From da58433b2ea5ea75d5b4669137b534eea8e693d8 Mon Sep 17 00:00:00 2001 From: kakakakakku Date: Wed, 17 May 2017 12:24:12 +0900 Subject: [PATCH 7/7] Fixed typo --- ecs-deploy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ecs-deploy b/ecs-deploy index e3a0cea..637e793 100755 --- a/ecs-deploy +++ b/ecs-deploy @@ -108,7 +108,7 @@ function assertRequiredArgumentsSet() { fi if [ $SERVICE == false ] && [ $TASK_DEFINITION == false ]; then - echo "One of SERVICE or TASK DEFINITON is required. You can pass the value using -n / --service-name for a service, or -d / --task-definiton for a task" + echo "One of SERVICE or TASK DEFINITON is required. You can pass the value using -n / --service-name for a service, or -d / --task-definition for a task" exit 5 fi if [ $SERVICE != false ] && [ $TASK_DEFINITION != false ]; then