Compare commits

...

26 Commits

Author SHA1 Message Date
3wc
65ba113696 Lower Docker req to 19, make sure we test locally
Ref #15

``` $ docker --version
Docker version 19.03.11, build 42e35e6
```

But abra works. So I think 19 might be sufficient?

Also, wondering if we should add `DOCKER_CONTEXT=default` to that check,
to make sure we're not querying a remote server. (Semi-related question
- should we also check remote Docker versions?)
2021-03-21 15:39:50 +02:00
3wc
36dd6b5eff Simplify require_foo commands 2021-03-20 23:17:05 +02:00
2f1f51bad1 Check for docker version
Closes https://git.autonomic.zone/coop-cloud/abra/issues/15.
2021-03-20 22:00:02 +01:00
bada24f3f6 Add warning to README too 2021-03-20 21:44:26 +01:00
2d5afd8149 Bump warning to the top and use emojis 2021-03-20 21:43:35 +01:00
dfb949eecc Specify and wrap 2021-03-20 21:42:04 +01:00
49771980a6 Add changes warning 2021-03-20 21:41:27 +01:00
7e31184bd6 Add add version check command
Closes https://git.autonomic.zone/coop-cloud/abra/issues/108.
2021-03-20 21:35:28 +01:00
49226f1640 Change warning to reflect version check scenarioj 2021-03-20 21:35:13 +01:00
4251c32b30 Re-word new app language to emphasise config editing
See https://git.autonomic.zone/coop-cloud/abra/issues/111#issuecomment-4407.
2021-03-20 21:24:38 +01:00
ece5385a38 Merge branch 'fix-subcommand-select' into main
Fix merge conflict in docopt generation + change log entry.
2021-03-20 21:18:34 +01:00
1c437b99eb Fix status checking 2021-03-18 20:10:42 +01:00
9580b2dd7d Add entry 2021-03-18 19:46:43 +01:00
f382765f29 Show correct status for missing contexts
Closes https://git.autonomic.zone/coop-cloud/abra/issues/99.
2021-03-18 19:45:30 +01:00
f5951add54 Fix variables in print statement 2021-03-18 19:09:34 +01:00
2b4efc2c61 Quote that 2021-03-18 18:57:00 +01:00
8ab854c822 Add log entry 2021-03-18 18:55:44 +01:00
005323ff3c Add debug for SSH connect on init
Closes https://git.autonomic.zone/coop-cloud/abra/issues/109.
2021-03-18 18:55:04 +01:00
390e918417 Add missing it 2021-03-18 18:54:53 +01:00
c5ccfa0fa1 Add entry 2021-03-18 18:47:13 +01:00
87b71cb9d4 Show connection details on abra server ls
Closes https://git.autonomic.zone/coop-cloud/abra/issues/110.
2021-03-18 18:46:33 +01:00
89bd18a76b Add change log entries 2021-03-18 17:21:16 +01:00
6e61c08b2c Handle undeployed state for version output summary
Closes https://git.autonomic.zone/coop-cloud/abra/issues/104.
2021-03-18 17:20:54 +01:00
54b6acc46c Fix output for stack name 2021-03-18 17:19:43 +01:00
e5e98d536a Add --force for undeploy 2021-03-18 17:18:35 +01:00
8df91de3af Add --force to deploy command
Closes https://git.autonomic.zone/coop-cloud/abra/issues/105.
2021-03-18 14:12:18 +01:00
3 changed files with 216 additions and 115 deletions

View File

@ -1,6 +1,24 @@
> 🔥 🔥 🔥 Please note, while we are still in [public
> alpha](https://docs.cloud.autonomic.zone/roadmap/), the `abra` release
> versioning scheme is not following [semver](https://semver.org/) conventions
> because we are still in the exploratory phases of building this tool. Please
> read the changes before upgrading your `abra` installation as there are
> **most likely** breaking changes coming each release. Sorry for any
> inconvenience caused, we're working hard to make this tool stable. Semver
> will be respected when we reach public beta. 🔥 🔥 🔥
# 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))
- Handle undeployed apps in version summaries when deploying ([#104](https://git.autonomic.zone/coop-cloud/abra/issues/104))
- Add `--force` to `undeploy` command ([e5e98d5](https://git.autonomic.zone/coop-cloud/abra/commit/e5e98d5))
- Rename "app type" back to "stack" in the deployment overview ([54b6acc](https://git.autonomic.zone/coop-cloud/abra/commit/54b6acc))
- Show context connection details on `abra server ls` ([#110](https://git.autonomic.zone/coop-cloud/abra/issues/110))
- Allow to debug the SSH connection details on swarm init ([#109](https://git.autonomic.zone/coop-cloud/abra/issues/109))
- Show correct status for apps deployed on servers with missing context ([#99](https://git.autonomic.zone/coop-cloud/abra/issues/99))
- Search for subcommands in descending order of how many components there are ([#108](https://git.autonomic.zone/coop-cloud/abra/issues/108))
- Add specific app version checking command (`abra app <app> version`) ([#108](https://git.autonomic.zone/coop-cloud/abra/issues/108))
- Add docker version check (guestimating < v20 is a bad idea) ([#15](https://git.autonomic.zone/coop-cloud/abra/issues/15))
# abra 0.6.0 (2021-03-17)

View File

@ -11,6 +11,15 @@ The cooperative cloud utility belt 🎩🐇
## Change log
> 🔥 🔥 🔥 Please note, while we are still in [public
> alpha](https://docs.cloud.autonomic.zone/roadmap/), the `abra` release
> versioning scheme is not following [semver](https://semver.org/) conventions
> because we are still in the exploratory phases of building this tool. Please
> read the changes before upgrading your `abra` installation as there are
> **most likely** breaking changes coming each release. Sorry for any
> inconvenience caused, we're working hard to make this tool stable. Semver
> will be respected when we reach public beta. 🔥 🔥 🔥
See [CHANGELOG.md](./CHANGELOG.md).
## Documentation

304
abra
View File

@ -18,7 +18,7 @@ Usage:
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 <app> backup (<service>|--all)
abra [options] app <app> deploy [--update]
abra [options] app <app> deploy [--update] [--force]
abra [options] app <app> check
abra [options] app <app> version
abra [options] app <app> config
@ -33,7 +33,7 @@ Usage:
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 (rm|delete) (<secret>|--all) [--pass] [--force]
abra [options] app <app> undeploy
abra [options] app <app> undeploy [--force]
abra [options] app <app> <command> [<args>...]
abra [options] server add <host> [<user>] [<port>]
abra [options] server new <provider>
@ -158,30 +158,31 @@ 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:2052}
usage=${DOC:40:1516}; digest=76d0e
shorts=(-U -d -s -C -e -h -v -b '' '' '' '' '' '' '' '' '' '' '' '' '' '')
longs=(--skip-update --debug --stack --skip-check --env --help --verbose --branch --status --server --type --domain --app-name --pass --secrets --all --update --force --volumes --no-tty --user --dev)
argcounts=(0 0 1 0 1 0 0 1 0 1 1 1 1 0 0 0 0 0 0 0 1 0); node_0(){
switch __skip_update 0; }; node_1(){ switch __debug 1; }; node_2(){
value __stack 2; }; node_3(){ switch __skip_check 3; }; node_4(){ value __env 4
}; node_5(){ switch __help 5; }; node_6(){ switch __verbose 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(){
switch __volumes 18; }; node_19(){ switch __no_tty 19; }; node_20(){
value __user 20; }; node_21(){ switch __dev 21; }; node_22(){ value _type_ a; }
node_23(){ value _app_ a; }; node_24(){ value _service_ a; }; node_25(){
value _src_ a; }; node_26(){ value _dst_ a; }; node_27(){ value _backup_file_ a
}; node_28(){ value _args_ a true; }; node_29(){ value _secret_ a; }; node_30(){
value _version_ a; }; node_31(){ value _cmd_ a; }; node_32(){ value _data_ a; }
node_33(){ value _command_ a; }; node_34(){ value _host_ a; }; node_35(){
value _user_ a; }; node_36(){ value _port_ a; }; node_37(){ value _provider_ a
}; node_38(){ value _subcommands_ a true; }; node_39(){ _command app; }
node_40(){ _command list; }; node_41(){ _command ls; }; node_42(){ _command new
}; node_43(){ _command backup; }; node_44(){ _command deploy; }; node_45(){
printf -- "exit %d\n" "$1"; exit "$1"; }; set -e; trimmed_doc=${DOC:1:2072}
usage=${DOC:40:1536}; digest=9142c
shorts=(-U -v -s -h -C -b -d -e '' '' '' '' '' '' '' '' '' '' '' '' '' '')
longs=(--skip-update --verbose --stack --help --skip-check --branch --debug --env --status --server --type --domain --app-name --pass --secrets --all --update --force --volumes --no-tty --user --dev)
argcounts=(0 0 1 0 0 1 0 1 0 1 1 1 1 0 0 0 0 0 0 0 1 0); node_0(){
switch __skip_update 0; }; node_1(){ switch __verbose 1; }; node_2(){
value __stack 2; }; node_3(){ switch __help 3; }; node_4(){
switch __skip_check 4; }; node_5(){ value __branch 5; }; node_6(){
switch __debug 6; }; node_7(){ value __env 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(){ switch __volumes 18; }; node_19(){
switch __no_tty 19; }; node_20(){ value __user 20; }; node_21(){ switch __dev 21
}; node_22(){ value _type_ a; }; node_23(){ value _app_ a; }; node_24(){
value _service_ a; }; node_25(){ value _src_ a; }; node_26(){ value _dst_ a; }
node_27(){ value _backup_file_ a; }; node_28(){ value _args_ a true; }
node_29(){ value _secret_ a; }; node_30(){ value _version_ a; }; node_31(){
value _cmd_ a; }; node_32(){ value _data_ a; }; node_33(){ value _command_ a; }
node_34(){ value _host_ a; }; node_35(){ value _user_ a; }; node_36(){
value _port_ a; }; node_37(){ value _provider_ a; }; node_38(){
value _subcommands_ a true; }; node_39(){ _command app; }; node_40(){
_command list; }; node_41(){ _command ls; }; node_42(){ _command new; }
node_43(){ _command backup; }; node_44(){ _command deploy; }; node_45(){
_command check; }; node_46(){ _command version; }; node_47(){ _command config; }
node_48(){ _command cp; }; node_49(){ _command logs; }; node_50(){ _command ps
}; node_51(){ _command restore; }; node_52(){ _command rm; }; node_53(){
@ -196,23 +197,22 @@ optional 9; }; node_72(){ optional 10; }; node_73(){ 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; }; node_87(){
required 67 39 23 48 25 26; }; node_88(){ optional 24; }; node_89(){
required 67 39 23 49 88; }; node_90(){ required 67 39 23 50; }; node_91(){
required 67 39 23 51 80; }; node_92(){ either 52 53; }; node_93(){ required 92
}; node_94(){ optional 17; }; node_95(){ optional 18; }; node_96(){
required 67 39 23 93 94 95 77; }; node_97(){ optional 27; }; node_98(){
required 67 39 23 51 24 97; }; node_99(){ optional 19; }; node_100(){
optional 20; }; node_101(){ oneormore 28; }; node_102(){
required 67 39 23 54 99 100 24 101; }; node_103(){ required 67 39 23 55 24; }
node_104(){ required 29 30; }; node_105(){ either 104 15; }; node_106(){
required 105; }; node_107(){ optional 31; }; node_108(){
required 67 39 23 56 57 106 107 76; }; node_109(){
required 67 39 23 43 80; }; node_82(){ optional 16; }; 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; }
node_88(){ required 67 39 23 48 25 26; }; node_89(){ optional 24; }; node_90(){
required 67 39 23 49 89; }; node_91(){ required 67 39 23 50; }; node_92(){
required 67 39 23 51 80; }; node_93(){ either 52 53; }; node_94(){ required 93
}; node_95(){ optional 18; }; node_96(){ required 67 39 23 94 83 95 77; }
node_97(){ optional 27; }; node_98(){ required 67 39 23 51 24 97; }; node_99(){
optional 19; }; node_100(){ optional 20; }; node_101(){ oneormore 28; }
node_102(){ required 67 39 23 54 99 100 24 101; }; node_103(){
required 67 39 23 55 24; }; node_104(){ required 29 30; }; node_105(){
either 104 15; }; node_106(){ required 105; }; node_107(){ optional 31; }
node_108(){ required 67 39 23 56 57 106 107 76; }; node_109(){
required 67 39 23 56 58 29 30 32 76; }; node_110(){ either 29 15; }; node_111(){
required 110; }; node_112(){ required 67 39 23 56 93 111 76 94; }; node_113(){
required 67 39 23 59; }; node_114(){ optional 101; }; node_115(){
required 110; }; node_112(){ required 67 39 23 56 94 111 76 83; }; node_113(){
required 67 39 23 59 83; }; node_114(){ optional 101; }; node_115(){
required 67 39 23 33 114; }; node_116(){ optional 35; }; node_117(){ optional 36
}; node_118(){ required 67 60 61 34 116 117; }; node_119(){ required 67 60 42 37
}; node_120(){ required 67 60 69; }; node_121(){ required 67 60 34 52; }
@ -220,11 +220,11 @@ node_122(){ required 67 60 34 62; }; node_123(){ required 67 60 34 63 70; }
node_124(){ optional 21; }; node_125(){ required 67 64 124; }; node_126(){
required 67 46; }; node_127(){ oneormore 38; }; node_128(){ optional 127; }
node_129(){ required 67 65 128; }; node_130(){ required 67; }; node_131(){
either 73 78 81 83 84 85 86 87 89 90 91 96 98 102 103 108 109 112 113 115 118 119 120 121 122 123 125 126 129 130
either 73 78 81 84 85 86 87 88 90 91 92 96 98 102 103 108 109 112 113 115 118 119 120 121 122 123 125 126 129 130
}; node_132(){ required 131; }; cat <<<' docopt_exit() {
[[ -n $1 ]] && printf "%s\n" "$1" >&2; printf "%s\n" "${DOC:40:1516}" >&2
exit 1; }'; unset var___skip_update var___debug var___stack var___skip_check \
var___env var___help var___verbose var___branch var___status var___server \
[[ -n $1 ]] && printf "%s\n" "$1" >&2; printf "%s\n" "${DOC:40:1536}" >&2
exit 1; }'; unset var___skip_update var___verbose var___stack var___help \
var___skip_check var___branch var___debug var___env 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_ \
@ -234,32 +234,31 @@ var_list var_ls 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_generate var_insert var_undeploy var_server var_add var_init \
var_apps var_upgrade var_help; parse 132 "$@"; local prefix=${DOCOPT_PREFIX:-''}
unset "${prefix}__skip_update" "${prefix}__debug" "${prefix}__stack" \
"${prefix}__skip_check" "${prefix}__env" "${prefix}__help" \
"${prefix}__verbose" "${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}version" "${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}help"
eval "${prefix}"'__skip_update=${var___skip_update:-false}'
eval "${prefix}"'__debug=${var___debug:-false}'
eval "${prefix}"'__stack=${var___stack:-}'
eval "${prefix}"'__skip_check=${var___skip_check:-false}'
eval "${prefix}"'__env=${var___env:-}'
eval "${prefix}"'__help=${var___help:-false}'
unset "${prefix}__skip_update" "${prefix}__verbose" "${prefix}__stack" \
"${prefix}__help" "${prefix}__skip_check" "${prefix}__branch" \
"${prefix}__debug" "${prefix}__env" "${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}version" "${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}help"; eval "${prefix}"'__skip_update=${var___skip_update:-false}'
eval "${prefix}"'__verbose=${var___verbose:-false}'
eval "${prefix}"'__stack=${var___stack:-}'
eval "${prefix}"'__help=${var___help:-false}'
eval "${prefix}"'__skip_check=${var___skip_check:-false}'
eval "${prefix}"'__branch=${var___branch:-}'
eval "${prefix}"'__debug=${var___debug:-false}'
eval "${prefix}"'__env=${var___env:-}'
eval "${prefix}"'__status=${var___status:-false}'
eval "${prefix}"'__server=${var___server:-}'
eval "${prefix}"'__type=${var___type:-}'
@ -316,24 +315,24 @@ eval "${prefix}"'apps=${var_apps:-false}'
eval "${prefix}"'upgrade=${var_upgrade:-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}__skip_update" "${prefix}__debug" "${prefix}__stack" \
"${prefix}__skip_check" "${prefix}__env" "${prefix}__help" \
"${prefix}__verbose" "${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}version" "${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}help"; done; }
declare -p "${prefix}__skip_update" "${prefix}__verbose" "${prefix}__stack" \
"${prefix}__help" "${prefix}__skip_check" "${prefix}__branch" \
"${prefix}__debug" "${prefix}__env" "${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}version" "${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}help"; done; }
# docopt parser above, complete command for generating this parser is `docopt.sh abra`
PROGRAM_NAME=$(basename "$0")
@ -402,16 +401,18 @@ require_bash_4() {
fi
}
require_pwqgen() {
if ! type pwqgen > /dev/null 2>&1; then
error "pwqgen program is not installed"
require_binary() {
if ! type "$1" > /dev/null 2>&1; then
error "'$1' program is not installed"
fi
}
require_pwqgen() {
require_binary pwqgen
}
require_wget() {
if ! type wget > /dev/null 2>&1; then
error "wget program is not installed"
fi
require_binary wget
}
require_abra_dir() {
@ -477,6 +478,15 @@ require_yq() {
esac
}
require_docker_version (){
major_version=$(DOCKER_CONTEXT=default docker version --format "{{.Server.Version}}" | cut -d'.' -f1)
if [[ "$major_version" -lt 19 ]]; then
error "This tool requires Docker v20 or greater. Please upgrade your Docker installation"
exit 1
fi
}
# FIXME 3wc: update or remove
if [ -z "$ABRA_ENV" ] && [ -f .env ] && type direnv > /dev/null 2>&1 && ! direnv status | grep -q 'Found RC allowed true'; then
error "direnv is blocked, run direnv allow"
@ -506,11 +516,17 @@ 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"
local -a UNDEPLOYED_STATE="false"
local -a CHECKED_SERVICES # array
if ! docker stack ls --format "{{ .Name }}" | grep -q "$STACK_NAME"; then
UNDEPLOYED_STATE="true"
fi
IFS=':' read -ra COMPOSE_FILES <<< "$COMPOSE_FILE"
for COMPOSE in "${COMPOSE_FILES[@]}"; do
SERVICES=$($YQ e '.services | keys | .[]' "${APP_DIR}/${COMPOSE}")
@ -543,20 +559,29 @@ output_version_summary() {
echo " to de deployed: $(tput setaf 1)$app_version ($app_digest)$(tput sgr0)"
fi
else
warning "Unable to detect deployed version of ${STACK_NAME}_${SERVICE}, please proceed with caution"
UNABLE_TO_DETECT="true"
if [[ $UNDEPLOYED_STATE == "true" ]]; then
image=$($YQ e ".services.${SERVICE}.image" "${APP_DIR}/${COMPOSE}" | cut -d':' -f1)
echo " ${STACK_NAME}_${SERVICE} (${image}):"
echo " undeployed!"
else
warning "Unable to detect deployed version of ${STACK_NAME}_${SERVICE}"
UNABLE_TO_DETECT="true"
fi
fi
CHECKED_SERVICES+=("$SERVICE")
done
done
if [[ $IS_AN_UPDATE == "true" ]]; then
if [[ -n "$IS_VERSION_CHECK" ]] && [[ "$IS_VERSION_CHECK" == "true" ]]; then
debug "Detected version check (without deploy), bailing out..."
exit 0
fi
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" ]] && [[ ! $UNDEPLOYED_STATE == "true" ]]; then
success "Nothing to deploy, you're on latest (use --force to re-deploy anyway)"
exit 0
fi
fi
@ -748,12 +773,13 @@ sub_app_list (){
fi
local -a DEPLOYED_APPS # array
local -a CHECKED_SERVERS # array
warning "Loading status from ${#SERVERS[@]} server(s), patience advised.."
for SERVER in "${SERVERS[@]}"; do
SERVER="${SERVER##*/}" # basename
mapfile -t SERVER_APPS < <(DOCKER_CONTEXT="$SERVER" docker stack ls --format '{{ .Name }}')
mapfile -t SERVER_APPS < <(DOCKER_CONTEXT="$SERVER" docker stack ls --format '{{ .Name }}' 2>/dev/null)
# add $SERVER~ to the start of each DEPLOYED_APPS
DEPLOYED_APPS+=("${SERVER_APPS[@]/#/$SERVER~}")
done
@ -793,6 +819,16 @@ sub_app_list (){
fi
if [ -n "$STATUS" ]; then
APP_STATUS=$( printf '%s\n' "${DEPLOYED_APPS[@]}" | grep -qP "^${SERVER}~${APP_STACK_NAME}$" && echo "deployed" || echo "inactive")
if [[ "$APP_STATUS" == "inactive" ]] ; then
if [[ ${CHECKED_SERVERS[*]} =~ ${SERVER} ]]; then
APP_STATUS="unknown"
else
if ! docker context inspect "$SERVER" > /dev/null 2>&1; then
APP_STATUS="unknown"
fi
CHECKED_SERVERS+=("$SERVER")
fi
fi
fi
printf " %s\t%s\t%s%s\n" "$DOMAIN" "$TYPE" "$SERVER" "${STATUS:+ }${APP_STATUS}"
done | column -s' ' -t
@ -895,10 +931,10 @@ sub_app_new (){
auto_gen_secrets
fi
echo "$(tput setaf 4)Your new '$TYPE' is ready for action:$(tput sgr0)"
echo " $(tput setaf 3)Customise the configuration:"
echo "$(tput setaf 4)Your new '$TYPE' has been created!$(tput sgr0)"
echo " $(tput setaf 3)Please customise the configuration defaults:"
echo " abra app $APP_NAME config$(tput sgr0)"
echo " $(tput setaf 2)Deploy it:"
echo " $(tput setaf 2)Then you can deploy it:"
echo " abra app $APP_NAME deploy$(tput sgr0)"
}
@ -1017,6 +1053,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)"
@ -1035,11 +1073,13 @@ sub_app_deploy (){
echo " Domain: $(tput setaf 2)${DOMAIN}$(tput sgr0)"
fi
echo " App type: $(tput setaf 3)${STACK_NAME}$(tput sgr0)"
echo " Stack: $(tput setaf 3)${STACK_NAME}$(tput sgr0)"
output_version_summary
prompt_confirm
if [[ $FORCE_DEPLOY != "true" ]]; then
prompt_confirm
fi
APP=$(basename "$APP_DIR")
@ -1070,8 +1110,13 @@ POWERED BY
}
sub_app_undeploy (){
FORCE_UNDEPLOY=$abra___force
warning "About to un-deploy $STACK_NAME from $SERVER"
prompt_confirm
if [[ $FORCE_UNDEPLOY != "true" ]]; then
prompt_confirm
fi
docker stack rm "$STACK_NAME"
}
@ -1113,9 +1158,19 @@ sub_app_config (){
}
###### .. app version
help_app_version (){
echo "abra [options] app <app> version
Show versions of the app that are currently deployed"
}
sub_app_version (){
# shellcheck disable=SC2016
echo '`abra app <app> version` command working correctly!'
require_yq
IS_VERSION_CHECK="true"
echo "Version overview:"
output_version_summary
}
###### .. app check
@ -1344,7 +1399,7 @@ sub_app_secret_generate(){
PWGEN="${abra__cmd_:-pwqgen}"
fi
echo "SECRET: $SECRET, VERSION $VERSION, PW $PW, ALL $abra___all"
debug "SECRET: $SECRET, VERSION $VERSION, PW $PWGEN, ALL $abra___all"
if [ -z "$SECRET" ] || [ -z "$VERSION" ] && [ "$abra___all" == "false" ]; then
error "Required arguments missing"
@ -1555,10 +1610,23 @@ List locally-defined servers."
sub_server_list() {
get_servers
warning "Loading status from ${#SERVERS[@]} server(s), patience advised.."
printf "%s servers:\n\n" "${#SERVERS[@]}"
local -a idx=0
for SERVER in "${SERVERS[@]}"; do
echo " ${SERVER##*/}"
done
if [[ "$idx" == 0 ]]; then
printf " NAME\tCONNECTION\n"
printf " --\t--\t\n"
fi
name="${SERVER##*/}"
host=$(docker context inspect "$name" -f "{{.Endpoints.docker.Host}}" 2>/dev/null)
printf " %s\t%s\n" "$name" "${host:-UNKNOWN}"
idx+=1
done | column -s' ' -t
}
###### .. server init
@ -1580,11 +1648,16 @@ sub_server_init() {
load_context
# Note(decentral1se): it sucks to use Google DNS but seems like a reliable method
# Note(decentral1se): it sucks to use Google DNS but it seems like a reliable method
# for determining the default IPv4 address especially nowadays
# when there are often multiple internal addresses assigned to eth0
default_ipv4="$(ip route get 8.8.8.8 | head -1 | awk '{print $7}')"
if [ "$abra___debug" = "true" ]; then
DOCKER_ENDPOINT=$(docker context inspect "$DOCKER_CONTEXT" -f "{{.Endpoints.docker.Host}}" 2>/dev/null)
debug "Connecting to $DOCKER_CONTEXT via SSH ($DOCKER_ENDPOINT)"
fi
docker swarm init --advertise-addr "$default_ipv4" || true
docker network create --driver=overlay proxy --scope swarm || true
}
@ -1785,6 +1858,7 @@ sub_network() {
abra() {
require_bash_4
require_docker_version
# TODO (3wc): we either need to do this, or add 'shellcheck disable' all over
# the place to handle the dynamically-defined vars
@ -1828,7 +1902,7 @@ abra() {
# Search for sub_* functions, and check if any of them matches enabled
# arguments (i.e. is a command and is specified). The `awk / sort` sorts by
# the number of occurrences of '_' in the function name, to ensure that
# the number of occurrences of '_' in the function name, to ensure that
# `abra app <app> version` will be matched before `abra version`.
SUBCOMMANDS=$(declare -Ff | grep 'sub_' | cut -d' ' -f3 | awk '{ print gsub("_","&"), $0 }' | sort -n -r | cut -d" " -f2-)
for SUBCOMMAND in $SUBCOMMANDS; do