From 2a30f4517784fbd91f083e21c3605707118d8d16 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 13 Dec 2017 01:02:20 -0500 Subject: [PATCH 1/7] fix: return/exit 1 when an image being deployed is invalid Closes #2916 --- plugins/common/functions | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/common/functions b/plugins/common/functions index 450c1d7bd..619a0925f 100755 --- a/plugins/common/functions +++ b/plugins/common/functions @@ -744,6 +744,8 @@ release_and_deploy() { fi echo + else + return 1 fi } From 3fe0b56fb8df5dd107d518e768afc47fa009a706 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 13 Dec 2017 01:31:23 -0500 Subject: [PATCH 2/7] feat: add test --- tests/unit/40_tags.bats | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/unit/40_tags.bats b/tests/unit/40_tags.bats index dc6b1568f..6b9803203 100644 --- a/tests/unit/40_tags.bats +++ b/tests/unit/40_tags.bats @@ -46,3 +46,10 @@ teardown() { echo "status: "$status assert_success } + +@test "(tags) tags:deploy (missing tag)" { + run /bin/bash -c "dokku tags:create $TEST_APP missing-tag" + echo "output: "$output + echo "status: "$status + assert_failure +} From 4ae56cf01ca3c30f5fc2ee85f3a6284c609d2330 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 13 Dec 2017 03:16:10 -0500 Subject: [PATCH 3/7] fix: call tags:deploy --- tests/unit/40_tags.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/40_tags.bats b/tests/unit/40_tags.bats index 6b9803203..a59cbb36b 100644 --- a/tests/unit/40_tags.bats +++ b/tests/unit/40_tags.bats @@ -48,7 +48,7 @@ teardown() { } @test "(tags) tags:deploy (missing tag)" { - run /bin/bash -c "dokku tags:create $TEST_APP missing-tag" + run /bin/bash -c "dokku tags:deploy $TEST_APP missing-tag" echo "output: "$output echo "status: "$status assert_failure From 21645247fba9461d45fa120dd52a34b467a35cb6 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 13 Dec 2017 15:54:19 -0500 Subject: [PATCH 4/7] fix: scope non-zero return on invalid image to just the deploy command --- plugins/tags/subcommands/deploy | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/tags/subcommands/deploy b/plugins/tags/subcommands/deploy index ebd6ec1ac..688777aa2 100755 --- a/plugins/tags/subcommands/deploy +++ b/plugins/tags/subcommands/deploy @@ -10,7 +10,8 @@ tags_deploy_cmd() { local APP="$2"; local IMAGE_TAG="$3" verify_app_name "$APP" - release_and_deploy "$APP" "$IMAGE_TAG" + verify_image "$IMAGE" || return 1 + release_and_deploy "$APP" "$IMAGE_TAG" } tags_deploy_cmd "$@" From f1c043237543448c657680aff74c922ab19d7407 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 13 Dec 2017 15:54:43 -0500 Subject: [PATCH 5/7] fix: revert always returning 1 on error in release_and_deploy --- plugins/common/functions | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/common/functions b/plugins/common/functions index 619a0925f..450c1d7bd 100755 --- a/plugins/common/functions +++ b/plugins/common/functions @@ -744,8 +744,6 @@ release_and_deploy() { fi echo - else - return 1 fi } From af626a51ccdadca79119ba465f45eefbbecb34f2 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 13 Dec 2017 23:37:14 -0500 Subject: [PATCH 6/7] fix: set IMAGE variable correctly --- plugins/tags/subcommands/deploy | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/tags/subcommands/deploy b/plugins/tags/subcommands/deploy index 688777aa2..da9eba0a4 100755 --- a/plugins/tags/subcommands/deploy +++ b/plugins/tags/subcommands/deploy @@ -10,6 +10,7 @@ tags_deploy_cmd() { local APP="$2"; local IMAGE_TAG="$3" verify_app_name "$APP" + local IMAGE="$(get_app_image_name "$APP" "$IMAGE_TAG")" verify_image "$IMAGE" || return 1 release_and_deploy "$APP" "$IMAGE_TAG" } From 0e007a11963991e8d22047fc92cf24710e0c0970 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 13 Dec 2017 23:39:04 -0500 Subject: [PATCH 7/7] fix: declare and set variables separately --- plugins/tags/subcommands/deploy | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/tags/subcommands/deploy b/plugins/tags/subcommands/deploy index da9eba0a4..35c573595 100755 --- a/plugins/tags/subcommands/deploy +++ b/plugins/tags/subcommands/deploy @@ -6,11 +6,12 @@ source "$PLUGIN_AVAILABLE_PATH/tags/functions" tags_deploy_cmd() { declare desc="deploys an app with a given tagged image via command line" local cmd="tags:deploy" - [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" - local APP="$2"; local IMAGE_TAG="$3" + declare APP="$2" IMAGE_TAG="$3" + local IMAGE + [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" verify_app_name "$APP" - local IMAGE="$(get_app_image_name "$APP" "$IMAGE_TAG")" + IMAGE="$(get_app_image_name "$APP" "$IMAGE_TAG")" verify_image "$IMAGE" || return 1 release_and_deploy "$APP" "$IMAGE_TAG" }