Add service rollback

Closes coop-cloud/abra#76.
This commit is contained in:
Luke Murphy 2021-03-04 13:10:51 +01:00
parent 7f5e753dfd
commit 0bbff91722
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC

171
abra
View File

@ -26,6 +26,7 @@ Usage:
abra [options] app <app> (rm|delete) [--force] abra [options] app <app> (rm|delete) [--force]
abra [options] app <app> restore <service> [<backup file>] abra [options] app <app> restore <service> [<backup file>]
abra [options] app <app> run [--no-tty] [--user=<user>] <service> <args>... abra [options] app <app> run [--no-tty] [--user=<user>] <service> <args>...
abra [options] app <app> rollback <service>
abra [options] app <app> secret generate (<secret> <version>|--all) [<cmd>] [--pass] abra [options] app <app> secret generate (<secret> <version>|--all) [<cmd>] [--pass]
abra [options] app <app> secret insert <secret> <version> <data> [--pass] abra [options] app <app> secret insert <secret> <version> <data> [--pass]
abra [options] app <app> secret (rm|delete) (<secret>|--all) [--pass] [--force] abra [options] app <app> secret (rm|delete) (<secret>|--all) [--pass] [--force]
@ -152,15 +153,15 @@ 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() { return 1; }; stdout() { printf -- "cat <<'EOM'\n%s\nEOM\n" "$1"; }; stderr() {
printf -- "cat <<'EOM' >&2\n%s\nEOM\n" "$1"; }; error() { printf -- "cat <<'EOM' >&2\n%s\nEOM\n" "$1"; }; error() {
[[ -n $1 ]] && stderr "$1"; stderr "$usage"; _return 1; }; _return() { [[ -n $1 ]] && stderr "$1"; stderr "$usage"; _return 1; }; _return() {
printf -- "exit %d\n" "$1"; exit "$1"; }; set -e; trimmed_doc=${DOC:1:1811} printf -- "exit %d\n" "$1"; exit "$1"; }; set -e; trimmed_doc=${DOC:1:1857}
usage=${DOC:40:1348}; digest=4fa25 usage=${DOC:40:1394}; digest=42e85
shorts=(-v -s -C -U -h -e -d '' '' '' '' '' '' '' '' '' '' '') shorts=(-v -U -C -h -e -d -s '' '' '' '' '' '' '' '' '' '' '')
longs=(--verbose --stack --skip-check --skip-update --help --env --debug --status --server --domain --app-name --pass --secrets --all --update --force --no-tty --user) longs=(--verbose --skip-update --skip-check --help --env --debug --stack --status --server --domain --app-name --pass --secrets --all --update --force --no-tty --user)
argcounts=(0 1 0 0 0 1 0 0 1 1 1 0 0 0 0 0 0 1); node_0(){ switch __verbose 0; } argcounts=(0 0 0 0 1 0 1 0 1 1 1 0 0 0 0 0 0 1); node_0(){ switch __verbose 0; }
node_1(){ value __stack 1; }; node_2(){ switch __skip_check 2; }; node_3(){ node_1(){ switch __skip_update 1; }; node_2(){ switch __skip_check 2; }
switch __skip_update 3; }; node_4(){ switch __help 4; }; node_5(){ value __env 5 node_3(){ switch __help 3; }; node_4(){ value __env 4; }; node_5(){
}; node_6(){ switch __debug 6; }; node_7(){ switch __status 7; }; node_8(){ switch __debug 5; }; node_6(){ value __stack 6; }; node_7(){ switch __status 7
value __server 8; }; node_9(){ value __domain 9; }; node_10(){ }; node_8(){ value __server 8; }; node_9(){ value __domain 9; }; node_10(){
value __app_name 10; }; node_11(){ switch __pass 11; }; node_12(){ value __app_name 10; }; node_11(){ switch __pass 11; }; node_12(){
switch __secrets 12; }; node_13(){ switch __all 13; }; node_14(){ switch __secrets 12; }; node_13(){ switch __all 13; }; node_14(){
switch __update 14; }; node_15(){ switch __force 15; }; node_16(){ switch __update 14; }; node_15(){ switch __force 15; }; node_16(){
@ -177,74 +178,75 @@ node_38(){ _command backup; }; node_39(){ _command deploy; }; node_40(){
_command check; }; node_41(){ _command config; }; node_42(){ _command cp; } _command check; }; node_41(){ _command config; }; node_42(){ _command cp; }
node_43(){ _command logs; }; node_44(){ _command ps; }; node_45(){ node_43(){ _command logs; }; node_44(){ _command ps; }; node_45(){
_command restore; }; node_46(){ _command rm; }; node_47(){ _command delete; } _command restore; }; node_46(){ _command rm; }; node_47(){ _command delete; }
node_48(){ _command run; }; node_49(){ _command secret; }; node_50(){ node_48(){ _command run; }; node_49(){ _command rollback; }; node_50(){
_command generate; }; node_51(){ _command insert; }; node_52(){ _command secret; }; node_51(){ _command generate; }; node_52(){ _command insert
_command undeploy; }; node_53(){ _command server; }; node_54(){ _command add; } }; node_53(){ _command undeploy; }; node_54(){ _command server; }; node_55(){
node_55(){ _command init; }; node_56(){ _command apps; }; node_57(){ _command add; }; node_56(){ _command init; }; node_57(){ _command apps; }
_command upgrade; }; node_58(){ _command version; }; node_59(){ _command help; } node_58(){ _command upgrade; }; node_59(){ _command version; }; node_60(){
node_60(){ optional 0 1 2 3 4 5 6; }; node_61(){ optional 60; }; node_62(){ _command help; }; node_61(){ optional 0 1 2 3 4 5 6; }; node_62(){ optional 61
either 35 36; }; node_63(){ required 62; }; node_64(){ optional 7; }; node_65(){ }; node_63(){ either 35 36; }; node_64(){ required 63; }; node_65(){ optional 7
optional 8; }; node_66(){ required 61 34 63 64 65; }; node_67(){ optional 9; } }; node_66(){ optional 8; }; node_67(){ required 62 34 64 65 66; }; node_68(){
node_68(){ optional 10; }; node_69(){ optional 11; }; node_70(){ optional 12; } optional 9; }; node_69(){ optional 10; }; node_70(){ optional 11; }; node_71(){
node_71(){ required 61 34 37 65 67 68 69 70 18; }; node_72(){ either 20 13; } optional 12; }; node_72(){ required 62 34 37 66 68 69 70 71 18; }; node_73(){
node_73(){ required 72; }; node_74(){ required 61 34 19 38 73; }; node_75(){ either 20 13; }; node_74(){ required 73; }; node_75(){ required 62 34 19 38 74
optional 14; }; node_76(){ required 61 34 19 39 75; }; node_77(){ }; node_76(){ optional 14; }; node_77(){ required 62 34 19 39 76; }; node_78(){
required 61 34 19 40; }; node_78(){ required 61 34 19 41; }; node_79(){ required 62 34 19 40; }; node_79(){ required 62 34 19 41; }; node_80(){
required 61 34 19 42 21 22; }; node_80(){ optional 20; }; node_81(){ required 62 34 19 42 21 22; }; node_81(){ optional 20; }; node_82(){
required 61 34 19 43 80; }; node_82(){ required 61 34 19 44; }; node_83(){ required 62 34 19 43 81; }; node_83(){ required 62 34 19 44; }; node_84(){
required 61 34 19 45 73; }; node_84(){ either 46 47; }; node_85(){ required 84 required 62 34 19 45 74; }; node_85(){ either 46 47; }; node_86(){ required 85
}; node_86(){ optional 15; }; node_87(){ required 61 34 19 85 86; }; node_88(){ }; node_87(){ optional 15; }; node_88(){ required 62 34 19 86 87; }; node_89(){
optional 23; }; node_89(){ required 61 34 19 45 20 88; }; node_90(){ optional 16 optional 23; }; node_90(){ required 62 34 19 45 20 89; }; node_91(){ optional 16
}; node_91(){ optional 17; }; node_92(){ oneormore 24; }; node_93(){ }; node_92(){ optional 17; }; node_93(){ oneormore 24; }; node_94(){
required 61 34 19 48 90 91 20 92; }; node_94(){ required 25 26; }; node_95(){ required 62 34 19 48 91 92 20 93; }; node_95(){ required 62 34 19 49 20; }
either 94 13; }; node_96(){ required 95; }; node_97(){ optional 27; } node_96(){ required 25 26; }; node_97(){ either 96 13; }; node_98(){ required 97
node_98(){ required 61 34 19 49 50 96 97 69; }; node_99(){ }; node_99(){ optional 27; }; node_100(){ required 62 34 19 50 51 98 99 70; }
required 61 34 19 49 51 25 26 28 69; }; node_100(){ either 25 13; }; node_101(){ node_101(){ required 62 34 19 50 52 25 26 28 70; }; node_102(){ either 25 13; }
required 100; }; node_102(){ required 61 34 19 49 85 101 69 86; }; node_103(){ node_103(){ required 102; }; node_104(){ required 62 34 19 50 86 103 70 87; }
required 61 34 19 52; }; node_104(){ optional 92; }; node_105(){ node_105(){ required 62 34 19 53; }; node_106(){ optional 93; }; node_107(){
required 61 34 19 29 104; }; node_106(){ optional 31; }; node_107(){ optional 32 required 62 34 19 29 106; }; node_108(){ optional 31; }; node_109(){ optional 32
}; node_108(){ required 61 53 54 30 106 107; }; node_109(){ required 61 53 63; } }; node_110(){ required 62 54 55 30 108 109; }; node_111(){ required 62 54 64; }
node_110(){ required 61 53 30 46; }; node_111(){ required 61 53 30 55; } node_112(){ required 62 54 30 46; }; node_113(){ required 62 54 30 56; }
node_112(){ required 61 53 30 56 64; }; node_113(){ required 61 57; } node_114(){ required 62 54 30 57 65; }; node_115(){ required 62 58; }
node_114(){ required 61 58; }; node_115(){ oneormore 33; }; node_116(){ node_116(){ required 62 59; }; node_117(){ oneormore 33; }; node_118(){
optional 115; }; node_117(){ required 61 59 116; }; node_118(){ required 61; } optional 117; }; node_119(){ required 62 60 118; }; node_120(){ required 62; }
node_119(){ node_121(){
either 66 71 74 76 77 78 79 81 82 83 87 89 93 98 99 102 103 105 108 109 110 111 112 113 114 117 118 either 67 72 75 77 78 79 80 82 83 84 88 90 94 95 100 101 104 105 107 110 111 112 113 114 115 116 119 120
}; node_120(){ required 119; }; cat <<<' docopt_exit() { }; node_122(){ required 121; }; cat <<<' docopt_exit() {
[[ -n $1 ]] && printf "%s\n" "$1" >&2; printf "%s\n" "${DOC:40:1348}" >&2 [[ -n $1 ]] && printf "%s\n" "$1" >&2; printf "%s\n" "${DOC:40:1394}" >&2
exit 1; }'; unset var___verbose var___stack var___skip_check var___skip_update \ exit 1; }'; unset var___verbose var___skip_update var___skip_check var___help \
var___help var___env var___debug var___status var___server var___domain \ var___env var___debug var___stack var___status var___server var___domain \
var___app_name var___pass var___secrets var___all var___update var___force \ 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___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__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__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_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_secret var_generate \ var_logs var_ps var_restore var_rm var_delete var_run var_rollback var_secret \
var_insert var_undeploy var_server var_add var_init var_apps var_upgrade \ var_generate var_insert var_undeploy var_server var_add var_init var_apps \
var_version var_help; parse 120 "$@"; local prefix=${DOCOPT_PREFIX:-''} var_upgrade var_version var_help; parse 122 "$@"
unset "${prefix}__verbose" "${prefix}__stack" "${prefix}__skip_check" \ local prefix=${DOCOPT_PREFIX:-''}; unset "${prefix}__verbose" \
"${prefix}__skip_update" "${prefix}__help" "${prefix}__env" "${prefix}__debug" \ "${prefix}__skip_update" "${prefix}__skip_check" "${prefix}__help" \
"${prefix}__status" "${prefix}__server" "${prefix}__domain" \ "${prefix}__env" "${prefix}__debug" "${prefix}__stack" "${prefix}__status" \
"${prefix}__app_name" "${prefix}__pass" "${prefix}__secrets" "${prefix}__all" \ "${prefix}__server" "${prefix}__domain" "${prefix}__app_name" \
"${prefix}__update" "${prefix}__force" "${prefix}__no_tty" "${prefix}__user" \ "${prefix}__pass" "${prefix}__secrets" "${prefix}__all" "${prefix}__update" \
"${prefix}_type_" "${prefix}_app_" "${prefix}_service_" "${prefix}_src_" \ "${prefix}__force" "${prefix}__no_tty" "${prefix}__user" "${prefix}_type_" \
"${prefix}_dst_" "${prefix}_backup_file_" "${prefix}_args_" \ "${prefix}_app_" "${prefix}_service_" "${prefix}_src_" "${prefix}_dst_" \
"${prefix}_secret_" "${prefix}_version_" "${prefix}_cmd_" "${prefix}_data_" \ "${prefix}_backup_file_" "${prefix}_args_" "${prefix}_secret_" \
"${prefix}_command_" "${prefix}_host_" "${prefix}_user_" "${prefix}_port_" \ "${prefix}_version_" "${prefix}_cmd_" "${prefix}_data_" "${prefix}_command_" \
"${prefix}_subcommands_" "${prefix}app" "${prefix}list" "${prefix}ls" \ "${prefix}_host_" "${prefix}_user_" "${prefix}_port_" "${prefix}_subcommands_" \
"${prefix}new" "${prefix}backup" "${prefix}deploy" "${prefix}check" \ "${prefix}app" "${prefix}list" "${prefix}ls" "${prefix}new" "${prefix}backup" \
"${prefix}config" "${prefix}cp" "${prefix}logs" "${prefix}ps" \ "${prefix}deploy" "${prefix}check" "${prefix}config" "${prefix}cp" \
"${prefix}restore" "${prefix}rm" "${prefix}delete" "${prefix}run" \ "${prefix}logs" "${prefix}ps" "${prefix}restore" "${prefix}rm" \
"${prefix}secret" "${prefix}generate" "${prefix}insert" "${prefix}undeploy" \ "${prefix}delete" "${prefix}run" "${prefix}rollback" "${prefix}secret" \
"${prefix}server" "${prefix}add" "${prefix}init" "${prefix}apps" \ "${prefix}generate" "${prefix}insert" "${prefix}undeploy" "${prefix}server" \
"${prefix}upgrade" "${prefix}version" "${prefix}help" "${prefix}add" "${prefix}init" "${prefix}apps" "${prefix}upgrade" \
"${prefix}version" "${prefix}help"
eval "${prefix}"'__verbose=${var___verbose:-false}' eval "${prefix}"'__verbose=${var___verbose:-false}'
eval "${prefix}"'__stack=${var___stack:-}'
eval "${prefix}"'__skip_check=${var___skip_check:-false}'
eval "${prefix}"'__skip_update=${var___skip_update:-false}' eval "${prefix}"'__skip_update=${var___skip_update:-false}'
eval "${prefix}"'__skip_check=${var___skip_check:-false}'
eval "${prefix}"'__help=${var___help:-false}' eval "${prefix}"'__help=${var___help:-false}'
eval "${prefix}"'__env=${var___env:-}' eval "${prefix}"'__env=${var___env:-}'
eval "${prefix}"'__debug=${var___debug:-false}' eval "${prefix}"'__debug=${var___debug:-false}'
eval "${prefix}"'__stack=${var___stack:-}'
eval "${prefix}"'__status=${var___status:-false}' eval "${prefix}"'__status=${var___status:-false}'
eval "${prefix}"'__server=${var___server:-}' eval "${prefix}"'__server=${var___server:-}'
eval "${prefix}"'__domain=${var___domain:-}' eval "${prefix}"'__domain=${var___domain:-}'
@ -284,6 +286,7 @@ eval "${prefix}"'restore=${var_restore:-false}'
eval "${prefix}"'rm=${var_rm:-false}' eval "${prefix}"'rm=${var_rm:-false}'
eval "${prefix}"'delete=${var_delete:-false}' eval "${prefix}"'delete=${var_delete:-false}'
eval "${prefix}"'run=${var_run:-false}' eval "${prefix}"'run=${var_run:-false}'
eval "${prefix}"'rollback=${var_rollback:-false}'
eval "${prefix}"'secret=${var_secret:-false}' eval "${prefix}"'secret=${var_secret:-false}'
eval "${prefix}"'generate=${var_generate:-false}' eval "${prefix}"'generate=${var_generate:-false}'
eval "${prefix}"'insert=${var_insert:-false}' eval "${prefix}"'insert=${var_insert:-false}'
@ -296,9 +299,9 @@ eval "${prefix}"'upgrade=${var_upgrade:-false}'
eval "${prefix}"'version=${var_version:-false}' eval "${prefix}"'version=${var_version:-false}'
eval "${prefix}"'help=${var_help:-false}'; local docopt_i=1 eval "${prefix}"'help=${var_help:-false}'; local docopt_i=1
[[ $BASH_VERSION =~ ^4.3 ]] && docopt_i=2; for ((;docopt_i>0;docopt_i--)); do [[ $BASH_VERSION =~ ^4.3 ]] && docopt_i=2; for ((;docopt_i>0;docopt_i--)); do
declare -p "${prefix}__verbose" "${prefix}__stack" "${prefix}__skip_check" \ declare -p "${prefix}__verbose" "${prefix}__skip_update" \
"${prefix}__skip_update" "${prefix}__help" "${prefix}__env" "${prefix}__debug" \ "${prefix}__skip_check" "${prefix}__help" "${prefix}__env" "${prefix}__debug" \
"${prefix}__status" "${prefix}__server" "${prefix}__domain" \ "${prefix}__stack" "${prefix}__status" "${prefix}__server" "${prefix}__domain" \
"${prefix}__app_name" "${prefix}__pass" "${prefix}__secrets" "${prefix}__all" \ "${prefix}__app_name" "${prefix}__pass" "${prefix}__secrets" "${prefix}__all" \
"${prefix}__update" "${prefix}__force" "${prefix}__no_tty" "${prefix}__user" \ "${prefix}__update" "${prefix}__force" "${prefix}__no_tty" "${prefix}__user" \
"${prefix}_type_" "${prefix}_app_" "${prefix}_service_" "${prefix}_src_" \ "${prefix}_type_" "${prefix}_app_" "${prefix}_service_" "${prefix}_src_" \
@ -309,9 +312,9 @@ declare -p "${prefix}__verbose" "${prefix}__stack" "${prefix}__skip_check" \
"${prefix}new" "${prefix}backup" "${prefix}deploy" "${prefix}check" \ "${prefix}new" "${prefix}backup" "${prefix}deploy" "${prefix}check" \
"${prefix}config" "${prefix}cp" "${prefix}logs" "${prefix}ps" \ "${prefix}config" "${prefix}cp" "${prefix}logs" "${prefix}ps" \
"${prefix}restore" "${prefix}rm" "${prefix}delete" "${prefix}run" \ "${prefix}restore" "${prefix}rm" "${prefix}delete" "${prefix}run" \
"${prefix}secret" "${prefix}generate" "${prefix}insert" "${prefix}undeploy" \ "${prefix}rollback" "${prefix}secret" "${prefix}generate" "${prefix}insert" \
"${prefix}server" "${prefix}add" "${prefix}init" "${prefix}apps" \ "${prefix}undeploy" "${prefix}server" "${prefix}add" "${prefix}init" \
"${prefix}upgrade" "${prefix}version" "${prefix}help"; done; } "${prefix}apps" "${prefix}upgrade" "${prefix}version" "${prefix}help"; done; }
# docopt parser above, complete command for generating this parser is `docopt.sh abra` # docopt parser above, complete command for generating this parser is `docopt.sh abra`
PROGRAM_NAME=$(basename "$0") PROGRAM_NAME=$(basename "$0")
@ -1294,6 +1297,28 @@ sub_app_run(){
return return
} }
###### .. app rollback
help_app_rollback (){
echo "abra [options] app <app> rollback <service>
Rollback a deployed app service to a previous version.
EXAMPLES
abra app wordpress rollback app
POWERED BY
docker service rollback \$CONTAINER_ID ..."
}
sub_app_rollback(){
load_instance
load_instance_env
SERVICE="${abra__service_}"
docker service rollback "${STACK_NAME}_${SERVICE}"
}
###### .. app logs ###### .. app logs
help_app_logs (){ help_app_logs (){
echo "abra [options] app <app> logs [<service>] echo "abra [options] app <app> logs [<service>]