From 8df91de3af8ae00411518dad453615bd1fb44fd1 Mon Sep 17 00:00:00 2001 From: decentral1se Date: Thu, 18 Mar 2021 14:12:18 +0100 Subject: [PATCH] Add --force to deploy command Closes https://git.autonomic.zone/coop-cloud/abra/issues/105. --- CHANGELOG.md | 2 + abra | 136 ++++++++++++++++++++++++++------------------------- 2 files changed, 72 insertions(+), 66 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 10265fa..7d78d41 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # abra x.x.x (UNRELEASED) +- Add `--force` to the deploy command to allow overriding deployment logic ([#105](https://git.autonomic.zone/coop-cloud/abra/issues/105)) + # abra 0.6.0 (2021-03-17) - Show version and digest of app if labelled ([98e674b8e8](https://git.autonomic.zone/coop-cloud/abra/commit/98e674b8e83458a83dcbf331e8e34c7188559c4a)) diff --git a/abra b/abra index 8c9cc38..bc56bd4 100755 --- a/abra +++ b/abra @@ -18,7 +18,7 @@ Usage: abra [options] app (list|ls) [--status] [--server=] [--type=] abra [options] app new [--server=] [--domain=] [--app-name=] [--pass] [--secrets] abra [options] app backup (|--all) - abra [options] app deploy [--update] + abra [options] app deploy [--update] [--force] abra [options] app check abra [options] app config abra [options] app cp @@ -157,16 +157,16 @@ eval "var_$1+=($value)"; else eval "var_$1=$value"; fi; return 0; fi; done return 1; }; stdout() { printf -- "cat <<'EOM'\n%s\nEOM\n" "$1"; }; stderr() { printf -- "cat <<'EOM' >&2\n%s\nEOM\n" "$1"; }; error() { [[ -n $1 ]] && stderr "$1"; stderr "$usage"; _return 1; }; _return() { -printf -- "exit %d\n" "$1"; exit "$1"; }; set -e; trimmed_doc=${DOC:1:2017} -usage=${DOC:40:1481}; digest=fd466 -shorts=(-e -U -d -v -C -s -h -b '' '' '' '' '' '' '' '' '' '' '' '' '' '') -longs=(--env --skip-update --debug --verbose --skip-check --stack --help --branch --status --server --type --domain --app-name --pass --secrets --all --update --force --volumes --no-tty --user --dev) -argcounts=(1 0 0 0 0 1 0 1 0 1 1 1 1 0 0 0 0 0 0 0 1 0); node_0(){ value __env 0 -}; node_1(){ switch __skip_update 1; }; node_2(){ switch __debug 2; }; node_3(){ -switch __verbose 3; }; node_4(){ switch __skip_check 4; }; node_5(){ -value __stack 5; }; node_6(){ switch __help 6; }; node_7(){ value __branch 7; } -node_8(){ switch __status 8; }; node_9(){ value __server 9; }; node_10(){ -value __type 10; }; node_11(){ value __domain 11; }; node_12(){ +printf -- "exit %d\n" "$1"; exit "$1"; }; set -e; trimmed_doc=${DOC:1:2027} +usage=${DOC:40:1491}; digest=64041 +shorts=(-s -e -U -d -h -v -C -b '' '' '' '' '' '' '' '' '' '' '' '' '' '') +longs=(--stack --env --skip-update --debug --help --verbose --skip-check --branch --status --server --type --domain --app-name --pass --secrets --all --update --force --volumes --no-tty --user --dev) +argcounts=(1 1 0 0 0 0 0 1 0 1 1 1 1 0 0 0 0 0 0 0 1 0); node_0(){ +value __stack 0; }; node_1(){ value __env 1; }; node_2(){ switch __skip_update 2 +}; node_3(){ switch __debug 3; }; node_4(){ switch __help 4; }; node_5(){ +switch __verbose 5; }; node_6(){ switch __skip_check 6; }; node_7(){ +value __branch 7; }; node_8(){ switch __status 8; }; node_9(){ value __server 9 +}; node_10(){ value __type 10; }; node_11(){ value __domain 11; }; node_12(){ value __app_name 12; }; node_13(){ switch __pass 13; }; node_14(){ switch __secrets 14; }; node_15(){ switch __all 15; }; node_16(){ switch __update 16; }; node_17(){ switch __force 17; }; node_18(){ @@ -196,12 +196,12 @@ required 67 39 69 70 71 72; }; node_74(){ optional 11; }; node_75(){ optional 12 }; node_76(){ optional 13; }; node_77(){ optional 14; }; node_78(){ required 67 39 42 71 74 75 76 77 22; }; node_79(){ either 24 15; }; node_80(){ required 79; }; node_81(){ required 67 39 23 43 80; }; node_82(){ optional 16; } -node_83(){ required 67 39 23 44 82; }; node_84(){ required 67 39 23 45; } -node_85(){ required 67 39 23 46; }; node_86(){ required 67 39 23 47 25 26; } -node_87(){ optional 24; }; node_88(){ required 67 39 23 48 87; }; node_89(){ -required 67 39 23 49; }; node_90(){ required 67 39 23 50 80; }; node_91(){ -either 51 52; }; node_92(){ required 91; }; node_93(){ optional 17; } -node_94(){ optional 18; }; node_95(){ required 67 39 23 92 93 94 77; } +node_83(){ optional 17; }; node_84(){ required 67 39 23 44 82 83; }; node_85(){ +required 67 39 23 45; }; node_86(){ required 67 39 23 46; }; node_87(){ +required 67 39 23 47 25 26; }; node_88(){ optional 24; }; node_89(){ +required 67 39 23 48 88; }; node_90(){ required 67 39 23 49; }; node_91(){ +required 67 39 23 50 80; }; node_92(){ either 51 52; }; node_93(){ required 92 +}; node_94(){ optional 18; }; node_95(){ required 67 39 23 93 83 94 77; } node_96(){ optional 27; }; node_97(){ required 67 39 23 50 24 96; }; node_98(){ optional 19; }; node_99(){ optional 20; }; node_100(){ oneormore 28; } node_101(){ required 67 39 23 53 98 99 24 100; }; node_102(){ @@ -209,7 +209,7 @@ required 67 39 23 54 24; }; node_103(){ required 29 30; }; node_104(){ either 103 15; }; node_105(){ required 104; }; node_106(){ optional 31; } node_107(){ required 67 39 23 55 56 105 106 76; }; node_108(){ required 67 39 23 55 57 29 30 32 76; }; node_109(){ either 29 15; }; node_110(){ -required 109; }; node_111(){ required 67 39 23 55 92 110 76 93; }; node_112(){ +required 109; }; node_111(){ required 67 39 23 55 93 110 76 83; }; node_112(){ required 67 39 23 58; }; node_113(){ optional 100; }; node_114(){ required 67 39 23 33 113; }; node_115(){ optional 35; }; node_116(){ optional 36 }; node_117(){ required 67 59 60 34 115 116; }; node_118(){ required 67 59 42 37 @@ -218,45 +218,45 @@ node_121(){ required 67 59 34 61; }; node_122(){ required 67 59 34 62 70; } node_123(){ optional 21; }; node_124(){ required 67 63 123; }; node_125(){ required 67 64; }; node_126(){ oneormore 38; }; node_127(){ optional 126; } node_128(){ required 67 65 127; }; node_129(){ required 67; }; node_130(){ -either 73 78 81 83 84 85 86 88 89 90 95 97 101 102 107 108 111 112 114 117 118 119 120 121 122 124 125 128 129 +either 73 78 81 84 85 86 87 89 90 91 95 97 101 102 107 108 111 112 114 117 118 119 120 121 122 124 125 128 129 }; node_131(){ required 130; }; cat <<<' docopt_exit() { -[[ -n $1 ]] && printf "%s\n" "$1" >&2; printf "%s\n" "${DOC:40:1481}" >&2 -exit 1; }'; unset var___env var___skip_update var___debug var___verbose \ -var___skip_check var___stack var___help var___branch var___status var___server \ -var___type var___domain var___app_name var___pass var___secrets var___all \ -var___update var___force var___volumes var___no_tty var___user var___dev \ -var__type_ var__app_ var__service_ var__src_ var__dst_ var__backup_file_ \ -var__args_ var__secret_ var__version_ var__cmd_ var__data_ var__command_ \ -var__host_ var__user_ var__port_ var__provider_ var__subcommands_ var_app \ -var_list var_ls var_new var_backup var_deploy var_check var_config var_cp \ -var_logs var_ps var_restore var_rm var_delete var_run var_rollback var_secret \ -var_generate var_insert var_undeploy var_server var_add var_init var_apps \ -var_upgrade var_version var_help; parse 131 "$@" -local prefix=${DOCOPT_PREFIX:-''}; unset "${prefix}__env" \ -"${prefix}__skip_update" "${prefix}__debug" "${prefix}__verbose" \ -"${prefix}__skip_check" "${prefix}__stack" "${prefix}__help" \ -"${prefix}__branch" "${prefix}__status" "${prefix}__server" "${prefix}__type" \ -"${prefix}__domain" "${prefix}__app_name" "${prefix}__pass" \ -"${prefix}__secrets" "${prefix}__all" "${prefix}__update" "${prefix}__force" \ -"${prefix}__volumes" "${prefix}__no_tty" "${prefix}__user" "${prefix}__dev" \ -"${prefix}_type_" "${prefix}_app_" "${prefix}_service_" "${prefix}_src_" \ -"${prefix}_dst_" "${prefix}_backup_file_" "${prefix}_args_" \ -"${prefix}_secret_" "${prefix}_version_" "${prefix}_cmd_" "${prefix}_data_" \ -"${prefix}_command_" "${prefix}_host_" "${prefix}_user_" "${prefix}_port_" \ -"${prefix}_provider_" "${prefix}_subcommands_" "${prefix}app" "${prefix}list" \ -"${prefix}ls" "${prefix}new" "${prefix}backup" "${prefix}deploy" \ -"${prefix}check" "${prefix}config" "${prefix}cp" "${prefix}logs" "${prefix}ps" \ +[[ -n $1 ]] && printf "%s\n" "$1" >&2; printf "%s\n" "${DOC:40:1491}" >&2 +exit 1; }'; unset var___stack var___env var___skip_update var___debug \ +var___help var___verbose var___skip_check var___branch var___status \ +var___server var___type var___domain var___app_name var___pass var___secrets \ +var___all var___update var___force var___volumes var___no_tty var___user \ +var___dev var__type_ var__app_ var__service_ var__src_ var__dst_ \ +var__backup_file_ var__args_ var__secret_ var__version_ var__cmd_ var__data_ \ +var__command_ var__host_ var__user_ var__port_ var__provider_ \ +var__subcommands_ var_app var_list var_ls var_new var_backup var_deploy \ +var_check var_config var_cp var_logs var_ps var_restore var_rm var_delete \ +var_run var_rollback var_secret var_generate var_insert var_undeploy \ +var_server var_add var_init var_apps var_upgrade var_version var_help +parse 131 "$@"; local prefix=${DOCOPT_PREFIX:-''}; unset "${prefix}__stack" \ +"${prefix}__env" "${prefix}__skip_update" "${prefix}__debug" "${prefix}__help" \ +"${prefix}__verbose" "${prefix}__skip_check" "${prefix}__branch" \ +"${prefix}__status" "${prefix}__server" "${prefix}__type" "${prefix}__domain" \ +"${prefix}__app_name" "${prefix}__pass" "${prefix}__secrets" "${prefix}__all" \ +"${prefix}__update" "${prefix}__force" "${prefix}__volumes" \ +"${prefix}__no_tty" "${prefix}__user" "${prefix}__dev" "${prefix}_type_" \ +"${prefix}_app_" "${prefix}_service_" "${prefix}_src_" "${prefix}_dst_" \ +"${prefix}_backup_file_" "${prefix}_args_" "${prefix}_secret_" \ +"${prefix}_version_" "${prefix}_cmd_" "${prefix}_data_" "${prefix}_command_" \ +"${prefix}_host_" "${prefix}_user_" "${prefix}_port_" "${prefix}_provider_" \ +"${prefix}_subcommands_" "${prefix}app" "${prefix}list" "${prefix}ls" \ +"${prefix}new" "${prefix}backup" "${prefix}deploy" "${prefix}check" \ +"${prefix}config" "${prefix}cp" "${prefix}logs" "${prefix}ps" \ "${prefix}restore" "${prefix}rm" "${prefix}delete" "${prefix}run" \ "${prefix}rollback" "${prefix}secret" "${prefix}generate" "${prefix}insert" \ "${prefix}undeploy" "${prefix}server" "${prefix}add" "${prefix}init" \ "${prefix}apps" "${prefix}upgrade" "${prefix}version" "${prefix}help" +eval "${prefix}"'__stack=${var___stack:-}' eval "${prefix}"'__env=${var___env:-}' eval "${prefix}"'__skip_update=${var___skip_update:-false}' eval "${prefix}"'__debug=${var___debug:-false}' +eval "${prefix}"'__help=${var___help:-false}' eval "${prefix}"'__verbose=${var___verbose:-false}' eval "${prefix}"'__skip_check=${var___skip_check:-false}' -eval "${prefix}"'__stack=${var___stack:-}' -eval "${prefix}"'__help=${var___help:-false}' eval "${prefix}"'__branch=${var___branch:-}' eval "${prefix}"'__status=${var___status:-false}' eval "${prefix}"'__server=${var___server:-}' @@ -314,19 +314,20 @@ eval "${prefix}"'upgrade=${var_upgrade:-false}' eval "${prefix}"'version=${var_version:-false}' eval "${prefix}"'help=${var_help:-false}'; local docopt_i=1 [[ $BASH_VERSION =~ ^4.3 ]] && docopt_i=2; for ((;docopt_i>0;docopt_i--)); do -declare -p "${prefix}__env" "${prefix}__skip_update" "${prefix}__debug" \ -"${prefix}__verbose" "${prefix}__skip_check" "${prefix}__stack" \ -"${prefix}__help" "${prefix}__branch" "${prefix}__status" "${prefix}__server" \ -"${prefix}__type" "${prefix}__domain" "${prefix}__app_name" "${prefix}__pass" \ -"${prefix}__secrets" "${prefix}__all" "${prefix}__update" "${prefix}__force" \ -"${prefix}__volumes" "${prefix}__no_tty" "${prefix}__user" "${prefix}__dev" \ -"${prefix}_type_" "${prefix}_app_" "${prefix}_service_" "${prefix}_src_" \ -"${prefix}_dst_" "${prefix}_backup_file_" "${prefix}_args_" \ -"${prefix}_secret_" "${prefix}_version_" "${prefix}_cmd_" "${prefix}_data_" \ -"${prefix}_command_" "${prefix}_host_" "${prefix}_user_" "${prefix}_port_" \ -"${prefix}_provider_" "${prefix}_subcommands_" "${prefix}app" "${prefix}list" \ -"${prefix}ls" "${prefix}new" "${prefix}backup" "${prefix}deploy" \ -"${prefix}check" "${prefix}config" "${prefix}cp" "${prefix}logs" "${prefix}ps" \ +declare -p "${prefix}__stack" "${prefix}__env" "${prefix}__skip_update" \ +"${prefix}__debug" "${prefix}__help" "${prefix}__verbose" \ +"${prefix}__skip_check" "${prefix}__branch" "${prefix}__status" \ +"${prefix}__server" "${prefix}__type" "${prefix}__domain" \ +"${prefix}__app_name" "${prefix}__pass" "${prefix}__secrets" "${prefix}__all" \ +"${prefix}__update" "${prefix}__force" "${prefix}__volumes" \ +"${prefix}__no_tty" "${prefix}__user" "${prefix}__dev" "${prefix}_type_" \ +"${prefix}_app_" "${prefix}_service_" "${prefix}_src_" "${prefix}_dst_" \ +"${prefix}_backup_file_" "${prefix}_args_" "${prefix}_secret_" \ +"${prefix}_version_" "${prefix}_cmd_" "${prefix}_data_" "${prefix}_command_" \ +"${prefix}_host_" "${prefix}_user_" "${prefix}_port_" "${prefix}_provider_" \ +"${prefix}_subcommands_" "${prefix}app" "${prefix}list" "${prefix}ls" \ +"${prefix}new" "${prefix}backup" "${prefix}deploy" "${prefix}check" \ +"${prefix}config" "${prefix}cp" "${prefix}logs" "${prefix}ps" \ "${prefix}restore" "${prefix}rm" "${prefix}delete" "${prefix}run" \ "${prefix}rollback" "${prefix}secret" "${prefix}generate" "${prefix}insert" \ "${prefix}undeploy" "${prefix}server" "${prefix}add" "${prefix}init" \ @@ -503,6 +504,7 @@ output_version_summary() { echo " Versions:" CONSENT_TO_UPDATE=$abra___update + FORCE_DEPLOY=$abra___force local -a IS_AN_UPDATE="false" local -a UNABLE_TO_DETECT="false" @@ -547,13 +549,11 @@ output_version_summary() { done done - if [[ $IS_AN_UPDATE == "true" ]]; then + if [[ $IS_AN_UPDATE == "true" ]] && [[ $FORCE_DEPLOY != "true" ]]; then require_consent_for_update else - # Note(decentral1se): in the cases where we couldn't detect a version we - # shouldn't block an update and the end-user can still make progress - if [[ ! $UNABLE_TO_DETECT == "true" ]]; then - success "Nothing to deploy, you're on latest" + if [[ ! $UNABLE_TO_DETECT == "true" ]] && [[ $FORCE_DEPLOY != "true" ]]; then + success "Nothing to deploy, you're on latest (use --force to re-deploy anyway)" exit 0 fi fi @@ -1014,6 +1014,8 @@ sub_app_deploy (){ require_yq require_app_latest "$TYPE" + FORCE_DEPLOY=$abra___force + echo "Deployment overview:" echo " Server: $(tput setaf 4)${SERVER}$(tput sgr0)" @@ -1036,7 +1038,9 @@ sub_app_deploy (){ output_version_summary - prompt_confirm + if [[ $FORCE_DEPLOY != "true" ]]; then + prompt_confirm + fi APP=$(basename "$APP_DIR")