Support volume and secret removal
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Luke Murphy 2021-03-04 16:55:24 +01:00
parent 2e3f4cabd8
commit 17306a753b
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
2 changed files with 112 additions and 91 deletions

View File

@ -7,6 +7,7 @@
- Detect when latest version is deployed and perform a no-op ([#87](https://git.autonomic.zone/coop-cloud/abra/issues/87))
- Allow cloning of app repos with different main branches using `-b, --branch=<branch>` ([#80](https://git.autonomic.zone/coop-cloud/abra/issues/80))
- Protect against lengthy app names which gives Docker trouble later on ([#83](https://git.autonomic.zone/coop-cloud/abra/issues/83))
- Support removal of secrets and volumes when `rm`'ing apps ([#44](https://git.autonomic.zone/coop-cloud/abra/issues/44))
# abra 0.5.0 (2021-03-01)

202
abra
View File

@ -23,7 +23,7 @@ Usage:
abra [options] app <app> logs [<service>]
abra [options] app <app> ps
abra [options] app <app> restore (<service>|--all)
abra [options] app <app> (rm|delete) [--force]
abra [options] app <app> (rm|delete) [--force] [--volumes] [--secrets]
abra [options] app <app> restore <service> [<backup file>]
abra [options] app <app> run [--no-tty] [--user=<user>] <service> <args>...
abra [options] app <app> rollback <service>
@ -154,85 +154,86 @@ 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:1930}
usage=${DOC:40:1394}; digest=b0304
shorts=(-b -C -d -s -h -U -e -v '' '' '' '' '' '' '' '' '' '' '')
longs=(--branch --skip-check --debug --stack --help --skip-update --env --verbose --status --server --domain --app-name --pass --secrets --all --update --force --no-tty --user)
argcounts=(1 0 0 1 0 0 1 0 0 1 1 1 0 0 0 0 0 0 1); node_0(){ value __branch 0; }
node_1(){ switch __skip_check 1; }; node_2(){ switch __debug 2; }; node_3(){
value __stack 3; }; node_4(){ switch __help 4; }; node_5(){
switch __skip_update 5; }; node_6(){ value __env 6; }; node_7(){
switch __verbose 7; }; node_8(){ switch __status 8; }; node_9(){
value __server 9; }; node_10(){ value __domain 10; }; node_11(){
value __app_name 11; }; node_12(){ switch __pass 12; }; node_13(){
switch __secrets 13; }; node_14(){ switch __all 14; }; node_15(){
switch __update 15; }; node_16(){ switch __force 16; }; node_17(){
switch __no_tty 17; }; node_18(){ value __user 18; }; node_19(){ value _type_ a
}; node_20(){ value _app_ a; }; node_21(){ value _service_ a; }; node_22(){
value _src_ a; }; node_23(){ value _dst_ a; }; node_24(){ value _backup_file_ a
}; node_25(){ value _args_ a true; }; node_26(){ value _secret_ a; }; node_27(){
value _version_ a; }; node_28(){ value _cmd_ a; }; node_29(){ value _data_ a; }
node_30(){ value _command_ a; }; node_31(){ value _host_ a; }; node_32(){
value _user_ a; }; node_33(){ value _port_ a; }; node_34(){
value _subcommands_ a true; }; node_35(){ _command app; }; node_36(){
_command list; }; node_37(){ _command ls; }; node_38(){ _command new; }
node_39(){ _command backup; }; node_40(){ _command deploy; }; node_41(){
_command check; }; node_42(){ _command config; }; node_43(){ _command cp; }
node_44(){ _command logs; }; node_45(){ _command ps; }; node_46(){
_command restore; }; node_47(){ _command rm; }; node_48(){ _command delete; }
node_49(){ _command run; }; node_50(){ _command rollback; }; node_51(){
_command secret; }; node_52(){ _command generate; }; node_53(){ _command insert
}; node_54(){ _command undeploy; }; node_55(){ _command server; }; node_56(){
_command add; }; node_57(){ _command init; }; node_58(){ _command apps; }
node_59(){ _command upgrade; }; node_60(){ _command version; }; node_61(){
_command help; }; node_62(){ optional 0 1 2 3 4 5 6 7; }; node_63(){ optional 62
}; node_64(){ either 36 37; }; node_65(){ required 64; }; node_66(){ optional 8
}; node_67(){ optional 9; }; node_68(){ required 63 35 65 66 67; }; node_69(){
optional 10; }; node_70(){ optional 11; }; node_71(){ optional 12; }; node_72(){
optional 13; }; node_73(){ required 63 35 38 67 69 70 71 72 19; }; node_74(){
either 21 14; }; node_75(){ required 74; }; node_76(){ required 63 35 20 39 75
}; node_77(){ optional 15; }; node_78(){ required 63 35 20 40 77; }; node_79(){
required 63 35 20 41; }; node_80(){ required 63 35 20 42; }; node_81(){
required 63 35 20 43 22 23; }; node_82(){ optional 21; }; node_83(){
required 63 35 20 44 82; }; node_84(){ required 63 35 20 45; }; node_85(){
required 63 35 20 46 75; }; node_86(){ either 47 48; }; node_87(){ required 86
}; node_88(){ optional 16; }; node_89(){ required 63 35 20 87 88; }; node_90(){
optional 24; }; node_91(){ required 63 35 20 46 21 90; }; node_92(){ optional 17
}; node_93(){ optional 18; }; node_94(){ oneormore 25; }; node_95(){
required 63 35 20 49 92 93 21 94; }; node_96(){ required 63 35 20 50 21; }
node_97(){ required 26 27; }; node_98(){ either 97 14; }; node_99(){ required 98
}; node_100(){ optional 28; }; node_101(){ required 63 35 20 51 52 99 100 71; }
node_102(){ required 63 35 20 51 53 26 27 29 71; }; node_103(){ either 26 14; }
node_104(){ required 103; }; node_105(){ required 63 35 20 51 87 104 71 88; }
node_106(){ required 63 35 20 54; }; node_107(){ optional 94; }; node_108(){
required 63 35 20 30 107; }; node_109(){ optional 32; }; node_110(){ optional 33
}; node_111(){ required 63 55 56 31 109 110; }; node_112(){ required 63 55 65; }
node_113(){ required 63 55 31 47; }; node_114(){ required 63 55 31 57; }
node_115(){ required 63 55 31 58 66; }; node_116(){ required 63 59; }
node_117(){ required 63 60; }; node_118(){ oneormore 34; }; node_119(){
optional 118; }; node_120(){ required 63 61 119; }; node_121(){ required 63; }
node_122(){
either 68 73 76 78 79 80 81 83 84 85 89 91 95 96 101 102 105 106 108 111 112 113 114 115 116 117 120 121
}; node_123(){ required 122; }; cat <<<' docopt_exit() {
[[ -n $1 ]] && printf "%s\n" "$1" >&2; printf "%s\n" "${DOC:40:1394}" >&2
exit 1; }'; unset var___branch var___skip_check var___debug var___stack \
var___help var___skip_update var___env var___verbose var___status var___server \
var___domain var___app_name var___pass var___secrets var___all var___update \
var___force var___no_tty var___user 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__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 123 "$@"; local prefix=${DOCOPT_PREFIX:-''}; unset "${prefix}__branch" \
"${prefix}__skip_check" "${prefix}__debug" "${prefix}__stack" \
"${prefix}__help" "${prefix}__skip_update" "${prefix}__env" \
"${prefix}__verbose" "${prefix}__status" "${prefix}__server" \
printf -- "exit %d\n" "$1"; exit "$1"; }; set -e; trimmed_doc=${DOC:1:1954}
usage=${DOC:40:1418}; digest=96f0f
shorts=(-s -h -U -e -d -b -v -C '' '' '' '' '' '' '' '' '' '' '' '')
longs=(--stack --help --skip-update --env --debug --branch --verbose --skip-check --status --server --domain --app-name --pass --secrets --all --update --force --volumes --no-tty --user)
argcounts=(1 0 0 1 0 1 0 0 0 1 1 1 0 0 0 0 0 0 0 1); node_0(){ value __stack 0
}; node_1(){ switch __help 1; }; node_2(){ switch __skip_update 2; }; node_3(){
value __env 3; }; node_4(){ switch __debug 4; }; node_5(){ value __branch 5; }
node_6(){ switch __verbose 6; }; node_7(){ switch __skip_check 7; }; node_8(){
switch __status 8; }; node_9(){ value __server 9; }; node_10(){
value __domain 10; }; node_11(){ value __app_name 11; }; node_12(){
switch __pass 12; }; node_13(){ switch __secrets 13; }; node_14(){
switch __all 14; }; node_15(){ switch __update 15; }; node_16(){
switch __force 16; }; node_17(){ switch __volumes 17; }; node_18(){
switch __no_tty 18; }; node_19(){ value __user 19; }; node_20(){ value _type_ a
}; node_21(){ value _app_ a; }; node_22(){ value _service_ a; }; node_23(){
value _src_ a; }; node_24(){ value _dst_ a; }; node_25(){ value _backup_file_ a
}; node_26(){ value _args_ a true; }; node_27(){ value _secret_ a; }; node_28(){
value _version_ a; }; node_29(){ value _cmd_ a; }; node_30(){ value _data_ a; }
node_31(){ value _command_ a; }; node_32(){ value _host_ a; }; node_33(){
value _user_ a; }; node_34(){ value _port_ a; }; node_35(){
value _subcommands_ a true; }; node_36(){ _command app; }; node_37(){
_command list; }; node_38(){ _command ls; }; node_39(){ _command new; }
node_40(){ _command backup; }; node_41(){ _command deploy; }; node_42(){
_command check; }; node_43(){ _command config; }; node_44(){ _command cp; }
node_45(){ _command logs; }; node_46(){ _command ps; }; node_47(){
_command restore; }; node_48(){ _command rm; }; node_49(){ _command delete; }
node_50(){ _command run; }; node_51(){ _command rollback; }; node_52(){
_command secret; }; node_53(){ _command generate; }; node_54(){ _command insert
}; node_55(){ _command undeploy; }; node_56(){ _command server; }; node_57(){
_command add; }; node_58(){ _command init; }; node_59(){ _command apps; }
node_60(){ _command upgrade; }; node_61(){ _command version; }; node_62(){
_command help; }; node_63(){ optional 0 1 2 3 4 5 6 7; }; node_64(){ optional 63
}; node_65(){ either 37 38; }; node_66(){ required 65; }; node_67(){ optional 8
}; node_68(){ optional 9; }; node_69(){ required 64 36 66 67 68; }; node_70(){
optional 10; }; node_71(){ optional 11; }; node_72(){ optional 12; }; node_73(){
optional 13; }; node_74(){ required 64 36 39 68 70 71 72 73 20; }; node_75(){
either 22 14; }; node_76(){ required 75; }; node_77(){ required 64 36 21 40 76
}; node_78(){ optional 15; }; node_79(){ required 64 36 21 41 78; }; node_80(){
required 64 36 21 42; }; node_81(){ required 64 36 21 43; }; node_82(){
required 64 36 21 44 23 24; }; node_83(){ optional 22; }; node_84(){
required 64 36 21 45 83; }; node_85(){ required 64 36 21 46; }; node_86(){
required 64 36 21 47 76; }; node_87(){ either 48 49; }; node_88(){ required 87
}; node_89(){ optional 16; }; node_90(){ optional 17; }; node_91(){
required 64 36 21 88 89 90 73; }; node_92(){ optional 25; }; node_93(){
required 64 36 21 47 22 92; }; node_94(){ optional 18; }; node_95(){ optional 19
}; node_96(){ oneormore 26; }; node_97(){ required 64 36 21 50 94 95 22 96; }
node_98(){ required 64 36 21 51 22; }; node_99(){ required 27 28; }; node_100(){
either 99 14; }; node_101(){ required 100; }; node_102(){ optional 29; }
node_103(){ required 64 36 21 52 53 101 102 72; }; node_104(){
required 64 36 21 52 54 27 28 30 72; }; node_105(){ either 27 14; }; node_106(){
required 105; }; node_107(){ required 64 36 21 52 88 106 72 89; }; node_108(){
required 64 36 21 55; }; node_109(){ optional 96; }; node_110(){
required 64 36 21 31 109; }; node_111(){ optional 33; }; node_112(){ optional 34
}; node_113(){ required 64 56 57 32 111 112; }; node_114(){ required 64 56 66; }
node_115(){ required 64 56 32 48; }; node_116(){ required 64 56 32 58; }
node_117(){ required 64 56 32 59 67; }; node_118(){ required 64 60; }
node_119(){ required 64 61; }; node_120(){ oneormore 35; }; node_121(){
optional 120; }; node_122(){ required 64 62 121; }; node_123(){ required 64; }
node_124(){
either 69 74 77 79 80 81 82 84 85 86 91 93 97 98 103 104 107 108 110 113 114 115 116 117 118 119 122 123
}; node_125(){ required 124; }; cat <<<' docopt_exit() {
[[ -n $1 ]] && printf "%s\n" "$1" >&2; printf "%s\n" "${DOC:40:1418}" >&2
exit 1; }'; unset var___stack var___help var___skip_update var___env \
var___debug var___branch var___verbose var___skip_check var___status \
var___server var___domain var___app_name var___pass var___secrets var___all \
var___update var___force var___volumes var___no_tty var___user 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__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 125 "$@"; local prefix=${DOCOPT_PREFIX:-''}
unset "${prefix}__stack" "${prefix}__help" "${prefix}__skip_update" \
"${prefix}__env" "${prefix}__debug" "${prefix}__branch" "${prefix}__verbose" \
"${prefix}__skip_check" "${prefix}__status" "${prefix}__server" \
"${prefix}__domain" "${prefix}__app_name" "${prefix}__pass" \
"${prefix}__secrets" "${prefix}__all" "${prefix}__update" "${prefix}__force" \
"${prefix}__no_tty" "${prefix}__user" "${prefix}_type_" "${prefix}_app_" \
"${prefix}_service_" "${prefix}_src_" "${prefix}_dst_" \
"${prefix}__volumes" "${prefix}__no_tty" "${prefix}__user" "${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}_subcommands_" \
@ -242,14 +243,14 @@ parse 123 "$@"; local prefix=${DOCOPT_PREFIX:-''}; unset "${prefix}__branch" \
"${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}"'__branch=${var___branch:-}'
eval "${prefix}"'__skip_check=${var___skip_check:-false}'
eval "${prefix}"'__debug=${var___debug:-false}'
eval "${prefix}"'__stack=${var___stack:-}'
"${prefix}version" "${prefix}help"; eval "${prefix}"'__stack=${var___stack:-}'
eval "${prefix}"'__help=${var___help:-false}'
eval "${prefix}"'__skip_update=${var___skip_update:-false}'
eval "${prefix}"'__env=${var___env:-}'
eval "${prefix}"'__debug=${var___debug:-false}'
eval "${prefix}"'__branch=${var___branch:-}'
eval "${prefix}"'__verbose=${var___verbose:-false}'
eval "${prefix}"'__skip_check=${var___skip_check:-false}'
eval "${prefix}"'__status=${var___status:-false}'
eval "${prefix}"'__server=${var___server:-}'
eval "${prefix}"'__domain=${var___domain:-}'
@ -259,6 +260,7 @@ eval "${prefix}"'__secrets=${var___secrets:-false}'
eval "${prefix}"'__all=${var___all:-false}'
eval "${prefix}"'__update=${var___update:-false}'
eval "${prefix}"'__force=${var___force:-false}'
eval "${prefix}"'__volumes=${var___volumes:-false}'
eval "${prefix}"'__no_tty=${var___no_tty:-false}'
eval "${prefix}"'__user=${var___user:-}'
eval "${prefix}"'_type_=${var__type_:-}'; eval "${prefix}"'_app_=${var__app_:-}'
@ -302,13 +304,13 @@ 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}__branch" "${prefix}__skip_check" "${prefix}__debug" \
"${prefix}__stack" "${prefix}__help" "${prefix}__skip_update" "${prefix}__env" \
"${prefix}__verbose" "${prefix}__status" "${prefix}__server" \
declare -p "${prefix}__stack" "${prefix}__help" "${prefix}__skip_update" \
"${prefix}__env" "${prefix}__debug" "${prefix}__branch" "${prefix}__verbose" \
"${prefix}__skip_check" "${prefix}__status" "${prefix}__server" \
"${prefix}__domain" "${prefix}__app_name" "${prefix}__pass" \
"${prefix}__secrets" "${prefix}__all" "${prefix}__update" "${prefix}__force" \
"${prefix}__no_tty" "${prefix}__user" "${prefix}_type_" "${prefix}_app_" \
"${prefix}_service_" "${prefix}_src_" "${prefix}_dst_" \
"${prefix}__volumes" "${prefix}__no_tty" "${prefix}__user" "${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}_subcommands_" \
@ -991,7 +993,8 @@ sub_app_deploy (){
help_app_undeploy (){
echo "abra [options] app <app> undeploy
Opposite of \`app <app> deploy\`; deactivate an app without deleting anything.
Opposite of \`app <app> deploy\`; deactivate an app without deleting anything. If
you want to completely delete an app, then you're looking for \`app <app> rm\`.
POWERED BY
docker stack rm <app>"
@ -1107,10 +1110,13 @@ sub_app_rm (){
help_app_delete (){
echo "abra [options] app <app> (rm|delete) [--force]
Delete local configuration for <app>.
Delete <app> completely (\"hard delete\"). All local configuration,
volumes and secrets can be removed with this command.
OPTIONS
--force Live dangerously; skip prompt for confirmation"
--force Live dangerously; skip prompt for confirmation
--volumes Delete all storage volumes
--secrets Delete all secrets"
}
sub_app_delete (){
@ -1123,6 +1129,20 @@ sub_app_delete (){
fi
rm "$ENV_FILE"
if [ "$abra___force" != "true" ] && [ "$abra___volumes" = "true" ]; then
warning "SCARY: About to remove all volumes associated with ${STACK_NAME}"
prompt_confirm
fi
docker volume rm --force "$(docker volume ls --filter \"name=${STACK_NAME}\" --quiet)"
if [ "$abra___force" != "true" ] && [ "$abra___secrets" = "true" ]; then
warning "SCARY: About to remove all secrets associated with $[STACK_NAME]"
prompt_confirm
fi
docker secret rm --force "$(docker secret ls --filter \"name=${STACK_NAME}\" --quiet)"
}
###### .. app secret insert
@ -1652,7 +1672,7 @@ abra() {
abra___secrets abra___status abra___no_tty abra___app_name \
abra__subcommands_ abra___skip_update abra___skip_check \
abra__backup_file_ abra___verbose abra___debug abra___help \
abra___update abra___branch
abra___update abra___branch abra___volumes
if ! type tput > /dev/null 2>&1; then
tput() {