@@ -7,9 +7,10 @@ case "$1" in
|
||||
help_content_func () {
|
||||
declare desc="return docker-options plugin help content"
|
||||
cat<<help_content
|
||||
docker-options <app> [phase(s)], Display app's Docker options for all phases (or comma separated phase list)
|
||||
docker-options <app> [phase(s)], [DEPRECATED] Alternative for docker-options:report
|
||||
docker-options:add <app> <phase(s)> OPTION, Add Docker option to app for phase (comma separated phase list)
|
||||
docker-options:remove <app> <phase(s)> OPTION, Remove Docker option from app for phase (comma separated phase list)
|
||||
docker-options:report [<app>] [<flag>], Displays a docker options report for one or more apps
|
||||
help_content
|
||||
}
|
||||
|
||||
|
||||
68
plugins/docker-options/subcommands/report
Executable file
68
plugins/docker-options/subcommands/report
Executable file
@@ -0,0 +1,68 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/docker-options/functions"
|
||||
|
||||
fn-docker-options() {
|
||||
declare APP="$1" PHASE="$2"
|
||||
local PHASE_FILE="$(fn-get-phase-file-path "$APP" "$PHASE")"
|
||||
if [[ -r "$PHASE_FILE" ]]; then
|
||||
cat "$PHASE_FILE" | tr '\n' ' '
|
||||
fi
|
||||
}
|
||||
|
||||
docker_options_report_single_app() {
|
||||
local APP="$1"; local APP_DIR="$DOKKU_ROOT/$APP"; local INFO_FLAG="$2"
|
||||
if [[ "$INFO_FLAG" == "true" ]]; then
|
||||
INFO_FLAG=""
|
||||
fi
|
||||
verify_app_name "$APP"
|
||||
local flag_map=(
|
||||
"--docker-options-build: $(fn-docker-options "$APP" build)"
|
||||
"--docker-options-deploy: $(fn-docker-options "$APP" deploy)"
|
||||
"--docker-options-run: $(fn-docker-options "$APP" run)"
|
||||
)
|
||||
|
||||
if [[ -z "$INFO_FLAG" ]]; then
|
||||
dokku_log_info2 "$APP docker options information"
|
||||
for flag in "${flag_map[@]}"; do
|
||||
key="$(echo "${flag#--}" | cut -f1 -d' ' | tr - ' ')"
|
||||
dokku_log_verbose "$(printf "%-20s %-25s" "${key^}" "${flag#*: }")"
|
||||
done
|
||||
else
|
||||
local match=false; local value_exists=false
|
||||
for flag in "${flag_map[@]}"; do
|
||||
valid_flags="${valid_flags} $(echo "$flag" | cut -d':' -f1)"
|
||||
if [[ "$flag" == "${INFO_FLAG}:"* ]]; then
|
||||
value=${flag#*: }
|
||||
size="${#value}"
|
||||
if [[ "$size" -ne 0 ]]; then
|
||||
echo "$value" && match=true && value_exists=true
|
||||
else
|
||||
match=true
|
||||
fi
|
||||
fi
|
||||
done
|
||||
if [[ "$match" == "true" ]]; then
|
||||
[[ "$value_exists" == "true" ]] || dokku_log_fail "not deployed"
|
||||
else
|
||||
dokku_log_fail "Invalid flag passed, valid flags:${valid_flags}"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
docker_options_report_cmd() {
|
||||
declare desc="displays a docker options report for one or more apps"
|
||||
local cmd="docker-options:report"
|
||||
local INSTALLED_APPS=$(dokku_apps); local APP
|
||||
|
||||
if [[ -z $2 ]]; then
|
||||
for APP in $INSTALLED_APPS; do
|
||||
docker_options_report_single_app "$APP" "true"
|
||||
done
|
||||
else
|
||||
docker_options_report_single_app "$2" "$3"
|
||||
fi
|
||||
}
|
||||
|
||||
docker_options_report_cmd "$@"
|
||||
Reference in New Issue
Block a user