Skip to content

domains:clear is misleading #7438

Open
@turicas

Description

@turicas

Description of problem

The semantics of domains:clear and domains:clear-global are not the same and induces the user to errors.

domains:clear-global completely removes the global domains, by calling the function below:

# plugins/domains/functions
domains_clear_global() {
  declare desc="remove all domains"
  local GLOBAL_VHOST_PATH="$DOKKU_ROOT/VHOST"

  rm "$GLOBAL_VHOST_PATH"
  touch "$GLOBAL_VHOST_PATH"
}

On the other hand, domains:clear removes the app's vhost file and then calls domains_setup "$APP", which copies the default vhost file to the app's directory. So it's more like a "reset" (reset to the global defaults) than a "clear" (remove all the domains).

I think domains:clear must really remove all the domains associated with the app. And if it's desirable to have a feature to "reset" the app domains to the global ones, I propose adding a domains:reset <app-name> command, which would do this action. These changes would make the command more or less backwards incompatible, but I think it's more like a bug-fix than an API change.
Another option would be to deprecate domains:clear and implement two new ones: domains:reset and domains:remove-all.

I'm willing to implement this if the idea is accepted. If not accepted, I think there should be a documentation change clarifying this behavior (the current one says domains:clear "Clear all domains for app").

Steps to reproduce

dokku domains:clear-global
dokku domains:report --global
dokku domains:add-global test1.example.com
dokku domains:add-global test2.example.com
dokku apps:create test-app
dokku apps:domains:report test-app
# Got: test-app.test1.example.com and test-app.test2.example.com (as expected)

dokku domains:report test-app
dokku domains:clear test-app
dokku domains:report test-app 
# Got: test-app.test1.example.com and test-app.test2.example.com (instead of none)

dokku report $APP_NAME

Not applicable.

Additional information

No response

Output of failing commands after running: dokku trace:off

No response

Output of failing commands after running: dokku trace:on

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions