fix: preserve info flag in plugin reports with --global

The argument-handling block in each plugin's report command overwrote APP with --global before checking whether $1 actually held an info flag, so `dokku <plugin>:report --global --<plugin>-foo` always emitted the full report instead of the requested value. Reorder the conditionals across the sixteen plugins that share the pattern so the info-flag check runs first, and add a regression bats case for each one.
This commit is contained in:
Jose Diaz-Gonzalez
2026-04-30 21:05:46 -04:00
parent 53ef8c7780
commit e8d8b0683a
31 changed files with 278 additions and 50 deletions

View File

@@ -12,13 +12,15 @@ cmd-builder-dockerfile-report() {
set -- "${REPORT_ARGS[@]}"
declare APP="${1:-}" INFO_FLAG="${2:-}"
if [[ "$REPORT_IS_GLOBAL" == "true" ]]; then
APP="--global"
elif [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
INFO_FLAG="$APP"
APP=""
fi
if [[ "$REPORT_IS_GLOBAL" == "true" ]]; then
APP="--global"
fi
if [[ -z "$APP" ]] && [[ -z "$INFO_FLAG" ]]; then
INFO_FLAG="true"
fi

View File

@@ -12,13 +12,15 @@ cmd-builder-herokuish-report() {
set -- "${REPORT_ARGS[@]}"
declare APP="${1:-}" INFO_FLAG="${2:-}"
if [[ "$REPORT_IS_GLOBAL" == "true" ]]; then
APP="--global"
elif [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
INFO_FLAG="$APP"
APP=""
fi
if [[ "$REPORT_IS_GLOBAL" == "true" ]]; then
APP="--global"
fi
if [[ -z "$APP" ]] && [[ -z "$INFO_FLAG" ]]; then
INFO_FLAG="true"
fi

View File

@@ -12,13 +12,15 @@ cmd-builder-lambda-report() {
set -- "${REPORT_ARGS[@]}"
declare APP="${1:-}" INFO_FLAG="${2:-}"
if [[ "$REPORT_IS_GLOBAL" == "true" ]]; then
APP="--global"
elif [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
INFO_FLAG="$APP"
APP=""
fi
if [[ "$REPORT_IS_GLOBAL" == "true" ]]; then
APP="--global"
fi
if [[ -z "$APP" ]] && [[ -z "$INFO_FLAG" ]]; then
INFO_FLAG="true"
fi

View File

@@ -12,13 +12,15 @@ cmd-builder-nixpacks-report() {
set -- "${REPORT_ARGS[@]}"
declare APP="${1:-}" INFO_FLAG="${2:-}"
if [[ "$REPORT_IS_GLOBAL" == "true" ]]; then
APP="--global"
elif [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
INFO_FLAG="$APP"
APP=""
fi
if [[ "$REPORT_IS_GLOBAL" == "true" ]]; then
APP="--global"
fi
if [[ -z "$APP" ]] && [[ -z "$INFO_FLAG" ]]; then
INFO_FLAG="true"
fi

View File

@@ -12,13 +12,15 @@ cmd-builder-pack-report() {
set -- "${REPORT_ARGS[@]}"
declare APP="${1:-}" INFO_FLAG="${2:-}"
if [[ "$REPORT_IS_GLOBAL" == "true" ]]; then
APP="--global"
elif [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
INFO_FLAG="$APP"
APP=""
fi
if [[ "$REPORT_IS_GLOBAL" == "true" ]]; then
APP="--global"
fi
if [[ -z "$APP" ]] && [[ -z "$INFO_FLAG" ]]; then
INFO_FLAG="true"
fi

View File

@@ -12,13 +12,15 @@ cmd-builder-railpack-report() {
set -- "${REPORT_ARGS[@]}"
declare APP="${1:-}" INFO_FLAG="${2:-}"
if [[ "$REPORT_IS_GLOBAL" == "true" ]]; then
APP="--global"
elif [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
INFO_FLAG="$APP"
APP=""
fi
if [[ "$REPORT_IS_GLOBAL" == "true" ]]; then
APP="--global"
fi
if [[ -z "$APP" ]] && [[ -z "$INFO_FLAG" ]]; then
INFO_FLAG="true"
fi

View File

@@ -37,13 +37,15 @@ cmd-caddy-report() {
set -- "${REPORT_ARGS[@]}"
declare APP="${1:-}" INFO_FLAG="${2:-}"
if [[ "$REPORT_IS_GLOBAL" == "true" ]]; then
APP="--global"
elif [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
INFO_FLAG="$APP"
APP=""
fi
if [[ "$REPORT_IS_GLOBAL" == "true" ]]; then
APP="--global"
fi
if [[ -z "$APP" ]] && [[ -z "$INFO_FLAG" ]]; then
INFO_FLAG="true"
fi

View File

@@ -12,13 +12,15 @@ cmd-certs-report() {
set -- "${REPORT_ARGS[@]}"
declare APP="${1:-}" INFO_FLAG="${2:-}"
if [[ "$REPORT_IS_GLOBAL" == "true" ]]; then
APP="--global"
elif [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
INFO_FLAG="$APP"
APP=""
fi
if [[ "$REPORT_IS_GLOBAL" == "true" ]]; then
APP="--global"
fi
if [[ -z "$APP" ]] && [[ -z "$INFO_FLAG" ]]; then
INFO_FLAG="true"
fi

View File

@@ -13,13 +13,15 @@ cmd-checks-report() {
set -- "${REPORT_ARGS[@]}"
declare APP="${1:-}" INFO_FLAG="${2:-}"
if [[ "$REPORT_IS_GLOBAL" == "true" ]]; then
APP="--global"
elif [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
INFO_FLAG="$APP"
APP=""
fi
if [[ "$REPORT_IS_GLOBAL" == "true" ]]; then
APP="--global"
fi
if [[ -z "$APP" ]] && [[ -z "$INFO_FLAG" ]]; then
INFO_FLAG="true"
fi

View File

@@ -12,15 +12,15 @@ cmd-domains-report() {
set -- "${REPORT_ARGS[@]}"
declare APP="${1:-}" INFO_FLAG="${2:-}"
if [[ "$REPORT_IS_GLOBAL" == "true" ]]; then
APP="--global"
elif [[ "$APP" == "--global" ]]; then
:
elif [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
if [[ -n "$APP" ]] && [[ "$APP" != "--global" ]] && [[ "$APP" == --* ]]; then
INFO_FLAG="$APP"
APP=""
fi
if [[ "$REPORT_IS_GLOBAL" == "true" ]]; then
APP="--global"
fi
if [[ -z "$APP" ]] && [[ -z "$INFO_FLAG" ]]; then
INFO_FLAG="true"
fi

View File

@@ -327,13 +327,15 @@ cmd-git-report() {
declare APP="${1:-}" INFO_FLAG="${2:-}"
if [[ "$REPORT_IS_GLOBAL" == "true" ]]; then
APP="--global"
elif [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
INFO_FLAG="$APP"
APP=""
fi
if [[ "$REPORT_IS_GLOBAL" == "true" ]]; then
APP="--global"
fi
if [[ -z "$APP" ]] && [[ -z "$INFO_FLAG" ]]; then
INFO_FLAG="true"
fi

View File

@@ -37,13 +37,15 @@ cmd-haproxy-report() {
set -- "${REPORT_ARGS[@]}"
declare APP="${1:-}" INFO_FLAG="${2:-}"
if [[ "$REPORT_IS_GLOBAL" == "true" ]]; then
APP="--global"
elif [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
INFO_FLAG="$APP"
APP=""
fi
if [[ "$REPORT_IS_GLOBAL" == "true" ]]; then
APP="--global"
fi
if [[ -z "$APP" ]] && [[ -z "$INFO_FLAG" ]]; then
INFO_FLAG="true"
fi

View File

@@ -15,13 +15,15 @@ cmd-nginx-report() {
declare APP="${1:-}" INFO_FLAG="${2:-}"
if [[ "$REPORT_IS_GLOBAL" == "true" ]]; then
APP="--global"
elif [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
INFO_FLAG="$APP"
APP=""
fi
if [[ "$REPORT_IS_GLOBAL" == "true" ]]; then
APP="--global"
fi
if [[ -z "$APP" ]] && [[ -z "$INFO_FLAG" ]]; then
INFO_FLAG="true"
fi

View File

@@ -37,13 +37,15 @@ cmd-openresty-report() {
set -- "${REPORT_ARGS[@]}"
declare APP="${1:-}" INFO_FLAG="${2:-}"
if [[ "$REPORT_IS_GLOBAL" == "true" ]]; then
APP="--global"
elif [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
INFO_FLAG="$APP"
APP=""
fi
if [[ "$REPORT_IS_GLOBAL" == "true" ]]; then
APP="--global"
fi
if [[ -z "$APP" ]] && [[ -z "$INFO_FLAG" ]]; then
INFO_FLAG="true"
fi

View File

@@ -13,13 +13,15 @@ cmd-scheduler-docker-local-report() {
set -- "${REPORT_ARGS[@]}"
declare APP="${1:-}" INFO_FLAG="${2:-}"
if [[ "$REPORT_IS_GLOBAL" == "true" ]]; then
APP="--global"
elif [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
INFO_FLAG="$APP"
APP=""
fi
if [[ "$REPORT_IS_GLOBAL" == "true" ]]; then
APP="--global"
fi
if [[ -z "$APP" ]] && [[ -z "$INFO_FLAG" ]]; then
INFO_FLAG="true"
fi

View File

@@ -37,13 +37,15 @@ cmd-traefik-report() {
set -- "${REPORT_ARGS[@]}"
declare APP="${1:-}" INFO_FLAG="${2:-}"
if [[ "$REPORT_IS_GLOBAL" == "true" ]]; then
APP="--global"
elif [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
INFO_FLAG="$APP"
APP=""
fi
if [[ "$REPORT_IS_GLOBAL" == "true" ]]; then
APP="--global"
fi
if [[ -z "$APP" ]] && [[ -z "$INFO_FLAG" ]]; then
INFO_FLAG="true"
fi

View File

@@ -35,6 +35,12 @@ teardown() {
echo "status: $status"
assert_success
assert_output_contains "global builder-dockerfile information"
run /bin/bash -c "dokku builder-dockerfile:report --global --builder-dockerfile-global-dockerfile-path"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "Dockerfile"
}
@test "(builder-dockerfile:set)" {

View File

@@ -10,6 +10,24 @@ teardown() {
destroy_app
}
@test "(builder-herokuish:report) --global --builder-herokuish-global-allowed" {
run /bin/bash -c "dokku builder-herokuish:set --global allowed false"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku builder-herokuish:report --global --builder-herokuish-global-allowed"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "false"
run /bin/bash -c "dokku builder-herokuish:set --global allowed"
echo "output: $output"
echo "status: $status"
assert_success
}
@test "(builder-herouish:build .env)" {
run deploy_app python dokku@$DOKKU_DOMAIN:$TEST_APP
echo "output: $output"

View File

@@ -10,6 +10,24 @@ teardown() {
destroy_app
}
@test "(builder-lambda:report) --global --builder-lambda-global-lambdayml-path" {
run /bin/bash -c "dokku builder-lambda:set --global lambdayml-path lambda.alt.yml"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku builder-lambda:report --global --builder-lambda-global-lambdayml-path"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "lambda.alt.yml"
run /bin/bash -c "dokku builder-lambda:set --global lambdayml-path"
echo "output: $output"
echo "status: $status"
assert_success
}
@test "(builder-lambda:set)" {
run /bin/bash -c "dokku config:set $TEST_APP SECRET_KEY=fjdkslafjdk"
echo "output: $output"

View File

@@ -14,6 +14,24 @@ teardown() {
destroy_app
}
@test "(builder-nixpacks:report) --global --builder-nixpacks-global-nixpackstoml-path" {
run /bin/bash -c "dokku builder-nixpacks:set --global nixpackstoml-path nixpacks.alt.toml"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku builder-nixpacks:report --global --builder-nixpacks-global-nixpackstoml-path"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "nixpacks.alt.toml"
run /bin/bash -c "dokku builder-nixpacks:set --global nixpackstoml-path"
echo "output: $output"
echo "status: $status"
assert_success
}
@test "(builder-nixpacks:set)" {
run /bin/bash -c "dokku config:set $TEST_APP SECRET_KEY=fjdkslafjdk"
echo "output: $output"

View File

@@ -16,6 +16,24 @@ teardown() {
global_teardown
}
@test "(builder-pack:report) --global --builder-pack-global-projecttoml-path" {
run /bin/bash -c "dokku builder-pack:set --global projecttoml-path project.alt.toml"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku builder-pack:report --global --builder-pack-global-projecttoml-path"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "project.alt.toml"
run /bin/bash -c "dokku builder-pack:set --global projecttoml-path"
echo "output: $output"
echo "status: $status"
assert_success
}
@test "(builder-pack:set)" {
run /bin/bash -c "dokku config:set $TEST_APP SECRET_KEY=fjdkslafjdk"
echo "output: $output"

View File

@@ -25,6 +25,24 @@ teardown() {
global_teardown
}
@test "(builder-railpack:report) --global --builder-railpack-global-railpackjson-path" {
run /bin/bash -c "dokku builder-railpack:set --global railpackjson-path railpack.alt.json"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku builder-railpack:report --global --builder-railpack-global-railpackjson-path"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "railpack.alt.json"
run /bin/bash -c "dokku builder-railpack:set --global railpackjson-path"
echo "output: $output"
echo "status: $status"
assert_success
}
@test "(builder-railpack:set)" {
run /bin/bash -c "dokku config:set $TEST_APP SECRET_KEY=fjdkslafjdk"
echo "output: $output"

View File

@@ -18,6 +18,24 @@ teardown() {
dokku nginx:start
}
@test "(caddy:report) --global --caddy-log-level" {
run /bin/bash -c "dokku caddy:set --global log-level DEBUG"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku caddy:report --global --caddy-log-level"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "DEBUG"
run /bin/bash -c "dokku caddy:set --global log-level"
echo "output: $output"
echo "status: $status"
assert_success
}
@test "(caddy) caddy:help" {
run /bin/bash -c "dokku caddy"
echo "output: $output"

View File

@@ -53,6 +53,12 @@ teardown() {
echo "status: $status"
assert_success
assert_output_contains "global ssl information"
run /bin/bash -c "dokku certs:report --global --ssl-bogus"
echo "output: $output"
echo "status: $status"
assert_failure
assert_output_contains "Invalid flag passed"
}
@test "(certs) certs:add" {

View File

@@ -45,6 +45,12 @@ teardown() {
assert_success
assert_output_contains "global checks information"
run /bin/bash -c "dokku checks:report --global --checks-global-wait-to-retire"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "90"
run /bin/bash -c "dokku checks:set --global wait-to-retire"
echo "output: $output"
echo "status: $status"

View File

@@ -45,6 +45,12 @@ teardown() {
echo "status: $status"
assert_success
assert_output_contains "Global domains information"
run /bin/bash -c "dokku domains:report --global --domains-global-enabled"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "true"
}
@test "(domains) domains" {

View File

@@ -858,4 +858,10 @@ teardown() {
echo "status: $status"
assert_success
assert_output "false"
run /bin/bash -c "dokku git:report --global --git-global-deploy-branch"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "master"
}

View File

@@ -79,6 +79,22 @@ teardown() {
echo "status: $status"
assert_success
assert_output_contains "global nginx information"
run /bin/bash -c "dokku nginx:set --global client-max-body-size 5m"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku nginx:report --global --nginx-global-client-max-body-size"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "5m"
run /bin/bash -c "dokku nginx:set --global client-max-body-size"
echo "output: $output"
echo "status: $status"
assert_success
}
@test "(nginx-vhosts) proxy:build-config (domains:disable/enable)" {

View File

@@ -18,6 +18,24 @@ teardown() {
dokku nginx:start
}
@test "(openresty:report) --global --openresty-global-hsts" {
run /bin/bash -c "dokku openresty:set --global hsts false"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku openresty:report --global --openresty-global-hsts"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "false"
run /bin/bash -c "dokku openresty:set --global hsts"
echo "output: $output"
echo "status: $status"
assert_success
}
@test "(openresty) openresty:help" {
run /bin/bash -c "dokku openresty"
echo "output: $output"

View File

@@ -10,6 +10,14 @@ teardown() {
global_teardown
}
@test "(scheduler-docker-local:report) --global --scheduler-docker-local-init-process" {
run /bin/bash -c "dokku scheduler-docker-local:report --global --scheduler-docker-local-init-process"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "true"
}
@test "(scheduler-docker-local) scheduler-docker-local:help" {
run /bin/bash -c "dokku scheduler-docker-local"
echo "output: $output"

View File

@@ -23,6 +23,24 @@ teardown() {
dokku nginx:start
}
@test "(traefik:report) --global --traefik-log-level" {
run /bin/bash -c "dokku traefik:set --global log-level DEBUG"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku traefik:report --global --traefik-log-level"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "DEBUG"
run /bin/bash -c "dokku traefik:set --global log-level"
echo "output: $output"
echo "status: $status"
assert_success
}
@test "(traefik) traefik:help" {
run /bin/bash -c "dokku traefik"
echo "output: $output"