From 887c0ebdd6797f7c2fa7aafe5b69a874e87a9e66 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Tue, 16 Apr 2019 21:23:45 -0400 Subject: [PATCH] feat: add ability to report domains globally The `domains` command previously had this functionality, but is deprecated, and thus we should provide an alternative method of presenting the information. --- docs/configuration/domains.md | 2 +- plugins/domains/internal-functions | 30 ++++++++++++++++++++++++------ tests/unit/20_domains.bats | 5 +++++ 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/docs/configuration/domains.md b/docs/configuration/domains.md index f039a51f9..1fc18556c 100644 --- a/docs/configuration/domains.md +++ b/docs/configuration/domains.md @@ -10,7 +10,7 @@ domains:disable # Disable VHOST support domains:enable # Enable VHOST support domains:remove [ ...] # Remove domains from app domains:remove-global [ ...] # Remove global domain names -domains:report [] [] # Displays a domains report for one or more apps +domains:report [|--global] [] # Displays a domains report for one or more apps domains:set [ ...] # Set domains for app domains:set-global [ ...] # Set global domain names ``` diff --git a/plugins/domains/internal-functions b/plugins/domains/internal-functions index f93d51429..db736e6d0 100755 --- a/plugins/domains/internal-functions +++ b/plugins/domains/internal-functions @@ -10,6 +10,11 @@ cmd-domains-report() { local INSTALLED_APPS=$(dokku_apps) local APP="$2" INFO_FLAG="$3" + if [[ "$APP" == "--global" ]]; then + cmd-domains-report-single "$APP" "$INFO_FLAG" + return + fi + if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then INFO_FLAG="$APP" APP="" @@ -33,16 +38,29 @@ cmd-domains-report-single() { if [[ "$INFO_FLAG" == "true" ]]; then INFO_FLAG="" fi - verify_app_name "$APP" - local flag_map=( - "--domains-app-enabled: $(fn-domains-app-enabled "$APP")" - "--domains-app-vhosts: $(fn-domains-app-vhosts "$APP")" + local flag_map=() app_flags=() global_flags=() + + if [[ "$APP" != "--global" ]]; then + verify_app_name "$APP" + app_flags=( + "--domains-app-enabled: $(fn-domains-app-enabled "$APP")" + "--domains-app-vhosts: $(fn-domains-app-vhosts "$APP")" + ) + fi + + global_flags=( "--domains-global-enabled: $(fn-domains-global-enabled)" "--domains-global-vhosts: $(fn-domains-global-vhosts)" ) + flag_map=("${app_flags[@]}" "${global_flags[@]}") + if [[ -z "$INFO_FLAG" ]]; then - dokku_log_info2_quiet "$APP domains information" + if [[ "$APP" == "--global" ]]; then + dokku_log_info2_quiet "Global domains information" + else + dokku_log_info2_quiet "$APP domains information" + fi for flag in "${flag_map[@]}"; do key="$(echo "${flag#--}" | cut -f1 -d' ' | tr - ' ')" dokku_log_verbose "$(printf "%-30s %-25s" "${key^}" "${flag#*: }")" @@ -78,7 +96,7 @@ domains_help_content_func() { domains:enable , Enable VHOST support domains:remove [ ...], Remove domains from app domains:remove-global [ ...], Remove global domain names - domains:report [] [], Displays a domains report for one or more apps + domains:report [|--global] [], Displays a domains report for one or more apps domains:set [ ...], Set domains for app domains:set-global [ ...], Set global domain names help_content diff --git a/tests/unit/20_domains.bats b/tests/unit/20_domains.bats index 8c05f8994..2c275a275 100644 --- a/tests/unit/20_domains.bats +++ b/tests/unit/20_domains.bats @@ -191,6 +191,11 @@ teardown() { echo "status: $status" assert_success + run /bin/bash -c "dokku domains:report --global" + echo "output: $output" + echo "status: $status" + assert_success + run /bin/bash -c "dokku domains 2>/dev/null | egrep -qw '^global.dokku.me\$'" echo "output: $output" echo "status: $status"