Rejig rollback, add <version> to deploy

Ref #132
This commit is contained in:
3wc 2021-04-04 20:20:54 +02:00
parent 8b60ece3d4
commit 33280f90b3

269
abra
View File

@ -18,7 +18,7 @@ Usage:
abra [options] app (list|ls) [--status] [--server=<server>] [--type=<type>] abra [options] app (list|ls) [--status] [--server=<server>] [--type=<type>]
abra [options] app new [--server=<server>] [--domain=<domain>] [--app-name=<app_name>] [--pass] [--secrets] <type> abra [options] app new [--server=<server>] [--domain=<domain>] [--app-name=<app_name>] [--pass] [--secrets] <type>
abra [options] app <app> backup (<service>|--all) abra [options] app <app> backup (<service>|--all)
abra [options] app <app> deploy [--update] [--force] [--skip-version-check] abra [options] app <app> deploy [--update] [--force] [--skip-version-check] [<version>]
abra [options] app <app> check abra [options] app <app> check
abra [options] app <app> version abra [options] app <app> version
abra [options] app <app> config abra [options] app <app> config
@ -29,7 +29,7 @@ Usage:
abra [options] app <app> (rm|delete) [--volumes] [--secrets] abra [options] app <app> (rm|delete) [--volumes] [--secrets]
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> rollback [<version>]
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] abra [options] app <app> secret (rm|delete) (<secret>|--all) [--pass]
@ -162,15 +162,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:2231} printf -- "exit %d\n" "$1"; exit "$1"; }; set -e; trimmed_doc=${DOC:1:2245}
usage=${DOC:40:1622}; digest=22c5b usage=${DOC:40:1636}; digest=ba0b1
shorts=(-h -b -n -s -e -d -C -v -U '' '' '' '' '' '' '' '' '' '' '' '' '' '' '') shorts=(-C -d -s -h -v -U -e -b -n '' '' '' '' '' '' '' '' '' '' '' '' '' '' '')
longs=(--help --branch --no-prompt --stack --env --debug --skip-check --verbose --skip-update --status --server --type --domain --app-name --pass --secrets --all --update --force --skip-version-check --volumes --no-tty --user --dev) longs=(--skip-check --debug --stack --help --verbose --skip-update --env --branch --no-prompt --status --server --type --domain --app-name --pass --secrets --all --update --force --skip-version-check --volumes --no-tty --user --dev)
argcounts=(0 1 0 1 1 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 1 0); node_0(){ argcounts=(0 0 1 0 0 0 1 1 0 0 1 1 1 1 0 0 0 0 0 0 0 0 1 0); node_0(){
switch __help 0; }; node_1(){ value __branch 1; }; node_2(){ switch __skip_check 0; }; node_1(){ switch __debug 1; }; node_2(){
switch __no_prompt 2; }; node_3(){ value __stack 3; }; node_4(){ value __env 4 value __stack 2; }; node_3(){ switch __help 3; }; node_4(){ switch __verbose 4
}; node_5(){ switch __debug 5; }; node_6(){ switch __skip_check 6; }; node_7(){ }; node_5(){ switch __skip_update 5; }; node_6(){ value __env 6; }; node_7(){
switch __verbose 7; }; node_8(){ switch __skip_update 8; }; node_9(){ value __branch 7; }; node_8(){ switch __no_prompt 8; }; node_9(){
switch __status 9; }; node_10(){ value __server 10; }; node_11(){ switch __status 9; }; node_10(){ value __server 10; }; node_11(){
value __type 11; }; node_12(){ value __domain 12; }; node_13(){ value __type 11; }; node_12(){ value __domain 12; }; node_13(){
value __app_name 13; }; node_14(){ switch __pass 14; }; node_15(){ value __app_name 13; }; node_14(){ switch __pass 14; }; node_15(){
@ -179,15 +179,15 @@ switch __update 17; }; node_18(){ switch __force 18; }; node_19(){
switch __skip_version_check 19; }; node_20(){ switch __volumes 20; }; node_21(){ switch __skip_version_check 19; }; node_20(){ switch __volumes 20; }; node_21(){
switch __no_tty 21; }; node_22(){ value __user 22; }; node_23(){ switch __dev 23 switch __no_tty 21; }; node_22(){ value __user 22; }; node_23(){ switch __dev 23
}; node_24(){ value _type_ a; }; node_25(){ value _app_ a; }; node_26(){ }; node_24(){ value _type_ a; }; node_25(){ value _app_ a; }; node_26(){
value _service_ a; }; node_27(){ value _src_ a; }; node_28(){ value _dst_ a; } value _service_ a; }; node_27(){ value _version_ a; }; node_28(){ value _src_ a
node_29(){ value _backup_file_ a; }; node_30(){ value _args_ a true; } }; node_29(){ value _dst_ a; }; node_30(){ value _backup_file_ a; }; node_31(){
node_31(){ value _secret_ a; }; node_32(){ value _version_ a; }; node_33(){ value _args_ a true; }; node_32(){ value _secret_ a; }; node_33(){ value _cmd_ a
value _cmd_ a; }; node_34(){ value _data_ a; }; node_35(){ value _command_ a; } }; node_34(){ value _data_ a; }; node_35(){ value _command_ a; }; node_36(){
node_36(){ value _recipe_ a; }; node_37(){ value _host_ a; }; node_38(){ value _recipe_ a; }; node_37(){ value _host_ a; }; node_38(){ value _user_ a; }
value _user_ a; }; node_39(){ value _port_ a; }; node_40(){ value _provider_ a node_39(){ value _port_ a; }; node_40(){ value _provider_ a; }; node_41(){
}; node_41(){ value _subcommands_ a true; }; node_42(){ _command app; } value _subcommands_ a true; }; node_42(){ _command app; }; node_43(){
node_43(){ _command list; }; node_44(){ _command ls; }; node_45(){ _command new _command list; }; node_44(){ _command ls; }; node_45(){ _command new; }
}; node_46(){ _command backup; }; node_47(){ _command deploy; }; node_48(){ node_46(){ _command backup; }; node_47(){ _command deploy; }; node_48(){
_command check; }; node_49(){ _command version; }; node_50(){ _command config; } _command check; }; node_49(){ _command version; }; node_50(){ _command config; }
node_51(){ _command cp; }; node_52(){ _command logs; }; node_53(){ _command ps node_51(){ _command cp; }; node_52(){ _command logs; }; node_53(){ _command ps
}; node_54(){ _command restore; }; node_55(){ _command rm; }; node_56(){ }; node_54(){ _command restore; }; node_55(){ _command rm; }; node_56(){
@ -204,75 +204,76 @@ node_79(){ required 73 42 75 76 77 78; }; node_80(){ optional 12; }; node_81(){
optional 13; }; node_82(){ optional 14; }; node_83(){ optional 15; }; node_84(){ optional 13; }; node_82(){ optional 14; }; node_83(){ optional 15; }; node_84(){
required 73 42 45 77 80 81 82 83 24; }; node_85(){ either 26 16; }; node_86(){ required 73 42 45 77 80 81 82 83 24; }; node_85(){ either 26 16; }; node_86(){
required 85; }; node_87(){ required 73 42 25 46 86; }; node_88(){ optional 17; } required 85; }; node_87(){ required 73 42 25 46 86; }; node_88(){ optional 17; }
node_89(){ optional 18; }; node_90(){ optional 19; }; node_91(){ node_89(){ optional 18; }; node_90(){ optional 19; }; node_91(){ optional 27; }
required 73 42 25 47 88 89 90; }; node_92(){ required 73 42 25 48; }; node_93(){ node_92(){ required 73 42 25 47 88 89 90 91; }; node_93(){ required 73 42 25 48
required 73 42 25 49; }; node_94(){ required 73 42 25 50; }; node_95(){ }; node_94(){ required 73 42 25 49; }; node_95(){ required 73 42 25 50; }
required 73 42 25 51 27 28; }; node_96(){ optional 26; }; node_97(){ node_96(){ required 73 42 25 51 28 29; }; node_97(){ optional 26; }; node_98(){
required 73 42 25 52 96; }; node_98(){ required 73 42 25 53; }; node_99(){ required 73 42 25 52 97; }; node_99(){ required 73 42 25 53; }; node_100(){
required 73 42 25 54 86; }; node_100(){ either 55 56; }; node_101(){ required 73 42 25 54 86; }; node_101(){ either 55 56; }; node_102(){
required 100; }; node_102(){ optional 20; }; node_103(){ required 101; }; node_103(){ optional 20; }; node_104(){
required 73 42 25 101 102 83; }; node_104(){ optional 29; }; node_105(){ required 73 42 25 102 103 83; }; node_105(){ optional 30; }; node_106(){
required 73 42 25 54 26 104; }; node_106(){ optional 21; }; node_107(){ required 73 42 25 54 26 105; }; node_107(){ optional 21; }; node_108(){
optional 22; }; node_108(){ oneormore 30; }; node_109(){ optional 22; }; node_109(){ oneormore 31; }; node_110(){
required 73 42 25 57 106 107 26 108; }; node_110(){ required 73 42 25 58 26; } required 73 42 25 57 107 108 26 109; }; node_111(){ required 73 42 25 58 91; }
node_111(){ required 31 32; }; node_112(){ either 111 16; }; node_113(){ node_112(){ required 32 27; }; node_113(){ either 112 16; }; node_114(){
required 112; }; node_114(){ optional 33; }; node_115(){ required 113; }; node_115(){ optional 33; }; node_116(){
required 73 42 25 59 60 113 114 82; }; node_116(){ required 73 42 25 59 60 114 115 82; }; node_117(){
required 73 42 25 59 61 31 32 34 82; }; node_117(){ either 31 16; }; node_118(){ required 73 42 25 59 61 32 27 34 82; }; node_118(){ either 32 16; }; node_119(){
required 117; }; node_119(){ required 73 42 25 59 101 118 82; }; node_120(){ required 118; }; node_120(){ required 73 42 25 59 102 119 82; }; node_121(){
required 73 42 25 62; }; node_121(){ optional 108; }; node_122(){ required 73 42 25 62; }; node_122(){ optional 109; }; node_123(){
required 73 42 25 35 121; }; node_123(){ required 73 63 44; }; node_124(){ required 73 42 25 35 122; }; node_124(){ required 73 63 44; }; node_125(){
required 73 63 36 64; }; node_125(){ optional 38; }; node_126(){ optional 39; } required 73 63 36 64; }; node_126(){ optional 38; }; node_127(){ optional 39; }
node_127(){ required 73 65 66 37 125 126; }; node_128(){ required 73 65 45 40; } node_128(){ required 73 65 66 37 126 127; }; node_129(){ required 73 65 45 40; }
node_129(){ required 73 65 75; }; node_130(){ required 73 65 37 55; } node_130(){ required 73 65 75; }; node_131(){ required 73 65 37 55; }
node_131(){ required 73 65 37 67; }; node_132(){ required 73 65 37 68 76; } node_132(){ required 73 65 37 67; }; node_133(){ required 73 65 37 68 76; }
node_133(){ optional 23; }; node_134(){ required 73 69 133; }; node_135(){ node_134(){ optional 23; }; node_135(){ required 73 69 134; }; node_136(){
required 73 49; }; node_136(){ required 73 70; }; node_137(){ oneormore 41; } required 73 49; }; node_137(){ required 73 70; }; node_138(){ oneormore 41; }
node_138(){ optional 137; }; node_139(){ required 73 71 138; }; node_140(){ node_139(){ optional 138; }; node_140(){ required 73 71 139; }; node_141(){
required 73; }; node_141(){ required 73; }; node_142(){
either 79 84 87 91 92 93 94 95 97 98 99 103 105 109 110 115 116 119 120 122 123 124 127 128 129 130 131 132 134 135 136 139 140 either 79 84 87 92 93 94 95 96 98 99 100 104 106 110 111 116 117 120 121 123 124 125 128 129 130 131 132 133 135 136 137 140 141
}; node_142(){ required 141; }; cat <<<' docopt_exit() { }; node_143(){ required 142; }; cat <<<' docopt_exit() {
[[ -n $1 ]] && printf "%s\n" "$1" >&2; printf "%s\n" "${DOC:40:1622}" >&2 [[ -n $1 ]] && printf "%s\n" "$1" >&2; printf "%s\n" "${DOC:40:1636}" >&2
exit 1; }'; unset var___help var___branch var___no_prompt var___stack \ exit 1; }'; unset var___skip_check var___debug var___stack var___help \
var___env var___debug var___skip_check var___verbose var___skip_update \ var___verbose var___skip_update var___env var___branch var___no_prompt \
var___status var___server var___type var___domain var___app_name var___pass \ var___status var___server var___type var___domain var___app_name var___pass \
var___secrets var___all var___update var___force var___skip_version_check \ var___secrets var___all var___update var___force var___skip_version_check \
var___volumes var___no_tty var___user var___dev var__type_ var__app_ \ 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__service_ var__version_ var__src_ var__dst_ var__backup_file_ var__args_ \
var__version_ var__cmd_ var__data_ var__command_ var__recipe_ var__host_ \ var__secret_ var__cmd_ var__data_ var__command_ var__recipe_ var__host_ \
var__user_ var__port_ var__provider_ var__subcommands_ var_app var_list var_ls \ var__user_ var__port_ var__provider_ var__subcommands_ var_app var_list var_ls \
var_new var_backup var_deploy var_check var_version var_config var_cp var_logs \ var_new var_backup var_deploy var_check var_version var_config var_cp var_logs \
var_ps var_restore var_rm var_delete var_run var_rollback var_secret \ var_ps var_restore var_rm var_delete var_run var_rollback var_secret \
var_generate var_insert var_undeploy var_recipe var_versions var_server \ var_generate var_insert var_undeploy var_recipe var_versions var_server \
var_add var_init var_apps var_upgrade var_doctor var_help; parse 142 "$@" var_add var_init var_apps var_upgrade var_doctor var_help; parse 143 "$@"
local prefix=${DOCOPT_PREFIX:-''}; unset "${prefix}__help" "${prefix}__branch" \ local prefix=${DOCOPT_PREFIX:-''}; unset "${prefix}__skip_check" \
"${prefix}__no_prompt" "${prefix}__stack" "${prefix}__env" "${prefix}__debug" \ "${prefix}__debug" "${prefix}__stack" "${prefix}__help" "${prefix}__verbose" \
"${prefix}__skip_check" "${prefix}__verbose" "${prefix}__skip_update" \ "${prefix}__skip_update" "${prefix}__env" "${prefix}__branch" \
"${prefix}__status" "${prefix}__server" "${prefix}__type" "${prefix}__domain" \ "${prefix}__no_prompt" "${prefix}__status" "${prefix}__server" \
"${prefix}__app_name" "${prefix}__pass" "${prefix}__secrets" "${prefix}__all" \ "${prefix}__type" "${prefix}__domain" "${prefix}__app_name" "${prefix}__pass" \
"${prefix}__update" "${prefix}__force" "${prefix}__skip_version_check" \ "${prefix}__secrets" "${prefix}__all" "${prefix}__update" "${prefix}__force" \
"${prefix}__volumes" "${prefix}__no_tty" "${prefix}__user" "${prefix}__dev" \ "${prefix}__skip_version_check" "${prefix}__volumes" "${prefix}__no_tty" \
"${prefix}_type_" "${prefix}_app_" "${prefix}_service_" "${prefix}_src_" \ "${prefix}__user" "${prefix}__dev" "${prefix}_type_" "${prefix}_app_" \
"${prefix}_dst_" "${prefix}_backup_file_" "${prefix}_args_" \ "${prefix}_service_" "${prefix}_version_" "${prefix}_src_" "${prefix}_dst_" \
"${prefix}_secret_" "${prefix}_version_" "${prefix}_cmd_" "${prefix}_data_" \ "${prefix}_backup_file_" "${prefix}_args_" "${prefix}_secret_" \
"${prefix}_command_" "${prefix}_recipe_" "${prefix}_host_" "${prefix}_user_" \ "${prefix}_cmd_" "${prefix}_data_" "${prefix}_command_" "${prefix}_recipe_" \
"${prefix}_port_" "${prefix}_provider_" "${prefix}_subcommands_" \ "${prefix}_host_" "${prefix}_user_" "${prefix}_port_" "${prefix}_provider_" \
"${prefix}app" "${prefix}list" "${prefix}ls" "${prefix}new" "${prefix}backup" \ "${prefix}_subcommands_" "${prefix}app" "${prefix}list" "${prefix}ls" \
"${prefix}deploy" "${prefix}check" "${prefix}version" "${prefix}config" \ "${prefix}new" "${prefix}backup" "${prefix}deploy" "${prefix}check" \
"${prefix}cp" "${prefix}logs" "${prefix}ps" "${prefix}restore" "${prefix}rm" \ "${prefix}version" "${prefix}config" "${prefix}cp" "${prefix}logs" \
"${prefix}delete" "${prefix}run" "${prefix}rollback" "${prefix}secret" \ "${prefix}ps" "${prefix}restore" "${prefix}rm" "${prefix}delete" \
"${prefix}generate" "${prefix}insert" "${prefix}undeploy" "${prefix}recipe" \ "${prefix}run" "${prefix}rollback" "${prefix}secret" "${prefix}generate" \
"${prefix}versions" "${prefix}server" "${prefix}add" "${prefix}init" \ "${prefix}insert" "${prefix}undeploy" "${prefix}recipe" "${prefix}versions" \
"${prefix}apps" "${prefix}upgrade" "${prefix}doctor" "${prefix}help" "${prefix}server" "${prefix}add" "${prefix}init" "${prefix}apps" \
eval "${prefix}"'__help=${var___help:-false}' "${prefix}upgrade" "${prefix}doctor" "${prefix}help"
eval "${prefix}"'__branch=${var___branch:-}'
eval "${prefix}"'__no_prompt=${var___no_prompt:-false}'
eval "${prefix}"'__stack=${var___stack:-}'
eval "${prefix}"'__env=${var___env:-}'
eval "${prefix}"'__debug=${var___debug:-false}'
eval "${prefix}"'__skip_check=${var___skip_check:-false}' eval "${prefix}"'__skip_check=${var___skip_check:-false}'
eval "${prefix}"'__debug=${var___debug:-false}'
eval "${prefix}"'__stack=${var___stack:-}'
eval "${prefix}"'__help=${var___help:-false}'
eval "${prefix}"'__verbose=${var___verbose:-false}' eval "${prefix}"'__verbose=${var___verbose:-false}'
eval "${prefix}"'__skip_update=${var___skip_update:-false}' eval "${prefix}"'__skip_update=${var___skip_update:-false}'
eval "${prefix}"'__env=${var___env:-}'
eval "${prefix}"'__branch=${var___branch:-}'
eval "${prefix}"'__no_prompt=${var___no_prompt:-false}'
eval "${prefix}"'__status=${var___status:-false}' eval "${prefix}"'__status=${var___status:-false}'
eval "${prefix}"'__server=${var___server:-}' eval "${prefix}"'__server=${var___server:-}'
eval "${prefix}"'__type=${var___type:-}' eval "${prefix}"'__type=${var___type:-}'
@ -290,12 +291,12 @@ eval "${prefix}"'__user=${var___user:-}'
eval "${prefix}"'__dev=${var___dev:-false}' eval "${prefix}"'__dev=${var___dev:-false}'
eval "${prefix}"'_type_=${var__type_:-}'; eval "${prefix}"'_app_=${var__app_:-}' eval "${prefix}"'_type_=${var__type_:-}'; eval "${prefix}"'_app_=${var__app_:-}'
eval "${prefix}"'_service_=${var__service_:-}' eval "${prefix}"'_service_=${var__service_:-}'
eval "${prefix}"'_version_=${var__version_:-}'
eval "${prefix}"'_src_=${var__src_:-}'; eval "${prefix}"'_dst_=${var__dst_:-}' eval "${prefix}"'_src_=${var__src_:-}'; eval "${prefix}"'_dst_=${var__dst_:-}'
eval "${prefix}"'_backup_file_=${var__backup_file_:-}' eval "${prefix}"'_backup_file_=${var__backup_file_:-}'
if declare -p var__args_ >/dev/null 2>&1; then if declare -p var__args_ >/dev/null 2>&1; then
eval "${prefix}"'_args_=("${var__args_[@]}")'; else eval "${prefix}"'_args_=()' eval "${prefix}"'_args_=("${var__args_[@]}")'; else eval "${prefix}"'_args_=()'
fi; eval "${prefix}"'_secret_=${var__secret_:-}' fi; eval "${prefix}"'_secret_=${var__secret_:-}'
eval "${prefix}"'_version_=${var__version_:-}'
eval "${prefix}"'_cmd_=${var__cmd_:-}'; eval "${prefix}"'_data_=${var__data_:-}' eval "${prefix}"'_cmd_=${var__cmd_:-}'; eval "${prefix}"'_data_=${var__data_:-}'
eval "${prefix}"'_command_=${var__command_:-}' eval "${prefix}"'_command_=${var__command_:-}'
eval "${prefix}"'_recipe_=${var__recipe_:-}' eval "${prefix}"'_recipe_=${var__recipe_:-}'
@ -334,21 +335,21 @@ eval "${prefix}"'upgrade=${var_upgrade:-false}'
eval "${prefix}"'doctor=${var_doctor:-false}' eval "${prefix}"'doctor=${var_doctor:-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}__help" "${prefix}__branch" "${prefix}__no_prompt" \ declare -p "${prefix}__skip_check" "${prefix}__debug" "${prefix}__stack" \
"${prefix}__stack" "${prefix}__env" "${prefix}__debug" "${prefix}__skip_check" \ "${prefix}__help" "${prefix}__verbose" "${prefix}__skip_update" \
"${prefix}__verbose" "${prefix}__skip_update" "${prefix}__status" \ "${prefix}__env" "${prefix}__branch" "${prefix}__no_prompt" \
"${prefix}__server" "${prefix}__type" "${prefix}__domain" \ "${prefix}__status" "${prefix}__server" "${prefix}__type" "${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}__skip_version_check" \ "${prefix}__update" "${prefix}__force" "${prefix}__skip_version_check" \
"${prefix}__volumes" "${prefix}__no_tty" "${prefix}__user" "${prefix}__dev" \ "${prefix}__volumes" "${prefix}__no_tty" "${prefix}__user" "${prefix}__dev" \
"${prefix}_type_" "${prefix}_app_" "${prefix}_service_" "${prefix}_src_" \ "${prefix}_type_" "${prefix}_app_" "${prefix}_service_" "${prefix}_version_" \
"${prefix}_dst_" "${prefix}_backup_file_" "${prefix}_args_" \ "${prefix}_src_" "${prefix}_dst_" "${prefix}_backup_file_" "${prefix}_args_" \
"${prefix}_secret_" "${prefix}_version_" "${prefix}_cmd_" "${prefix}_data_" \ "${prefix}_secret_" "${prefix}_cmd_" "${prefix}_data_" "${prefix}_command_" \
"${prefix}_command_" "${prefix}_recipe_" "${prefix}_host_" "${prefix}_user_" \ "${prefix}_recipe_" "${prefix}_host_" "${prefix}_user_" "${prefix}_port_" \
"${prefix}_port_" "${prefix}_provider_" "${prefix}_subcommands_" \ "${prefix}_provider_" "${prefix}_subcommands_" "${prefix}app" "${prefix}list" \
"${prefix}app" "${prefix}list" "${prefix}ls" "${prefix}new" "${prefix}backup" \ "${prefix}ls" "${prefix}new" "${prefix}backup" "${prefix}deploy" \
"${prefix}deploy" "${prefix}check" "${prefix}version" "${prefix}config" \ "${prefix}check" "${prefix}version" "${prefix}config" "${prefix}cp" \
"${prefix}cp" "${prefix}logs" "${prefix}ps" "${prefix}restore" "${prefix}rm" \ "${prefix}logs" "${prefix}ps" "${prefix}restore" "${prefix}rm" \
"${prefix}delete" "${prefix}run" "${prefix}rollback" "${prefix}secret" \ "${prefix}delete" "${prefix}run" "${prefix}rollback" "${prefix}secret" \
"${prefix}generate" "${prefix}insert" "${prefix}undeploy" "${prefix}recipe" \ "${prefix}generate" "${prefix}insert" "${prefix}undeploy" "${prefix}recipe" \
"${prefix}versions" "${prefix}server" "${prefix}add" "${prefix}init" \ "${prefix}versions" "${prefix}server" "${prefix}add" "${prefix}init" \
@ -468,7 +469,13 @@ require_docker_version (){
require_apps_json() { require_apps_json() {
# Ensure we have the latest copy of apps.json # Ensure we have the latest copy of apps.json
if [ "$abra___skip_update" = "true" ]; then
return
fi
apps_url="https://abra-apps.cloud.autonomic.zone" apps_url="https://abra-apps.cloud.autonomic.zone"
if [ -f "$ABRA_APPS_JSON" ]; then if [ -f "$ABRA_APPS_JSON" ]; then
modified=$(curl --silent --head $apps_url | \ modified=$(curl --silent --head $apps_url | \
awk '/^Last-Modified/{print $0}' | \ awk '/^Last-Modified/{print $0}' | \
@ -537,8 +544,9 @@ require_app (){
success "Fetched app configuration via Git" success "Fetched app configuration via Git"
} }
require_app_latest() { require_app_version() {
APP="$1" APP="$1"
VERSION="$2"
APP_DIR="$ABRA_DIR/apps/$APP" APP_DIR="$ABRA_DIR/apps/$APP"
debug "Checking for type '$APP'" debug "Checking for type '$APP'"
@ -548,11 +556,13 @@ require_app_latest() {
fi fi
debug "Using $APP_DIR" debug "Using $APP_DIR"
cd "$APP_DIR" || error "Can't find app dir '$APP_DIR'"
if [ "$abra___skip_update" = "false" ]; then if ! git tag -l | grep -q "$VERSION"; then
debug "Pulling latest '$APP' definition via git" git fetch -q --all
(cd "$APP_DIR" && git pull > /dev/null 2>&1)
fi fi
git checkout -q "$VERSION" || error "Can't find version $VERSION"
} }
vendor_binary() { vendor_binary() {
@ -612,7 +622,9 @@ get_recipes() {
get_recipe_versions() { get_recipe_versions() {
require_jq require_jq
mapfile -t RECIPE_VERSIONS < <($JQ -r ".${abra__recipe_}.versions | keys | .[]" "$ABRA_APPS_JSON" | sort) recipe="${1?Recipe not set}"
mapfile -t RECIPE_VERSIONS < <($JQ -r ".${recipe}.versions | keys | .[]" "$ABRA_APPS_JSON" | sort)
} }
###### Run-time loading ###### Run-time loading
@ -624,10 +636,6 @@ load_abra_sh() {
info "Loading abra.sh" info "Loading abra.sh"
fi fi
if [ -n "$abra__app_" ]; then
require_app_latest "$TYPE"
fi
if [ -f "$APP_DIR/abra.sh" ]; then if [ -f "$APP_DIR/abra.sh" ]; then
info "Loading $APP_DIR/abra.sh" info "Loading $APP_DIR/abra.sh"
# shellcheck disable=SC1090,SC1091 # shellcheck disable=SC1090,SC1091
@ -683,7 +691,7 @@ output_version_summary() {
if [ "$live_version" != "$service_tag" ] || [ "$live_digest" != "$service_digest" ]; then if [ "$live_version" != "$service_tag" ] || [ "$live_digest" != "$service_digest" ]; then
IS_AN_UPDATE="true" IS_AN_UPDATE="true"
fi fi
echo " to be deployed: $(tput setaf 1)$service_version ($service_digest)$(tput sgr0)" echo " to be deployed: $(tput setaf 1)$service_tag ($service_digest)$(tput sgr0)"
fi fi
else else
if [[ $UNDEPLOYED_STATE == "true" ]]; then if [[ $UNDEPLOYED_STATE == "true" ]]; then
@ -1050,7 +1058,10 @@ sub_app_new (){
DOMAIN=$abra___domain DOMAIN=$abra___domain
APP_NAME=$abra___app_name APP_NAME=$abra___app_name
require_app_latest "$TYPE" get_recipe_versions "$TYPE"
VERSION="${RECIPE_VERSIONS[-1]}"
require_app_version "$TYPE" "$VERSION"
if [ -z "$SERVER" ]; then if [ -z "$SERVER" ]; then
echo "Where would you like to put $TYPE?" echo "Where would you like to put $TYPE?"
@ -1126,8 +1137,6 @@ sub_app_new (){
###### .. app backup ###### .. app backup
sub_app_backup (){ sub_app_backup (){
require_app_latest "$TYPE"
# Add _<service> if it's defined # Add _<service> if it's defined
FUNCTION="abra_backup${abra__service_:+_}$abra__service_" FUNCTION="abra_backup${abra__service_:+_}$abra__service_"
@ -1143,8 +1152,6 @@ sub_app_backup (){
###### .. app restore ###### .. app restore
sub_app_restore (){ sub_app_restore (){
require_app_latest "$TYPE"
FUNCTION="abra_restore_$abra__service_" FUNCTION="abra_restore_$abra__service_"
if ! type "$FUNCTION" > /dev/null 2>&1; then if ! type "$FUNCTION" > /dev/null 2>&1; then
@ -1239,11 +1246,24 @@ POWERED BY
sub_app_deploy (){ sub_app_deploy (){
require_yq require_yq
require_app_latest "$TYPE"
NON_INTERACTIVE=$abra___no_prompt NON_INTERACTIVE=$abra___no_prompt
SKIP_VERSION_CHECK=$abra___skip_version_check SKIP_VERSION_CHECK=$abra___skip_version_check
if [ -n "$abra__version_" ]; then
VERSION="$abra__version_"
if ! printf '%s\0' "${RECIPE_VERSIONS[@]}" | grep -Fqxz -- "$VERSION"; then
error "'$version' doesn't appear to be a valid version of $TYPE"
fi
else
get_recipe_versions "$TYPE"
VERSION="${RECIPE_VERSIONS[-1]}"
fi
info "Chose version $VERSION"
require_app_version "$TYPE" "$VERSION"
echo "Deployment overview:" echo "Deployment overview:"
echo " Server: $(tput setaf 4)${SERVER}$(tput sgr0)" echo " Server: $(tput setaf 4)${SERVER}$(tput sgr0)"
@ -1671,22 +1691,41 @@ sub_app_run(){
###### .. app rollback ###### .. app rollback
help_app_rollback (){ help_app_rollback (){
echo "abra [options] app <app> rollback <service> echo "abra [options] app <app> rollback [<version>]
Rollback a deployed app service to a previous version. Roll back a deployed app to a previous version.
You can specify a particular <version>; see \`abra recipe <recipe> version\` for
the list of options.
Otherwise, we'll roll back to the second-most-recent available version.
EXAMPLES EXAMPLES
abra app wordpress rollback app abra app wordpress rollback
POWERED BY POWERED BY
CONTAINER_ID=\$(docker container ls -f ...) abra app <app> deploy <version> --update"
docker service rollback \$CONTAINER_ID ..."
} }
sub_app_rollback(){ sub_app_rollback(){
SERVICE="${abra__service_}" version="${abra__version_}"
docker service rollback "${STACK_NAME}_${SERVICE}" get_recipe_versions "$TYPE"
if [ "${#RECIPE_VERSIONS[@]}" -lt 2 ]; then
error "Can't roll back; need 2 versions, ${#RECIPE_VERSIONS[@]} available"
fi
if [ -z "$version" ]; then
version="${RECIPE_VERSIONS[-2]}"
info "Guessed version $version"
fi
# FIXME 3wc: check if $version is actually older than what's deployed
abra__version_="$version"
abra___update="true"
sub_app_deploy
} }
###### .. app logs ###### .. app logs