feat: add --format json to git:report and nginx:report

Mirrors the JSON output convention already used by scheduler:report, builder:report, network:report, and traefik:report. Both plugins now accept `--format json` to emit a single-line JSON object whose keys are the property names with the plugin prefix stripped. Combining `--format` with an info flag is rejected with an error message that matches the Go-based report helper.

Closes #8499
This commit is contained in:
Jose Diaz-Gonzalez
2026-04-26 23:30:22 -04:00
parent ad00918891
commit 66c4b3b30e
6 changed files with 210 additions and 10 deletions

View File

@@ -731,3 +731,38 @@ teardown() {
assert_success
assert_output "master"
}
@test "(git:report) --format json" {
run /bin/bash -c "dokku git:set $TEST_APP deploy-branch main"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku git:report $TEST_APP --format json | jq -r '.\"deploy-branch\"'"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "main"
run /bin/bash -c "dokku git:report $TEST_APP --format json | jq -r '.\"global-deploy-branch\"'"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "master"
run /bin/bash -c "dokku git:report $TEST_APP --format json | jq -e ."
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku git:report --format json | jq -e ."
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku git:report $TEST_APP --format json --git-deploy-branch"
echo "output: $output"
echo "status: $status"
assert_failure
assert_output_contains "--format flag cannot be specified when specifying an info flag"
}

View File

@@ -28,6 +28,40 @@ teardown() {
assert_output "$help_output"
}
@test "(nginx:report) --format json" {
run create_app
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku nginx:set $TEST_APP bind-address-ipv4 127.0.0.1"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku nginx:report $TEST_APP --format json | jq -r '.\"bind-address-ipv4\"'"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "127.0.0.1"
run /bin/bash -c "dokku nginx:report $TEST_APP --format json | jq -e ."
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku nginx:report --format json | jq -e ."
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku nginx:report $TEST_APP --format json --nginx-bind-address-ipv4"
echo "output: $output"
echo "status: $status"
assert_failure
assert_output_contains "--format flag cannot be specified when specifying an info flag"
}
@test "(nginx-vhosts) proxy:build-config (domains:disable/enable)" {
run deploy_app
echo "output: $output"