Merge pull request #5017 from dokku/5002-proxy-clear-config
Add command to clear all proxy configs
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
```
|
||||
proxy:build-config [--parallel count] [--all|<app>] # (Re)builds config for given app
|
||||
proxy:clear-config [--all|<app>] # Clears config for given app
|
||||
proxy:disable [--parallel count] [--all|<app>] # Disable proxy for app
|
||||
proxy:enable [--parallel count] [--all|<app>] # Enable proxy for app
|
||||
proxy:report [<app>] [<flag>] # Displays a proxy report for one or more apps
|
||||
@@ -40,6 +41,24 @@ Finally, the number of parallel workers may be automatically set to the number o
|
||||
dokku proxy:build-config --all --parallel -1
|
||||
```
|
||||
|
||||
### Clearing the generated proxy config
|
||||
|
||||
> New as of 0.27.0
|
||||
|
||||
Generated proxy configurations can also be cleared using the `proxy:clear-config` command.
|
||||
|
||||
```shell
|
||||
dokku proxy:clear-config node-js-app
|
||||
```
|
||||
|
||||
All apps may have their proxy config cleared by using the `--all` flag.
|
||||
|
||||
```shell
|
||||
dokku proxy:clear-config --all
|
||||
```
|
||||
|
||||
Clearing a proxy configuration has different effects depending on the proxy plugin in use. Consul the documentation for your proxy implementation for further details.
|
||||
|
||||
### Displaying proxy reports for an app
|
||||
|
||||
> New as of 0.8.1
|
||||
|
||||
@@ -4,9 +4,8 @@ set -eo pipefail
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/internal-functions"
|
||||
|
||||
trigger-nginx-vhosts-proxy-clear-config() {
|
||||
declare desc="clear nginx config for proxy app containers from command line"
|
||||
declare trigger="proxy-clear-config"
|
||||
fn-trigger-nginx-vhosts-proxy-clear-config-app() {
|
||||
declare desc="clears the proxy config for a single app"
|
||||
declare APP="$1"
|
||||
|
||||
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
|
||||
@@ -16,4 +15,22 @@ trigger-nginx-vhosts-proxy-clear-config() {
|
||||
fi
|
||||
}
|
||||
|
||||
trigger-nginx-vhosts-proxy-clear-config() {
|
||||
declare desc="clear nginx config for proxy app containers from command line"
|
||||
declare trigger="proxy-clear-config"
|
||||
declare APP="$1"
|
||||
|
||||
if [[ "$APP" == "--all" ]]; then
|
||||
exit_code="0"
|
||||
for app in $(dokku_apps); do
|
||||
if ! fn-trigger-nginx-vhosts-proxy-clear-config-app "$app"; then
|
||||
exit_code="$?"
|
||||
fi
|
||||
done
|
||||
return "$exit_code"
|
||||
fi
|
||||
|
||||
fn-trigger-nginx-vhosts-proxy-clear-config-app "$APP"
|
||||
}
|
||||
|
||||
trigger-nginx-vhosts-proxy-clear-config "$@"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
SUBCOMMANDS = subcommands/build-config subcommands/disable subcommands/enable subcommands/ports subcommands/ports-add subcommands/ports-clear subcommands/ports-remove subcommands/ports-set subcommands/report subcommands/set
|
||||
SUBCOMMANDS = subcommands/build-config subcommands/clear-config subcommands/disable subcommands/enable subcommands/ports subcommands/ports-add subcommands/ports-clear subcommands/ports-remove subcommands/ports-set subcommands/report subcommands/set
|
||||
TRIGGERS = triggers/proxy-is-enabled triggers/proxy-type triggers/post-certs-remove triggers/post-certs-update triggers/report
|
||||
BUILD = commands subcommands triggers
|
||||
PLUGIN_NAME = proxy
|
||||
|
||||
@@ -32,6 +32,11 @@ func BuildConfig(appName string) error {
|
||||
return common.PlugnTrigger("proxy-build-config", []string{appName}...)
|
||||
}
|
||||
|
||||
// ClearConfig clears the proxy config for the specified app
|
||||
func ClearConfig(appName string) error {
|
||||
return common.PlugnTrigger("proxy-clear-config", []string{appName}...)
|
||||
}
|
||||
|
||||
// Disable disables proxy implementations for the specified app
|
||||
func Disable(appName string) error {
|
||||
if !IsAppProxyEnabled(appName) {
|
||||
|
||||
@@ -18,7 +18,8 @@ Manage the proxy integration for an app
|
||||
Additional commands:`
|
||||
|
||||
helpContent = `
|
||||
proxy:build-config <app>, (Re)builds config for a given app
|
||||
proxy:build-config [--parallel count] [--all|<app>], (Re)builds config for a given app
|
||||
proxy:clear-config [--all|<app>], Clears config for a given app
|
||||
proxy:disable <app>, Disable proxy for app
|
||||
proxy:enable <app>, Enable proxy for app
|
||||
proxy:ports <app>, List proxy port mappings for app
|
||||
|
||||
@@ -25,6 +25,12 @@ func main() {
|
||||
args.Parse(os.Args[2:])
|
||||
appName := args.Arg(0)
|
||||
err = proxy.CommandBuildConfig(appName, *allApps, *parallelCount)
|
||||
case "clear-config":
|
||||
args := flag.NewFlagSet("proxy:clear-config", flag.ExitOnError)
|
||||
allApps := args.Bool("all", false, "--all: build-config for all apps")
|
||||
args.Parse(os.Args[2:])
|
||||
appName := args.Arg(0)
|
||||
err = proxy.CommandClearConfig(appName, *allApps)
|
||||
case "disable":
|
||||
args := flag.NewFlagSet("proxy:disable", flag.ExitOnError)
|
||||
allApps := args.Bool("all", false, "--all: disable proxy for all apps")
|
||||
|
||||
@@ -21,6 +21,19 @@ func CommandBuildConfig(appName string, allApps bool, parallelCount int) error {
|
||||
return BuildConfig(appName)
|
||||
}
|
||||
|
||||
// CommandClearConfig clears config for a given app
|
||||
func CommandClearConfig(appName string, allApps bool) error {
|
||||
if allApps {
|
||||
return ClearConfig("--all")
|
||||
}
|
||||
|
||||
if err := common.VerifyAppName(appName); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return ClearConfig(appName)
|
||||
}
|
||||
|
||||
// CommandDisable disables the proxy for app via command line
|
||||
func CommandDisable(appName string, allApps bool, parallelCount int) error {
|
||||
if allApps {
|
||||
|
||||
@@ -218,16 +218,8 @@ func removeProcfile(appName string) error {
|
||||
}
|
||||
|
||||
func restorePrep() error {
|
||||
apps, err := common.DokkuApps()
|
||||
if err != nil {
|
||||
common.LogWarn(err.Error())
|
||||
return nil
|
||||
}
|
||||
|
||||
for _, appName := range apps {
|
||||
if err := common.PlugnTrigger("proxy-clear-config", []string{appName}...); err != nil {
|
||||
return fmt.Errorf("Error clearing proxy config: %s", err)
|
||||
}
|
||||
if err := common.PlugnTrigger("proxy-clear-config", []string{"--all"}...); err != nil {
|
||||
return fmt.Errorf("Error clearing proxy config: %s", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -99,7 +99,7 @@ func Restore(appName string) error {
|
||||
|
||||
common.LogInfo1("Clearing potentially invalid proxy configuration")
|
||||
if err := common.PlugnTrigger("proxy-clear-config", []string{appName}...); err != nil {
|
||||
return fmt.Errorf("Error clearing proxy config: %s", err)
|
||||
common.LogWarn(fmt.Sprintf("Error clearing proxy config: %s", err))
|
||||
}
|
||||
|
||||
if !common.IsDeployed(appName) {
|
||||
|
||||
@@ -28,6 +28,68 @@ teardown() {
|
||||
assert_output "$help_output"
|
||||
}
|
||||
|
||||
@test "(proxy) proxy:build-config/clear-config" {
|
||||
run deploy_app
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "test -f $DOKKU_ROOT/$TEST_APP/nginx.conf"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "rm -f $DOKKU_ROOT/$TEST_APP/nginx.conf"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "test -f $DOKKU_ROOT/$TEST_APP/nginx.conf"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_failure
|
||||
|
||||
run /bin/bash -c "dokku proxy:build-config $TEST_APP"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "test -f $DOKKU_ROOT/$TEST_APP/nginx.conf"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku proxy:clear-config $TEST_APP"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "test -f $DOKKU_ROOT/$TEST_APP/nginx.conf"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_failure
|
||||
|
||||
run /bin/bash -c "dokku proxy:build-config $TEST_APP"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "test -f $DOKKU_ROOT/$TEST_APP/nginx.conf"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku proxy:clear-config --all"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "test -f $DOKKU_ROOT/$TEST_APP/nginx.conf"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_failure
|
||||
}
|
||||
|
||||
@test "(proxy) proxy:enable/disable" {
|
||||
deploy_app
|
||||
assert_nonssl_domain "${TEST_APP}.dokku.me"
|
||||
|
||||
Reference in New Issue
Block a user