Skip to content

Update how domains:clear works and add domains:reset command #7442

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions docs/configuration/domains.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
```
domains:add <app> <domain> [<domain> ...] # Add domains to app
domains:add-global <domain> [<domain> ...] # Add global domain names
domains:clear <app> # Clear all domains for app
domains:clear-global # Clear global domain names
domains:clear <app> # Remove all app domains
domains:clear-global # Remove all global domains
domains:disable <app> # Disable VHOST support
domains:enable <app> # Enable VHOST support
domains:remove <app> <domain> [<domain> ...] # Remove domains from app
domains:remove-global <domain> [<domain> ...] # Remove global domain names
domains:report [<app>|--global] [<flag>] # Displays a domains report for one or more apps
domains:reset <app> # Reset app domains to global-configured domains
domains:set <app> <domain> [<domain> ...] # Set domains for app
domains:set-global <domain> [<domain> ...] # Set global domain names
```
Expand Down Expand Up @@ -54,14 +55,17 @@ 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
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
Expand Down
2 changes: 1 addition & 1 deletion docs/development/plugin-triggers.md
Original file line number Diff line number Diff line change
Expand Up @@ -1700,7 +1700,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:

Expand Down
4 changes: 3 additions & 1 deletion docs/networking/proxy-management.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,16 @@ 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`
- `domains:enable`: Enables domains for an app.
- 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.
Expand Down
3 changes: 2 additions & 1 deletion plugins/domains/help-functions
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ fn-help-content() {
cat <<help_content
domains:add <app> <domain> [<domain> ...], Add domains to app
domains:add-global <domain> [<domain> ...], Add global domain names
domains:clear <app>, Clear all domains for app
domains:clear <app>, Remove all app domains
domains:clear-global, Clear global domain names
domains:disable <app>, Disable VHOST support
domains:enable <app>, Enable VHOST support
domains:remove <app> <domain> [<domain> ...], Remove domains from app
domains:remove-global <domain> [<domain> ...], Remove global domain names
domains:report [<app>|--global] [<flag>], Displays a domains report for one or more apps
domains:reset <app>, Reset app domains to global-configured domains
domains:set <app> <domain> [<domain> ...], Set domains for app
domains:set-global <domain> [<domain> ...], Set global domain names
help_content
Expand Down
5 changes: 2 additions & 3 deletions plugins/domains/subcommands/clear
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -14,9 +14,8 @@ cmd-domains-clear() {
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"
}

cmd-domains-clear "$@"
4 changes: 2 additions & 2 deletions plugins/domains/subcommands/clear-global
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$@"
}

Expand Down
22 changes: 22 additions & 0 deletions plugins/domains/subcommands/reset
Original file line number Diff line number Diff line change
@@ -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 "$@"
4 changes: 2 additions & 2 deletions tests/unit/domains.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down