From b97086a8bd18a743bffd4509e3ee581c1a5f5ab9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Justen=20=28=40turicas=29?= Date: Sun, 5 Jan 2025 14:27:33 -0300 Subject: [PATCH 1/9] domains:clear now removes ALL app domains --- docs/configuration/domains.md | 6 +++--- docs/networking/proxy-management.md | 2 +- plugins/domains/functions | 3 +-- plugins/domains/help-functions | 2 +- plugins/domains/subcommands/clear | 2 +- plugins/domains/subcommands/clear-global | 4 ++-- 6 files changed, 9 insertions(+), 10 deletions(-) diff --git a/docs/configuration/domains.md b/docs/configuration/domains.md index 71ac8a98f..44a7627f8 100644 --- a/docs/configuration/domains.md +++ b/docs/configuration/domains.md @@ -6,8 +6,8 @@ ``` domains:add [ ...] # Add domains to app domains:add-global [ ...] # Add global domain names -domains:clear # Clear all domains for app -domains:clear-global # Clear global domain names +domains:clear # Remove all app domains +domains:clear-global # Remove all global domains domains:disable # Disable VHOST support domains:enable # Enable VHOST support domains:remove [ ...] # Remove domains from app @@ -67,7 +67,7 @@ dokku domains:add node-js-app dokku.me # list custom domains for app dokku domains:report node-js-app -# clear all custom domains for app +# delete all domains for app dokku domains:clear node-js-app # remove a custom domain from app diff --git a/docs/networking/proxy-management.md b/docs/networking/proxy-management.md index 6b1ec7f55..cce2b0835 100644 --- a/docs/networking/proxy-management.md +++ b/docs/networking/proxy-management.md @@ -150,7 +150,7 @@ At this time, the following dokku commands are used to interact with a complete - `domains:add`: Adds a given domain to an app. - triggers: `post-domains-update` -- `domains:clear`: Clears out an app's associated domains. +- `domains:clear`: Remove all app domains. - triggers: `post-domains-update` - `domains:disable`: Disables domains for an app. - triggers: `pre-disable-vhost` diff --git a/plugins/domains/functions b/plugins/domains/functions index 0798f48f3..41257e709 100755 --- a/plugins/domains/functions +++ b/plugins/domains/functions @@ -24,9 +24,8 @@ fn-domains-clear-app() { local APP_VHOST_PATH="$DOKKU_ROOT/$APP/VHOST" rm -f "$APP_VHOST_PATH" - domains_setup "$APP" plugn trigger post-domains-update "$APP" "clear" - dokku_log_info1 "Cleared domains in $APP" + dokku_log_info1 "Deleted all domains for $APP" } fn-domains-disable() { diff --git a/plugins/domains/help-functions b/plugins/domains/help-functions index 0f66a8734..72b8d9474 100755 --- a/plugins/domains/help-functions +++ b/plugins/domains/help-functions @@ -29,7 +29,7 @@ fn-help-content() { cat < [ ...], Add domains to app domains:add-global [ ...], Add global domain names - domains:clear , Clear all domains for app + domains:clear , Remove all app domains domains:clear-global, Clear global domain names domains:disable , Disable VHOST support domains:enable , Enable VHOST support diff --git a/plugins/domains/subcommands/clear b/plugins/domains/subcommands/clear index c6065abb2..3b18beaa0 100755 --- a/plugins/domains/subcommands/clear +++ b/plugins/domains/subcommands/clear @@ -5,7 +5,7 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/domains/functions" cmd-domains-clear() { - declare desc="clear all app domains" + declare desc="remove all app domains" declare cmd="domains:clear" [[ "$1" == "$cmd" ]] && shift 1 declare APP="$1" diff --git a/plugins/domains/subcommands/clear-global b/plugins/domains/subcommands/clear-global index ff7ae757b..3fd4815b5 100755 --- a/plugins/domains/subcommands/clear-global +++ b/plugins/domains/subcommands/clear-global @@ -5,11 +5,11 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/domains/functions" cmd-domains-clear-global() { - declare desc="clear global domain names via command line" + declare desc="remove all global domains" declare cmd="domains:clear-global" [[ "$1" == "$cmd" ]] && shift 1 - dokku_log_info1_quiet "Clearing global domains" + dokku_log_info1_quiet "Deleting global domains" domains_clear_global "$@" } From 67311264d76a87802e3b00e45df6ab4eb20dcae6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Justen=20=28=40turicas=29?= Date: Sun, 5 Jan 2025 14:28:31 -0300 Subject: [PATCH 2/9] Implement domains:reset --- docs/configuration/domains.md | 4 ++++ docs/development/plugin-triggers.md | 2 +- docs/networking/proxy-management.md | 2 ++ plugins/domains/help-functions | 1 + plugins/domains/subcommands/reset | 22 ++++++++++++++++++++++ tests/unit/domains.bats | 4 ++-- 6 files changed, 32 insertions(+), 3 deletions(-) create mode 100755 plugins/domains/subcommands/reset diff --git a/docs/configuration/domains.md b/docs/configuration/domains.md index 44a7627f8..851dd2894 100644 --- a/docs/configuration/domains.md +++ b/docs/configuration/domains.md @@ -13,6 +13,7 @@ domains:enable # Enable VHOST support domains:remove [ ...] # Remove domains from app domains:remove-global [ ...] # Remove global domain names domains:report [|--global] [] # Displays a domains report for one or more apps +domains:reset # Reset app domains to global-configured domains domains:set [ ...] # Set domains for app domains:set-global [ ...] # Set global domain names ``` @@ -75,6 +76,9 @@ dokku domains:remove node-js-app dokku.me # set all custom domains for app dokku domains:set node-js-app dokku.me dokku.org + +# delete all app domains and configure available global domains on it +dokku domains:reset node-js-app ``` ## Displaying domains reports for an app diff --git a/docs/development/plugin-triggers.md b/docs/development/plugin-triggers.md index c790eec4e..43bbab731 100644 --- a/docs/development/plugin-triggers.md +++ b/docs/development/plugin-triggers.md @@ -1699,7 +1699,7 @@ curl "http://httpstat.us/200" ### `post-domains-update` - Description: Allows you to run commands once the domain for an app has been updated. It also sends in the command that has been used. This can be "add", "clear" or "remove". The third argument will be the optional list of domains -- Invoked by: `dokku domains:add`, `dokku domains:clear`, `dokku domains:remove`, `dokku domains:set` +- Invoked by: `dokku domains:add`, `dokku domains:clear`, `dokku domains:remove`, `dokku domains:reset`, `dokku domains:set` - Arguments: `$APP` `action name` `domains` - Example: diff --git a/docs/networking/proxy-management.md b/docs/networking/proxy-management.md index cce2b0835..e10851d7f 100644 --- a/docs/networking/proxy-management.md +++ b/docs/networking/proxy-management.md @@ -158,6 +158,8 @@ At this time, the following dokku commands are used to interact with a complete - triggers: `pre-enable-vhost` - `domains:remove`: Removes a domain from an app. - triggers: `post-domains-update` +- `domains:reset`: Reset app domains to global-configured domains. + - triggers: `post-domains-update` - `domains:set`: Sets all domains for a given app. - triggers: `post-domains-update` - `proxy:build-config`: Builds - or rebuilds - external proxy configuration. diff --git a/plugins/domains/help-functions b/plugins/domains/help-functions index 72b8d9474..5a43671da 100755 --- a/plugins/domains/help-functions +++ b/plugins/domains/help-functions @@ -36,6 +36,7 @@ fn-help-content() { domains:remove [ ...], Remove domains from app domains:remove-global [ ...], Remove global domain names domains:report [|--global] [], Displays a domains report for one or more apps + domains:reset , Reset app domains to global-configured domains domains:set [ ...], Set domains for app domains:set-global [ ...], Set global domain names help_content diff --git a/plugins/domains/subcommands/reset b/plugins/domains/subcommands/reset new file mode 100755 index 000000000..2136ef5a9 --- /dev/null +++ b/plugins/domains/subcommands/reset @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +set -eo pipefail +[[ $DOKKU_TRACE ]] && set -x +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" +source "$PLUGIN_AVAILABLE_PATH/domains/functions" + +cmd-domains-reset() { + declare desc="reset app domains to global-configured domains" + declare cmd="domains:reset" + [[ "$1" == "$cmd" ]] && shift 1 + declare APP="$1" + + verify_app_name "$APP" + local APP_VHOST_PATH="$DOKKU_ROOT/$APP/VHOST" + + rm -f "$APP_VHOST_PATH" + domains_setup "$APP" + plugn trigger post-domains-update "$APP" "reset" + dokku_log_info1 "Reset domains for $APP" +} + +cmd-domains-reset "$@" diff --git a/tests/unit/domains.bats b/tests/unit/domains.bats index 24f0571d5..b8fa384eb 100644 --- a/tests/unit/domains.bats +++ b/tests/unit/domains.bats @@ -188,7 +188,7 @@ teardown() { assert_output_contains a--domain.with--hyphens } -@test "(domains) domains:clear" { +@test "(domains) domains:reset" { run /bin/bash -c "dokku domains:add $TEST_APP test.app.${DOKKU_DOMAIN}" echo "output: $output" echo "status: $status" @@ -199,7 +199,7 @@ teardown() { echo "status: $status" assert_success - run /bin/bash -c "dokku domains:clear $TEST_APP" + run /bin/bash -c "dokku domains:reset $TEST_APP" echo "output: $output" echo "status: $status" assert_success From 624acb8e184b4e8873dd7251a9cb3a0716e547ff Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 2 Jul 2025 01:12:35 -0400 Subject: [PATCH 3/9] chore: revert doc change --- docs/configuration/domains.md | 4 ++-- plugins/domains/help-functions | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/configuration/domains.md b/docs/configuration/domains.md index 851dd2894..f473fa6cd 100644 --- a/docs/configuration/domains.md +++ b/docs/configuration/domains.md @@ -6,8 +6,8 @@ ``` domains:add [ ...] # Add domains to app domains:add-global [ ...] # Add global domain names -domains:clear # Remove all app domains -domains:clear-global # Remove all global domains +domains:clear # Clear all domains for app +domains:clear-global # Clear global domain names domains:disable # Disable VHOST support domains:enable # Enable VHOST support domains:remove [ ...] # Remove domains from app diff --git a/plugins/domains/help-functions b/plugins/domains/help-functions index 5a43671da..028c11204 100755 --- a/plugins/domains/help-functions +++ b/plugins/domains/help-functions @@ -29,7 +29,7 @@ fn-help-content() { cat < [ ...], Add domains to app domains:add-global [ ...], Add global domain names - domains:clear , Remove all app domains + domains:clear , Clear all domains for app domains:clear-global, Clear global domain names domains:disable , Disable VHOST support domains:enable , Enable VHOST support From a062e283fe64ebd90725713b4385f3a4fb0eb76f Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 2 Jul 2025 01:14:30 -0400 Subject: [PATCH 4/9] chore: revert doc change --- docs/networking/proxy-management.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/networking/proxy-management.md b/docs/networking/proxy-management.md index e10851d7f..173b2e868 100644 --- a/docs/networking/proxy-management.md +++ b/docs/networking/proxy-management.md @@ -150,7 +150,7 @@ At this time, the following dokku commands are used to interact with a complete - `domains:add`: Adds a given domain to an app. - triggers: `post-domains-update` -- `domains:clear`: Remove all app domains. +- `domains:clear`: Clears out an app's associated domains. - triggers: `post-domains-update` - `domains:disable`: Disables domains for an app. - triggers: `pre-disable-vhost` From 6a0701fa6591f0381413d81649f3818ecd921055 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 2 Jul 2025 01:15:27 -0400 Subject: [PATCH 5/9] chore: revert doc change --- plugins/domains/functions | 2 +- plugins/domains/subcommands/clear | 2 +- plugins/domains/subcommands/clear-global | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/domains/functions b/plugins/domains/functions index 41257e709..cf705a243 100755 --- a/plugins/domains/functions +++ b/plugins/domains/functions @@ -25,7 +25,7 @@ fn-domains-clear-app() { rm -f "$APP_VHOST_PATH" plugn trigger post-domains-update "$APP" "clear" - dokku_log_info1 "Deleted all domains for $APP" + dokku_log_info1 "Cleared domains in $APP" } fn-domains-disable() { diff --git a/plugins/domains/subcommands/clear b/plugins/domains/subcommands/clear index 3b18beaa0..c6065abb2 100755 --- a/plugins/domains/subcommands/clear +++ b/plugins/domains/subcommands/clear @@ -5,7 +5,7 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/domains/functions" cmd-domains-clear() { - declare desc="remove all app domains" + declare desc="clear all app domains" declare cmd="domains:clear" [[ "$1" == "$cmd" ]] && shift 1 declare APP="$1" diff --git a/plugins/domains/subcommands/clear-global b/plugins/domains/subcommands/clear-global index 3fd4815b5..400450255 100755 --- a/plugins/domains/subcommands/clear-global +++ b/plugins/domains/subcommands/clear-global @@ -5,11 +5,11 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/domains/functions" cmd-domains-clear-global() { - declare desc="remove all global domains" + declare desc="clear global domain names" declare cmd="domains:clear-global" [[ "$1" == "$cmd" ]] && shift 1 - dokku_log_info1_quiet "Deleting global domains" + dokku_log_info1_quiet "Clearing global domains" domains_clear_global "$@" } From 77970a6b0d54284af36ac619ea08c7c783ea5e73 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 2 Jul 2025 01:17:09 -0400 Subject: [PATCH 6/9] chore: revert doc change --- docs/configuration/domains.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/configuration/domains.md b/docs/configuration/domains.md index f473fa6cd..120157f45 100644 --- a/docs/configuration/domains.md +++ b/docs/configuration/domains.md @@ -68,7 +68,7 @@ dokku domains:add node-js-app dokku.me # list custom domains for app dokku domains:report node-js-app -# delete all domains for app +# clear all custom domains for app dokku domains:clear node-js-app # remove a custom domain from app From b11c72d0ae9957b976a801acbfc16801bdddca41 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 2 Jul 2025 01:17:57 -0400 Subject: [PATCH 7/9] tests: update test logic --- tests/unit/domains.bats | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/domains.bats b/tests/unit/domains.bats index b8fa384eb..362131020 100644 --- a/tests/unit/domains.bats +++ b/tests/unit/domains.bats @@ -347,8 +347,8 @@ teardown() { echo "status: $status" assert_success - # run domains:clear in order to invoke default vhost creation - run /bin/bash -c "dokku --quiet domains:clear test.dokku.test" + # run domains:reset in order to invoke default vhost creation + run /bin/bash -c "dokku --quiet domains:reset test.dokku.test" echo "output: $output" echo "status: $status" assert_success From ea6adbbf5685f0418924b926af582abdb2013bdc Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 2 Jul 2025 01:21:57 -0400 Subject: [PATCH 8/9] fix: add missing trigger and use helper function for clearing vhost --- plugins/domains/subcommands/reset | 6 ++---- plugins/domains/subcommands/setup | 2 ++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/domains/subcommands/reset b/plugins/domains/subcommands/reset index 2136ef5a9..a01f95957 100755 --- a/plugins/domains/subcommands/reset +++ b/plugins/domains/subcommands/reset @@ -11,12 +11,10 @@ cmd-domains-reset() { declare APP="$1" verify_app_name "$APP" - local APP_VHOST_PATH="$DOKKU_ROOT/$APP/VHOST" - - rm -f "$APP_VHOST_PATH" + fn-domains-clear "$APP" domains_setup "$APP" plugn trigger post-domains-update "$APP" "reset" - dokku_log_info1 "Reset domains for $APP" + dokku_log_info1_quiet "Reset domains for $APP" } cmd-domains-reset "$@" diff --git a/plugins/domains/subcommands/setup b/plugins/domains/subcommands/setup index 6458bf6c4..4d0bb19b3 100755 --- a/plugins/domains/subcommands/setup +++ b/plugins/domains/subcommands/setup @@ -12,6 +12,8 @@ cmd-domains-setup() { verify_app_name "$APP" domains_setup "$APP" + plugn trigger post-domains-update "$APP" "reset" + dokku_log_info1_quiet "Setup domains for $APP" } cmd-domains-setup "$@" From a2ac21130a19ae055dff467ada58e1a1db41cd8c Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 2 Jul 2025 01:22:05 -0400 Subject: [PATCH 9/9] docs: add migration note --- docs/appendices/0.36.0-migration-guide.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/appendices/0.36.0-migration-guide.md b/docs/appendices/0.36.0-migration-guide.md index 2a79b6668..583fbfa75 100644 --- a/docs/appendices/0.36.0-migration-guide.md +++ b/docs/appendices/0.36.0-migration-guide.md @@ -3,4 +3,5 @@ ## Changes - Process stop timeouts are now configured via the `ps` property `stop-timeout-seconds`. Existing `DOKKU_DOCKER_STOP_TIMEOUT` environment variables will be automatically migrated to the new value. -- Processes now default to a `30` second stop timeout. \ No newline at end of file +- Processes now default to a `30` second stop timeout. +- The `domains:clear` command no longer runs domain setup after clearing the domains. Use `domains:reset` or run `domains:setup` manually to have the same effect. \ No newline at end of file