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/haproxy-vhosts/internal-functions"
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
cmd-haproxy-label() {
declare desc="set/unset/show container proxy labels"
declare cmd="haproxy:label"
cmd-haproxy-label-add() {
declare desc="adds container label to app for specified proxy"
declare cmd="haproxy:label:add"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
set -- haproxy "$@"
cmd-proxy-label "$@"
cmd-proxy-label-add "proxy:label:add" "haproxy" "$@"
}
cmd-haproxy-label-remove() {
declare desc="removes container label from app for specified proxy"
declare cmd="haproxy:label:remove"
[[ "$1" == "$cmd" ]] && shift 1
cmd-proxy-label-remove "proxy:label:remove" "haproxy" "$@"
}
cmd-haproxy-label-show() {
declare desc="shows container labels for app for specified proxy"
declare cmd="haproxy:label:show"
[[ "$1" == "$cmd" ]] && shift 1
cmd-proxy-label-show "proxy:label:show" "haproxy" "$@"
}
cmd-haproxy-report() {

View File

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

View File

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