refactor: split out label subcommands into distinct commands

This commit is contained in:
Jose Diaz-Gonzalez
2025-11-16 16:30:56 -05:00
parent 4eafd3b5b7
commit 12cc31427b
13 changed files with 146 additions and 83 deletions

View File

@@ -5,14 +5,28 @@ source "$PLUGIN_AVAILABLE_PATH/openresty-vhosts/internal-functions"
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
cmd-openresty-label() {
declare desc="set/unset/show container proxy labels"
declare cmd="openresty:label"
cmd-openresty-label-add() {
declare desc="adds container label to app for specified proxy"
declare cmd="openresty:label:add"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
set -- openresty "$@"
cmd-proxy-label "$@"
cmd-proxy-label-add "proxy:label:add" "openresty" "$@"
}
cmd-openresty-label-remove() {
declare desc="removes container label from app for specified proxy"
declare cmd="openresty:label:remove"
[[ "$1" == "$cmd" ]] && shift 1
cmd-proxy-label-remove "proxy:label:remove" "openresty" "$@"
}
cmd-openresty-label-show() {
declare desc="shows container labels for app for specified proxy"
declare cmd="openresty:label:show"
[[ "$1" == "$cmd" ]] && shift 1
cmd-proxy-label-show "proxy:label:show" "openresty" "$@"
}
cmd-openresty-report() {

View File

@@ -1,6 +1,7 @@
#!/usr/bin/env bash
[[ " openresty:help help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
source "$PLUGIN_AVAILABLE_PATH/openresty-vhosts/help-functions"
source "$PLUGIN_AVAILABLE_PATH/openresty-vhosts/command-functions"
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
@@ -9,6 +10,18 @@ case "$1" in
cmd-openresty-help "$@"
;;
openresty:label:add)
cmd-openresty-label-add "$@"
;;
openresty:label:remove)
cmd-openresty-label-remove "$@"
;;
openresty:label:show)
cmd-openresty-label-show "$@"
;;
*)
exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
;;

View File

@@ -1,6 +0,0 @@
#!/usr/bin/env bash
source "$PLUGIN_AVAILABLE_PATH/openresty-vhosts/command-functions"
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
cmd-openresty-label "$@"