feat: use ports-clear plugn trigger to manage clearing the port map
This removes any access to the underlying implementation for port map clearing, which will make it easier to refactor the actual clearing.
This commit is contained in:
1 parent
fb9d77878d
commit
1431724b85
12 files changed
+45
-8
No files matched your search
@@ -29,7 +29,7 @@ Dokku will only select the `dockerfile` builder if both the `herokuish` and `pac
|
|||||||
If an application was previously deployed via buildpacks, the following commands should be run before a Dockerfile deploy will succeed:
|
If an application was previously deployed via buildpacks, the following commands should be run before a Dockerfile deploy will succeed:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
dokku config:unset --no-restart node-js-app DOKKU_PROXY_PORT_MAP
|
dokku proxy:clear node-js-app
|
||||||
```
|
```
|
||||||
|
|
||||||
### Changing the `Dockerfile` location
|
### Changing the `Dockerfile` location
|
||||||
|
|||||||
@@ -301,7 +301,7 @@ false
|
|||||||
If an application was previously deployed via Dockerfile, the following commands should be run before a buildpack deploy will succeed:
|
If an application was previously deployed via Dockerfile, the following commands should be run before a buildpack deploy will succeed:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
dokku config:unset --no-restart node-js-app DOKKU_PROXY_PORT_MAP
|
dokku ports:clear node-js-app
|
||||||
```
|
```
|
||||||
|
|
||||||
### Using a specific buildpack version
|
### Using a specific buildpack version
|
||||||
|
|||||||
@@ -1242,12 +1242,32 @@ nginx -t
|
|||||||
```
|
```
|
||||||
|
|
||||||
### `ports-get`
|
### `ports-get`
|
||||||
|
|
||||||
- Description: Returns a list of port mappings, newline delimited
|
- Description: Returns a list of port mappings, newline delimited
|
||||||
- Invoked by: Various networking plugins
|
- Invoked by: Various networking plugins
|
||||||
- Arguments `$APP`
|
- Arguments `$APP`
|
||||||
|
- Example:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||||
|
|
||||||
|
# TODO
|
||||||
|
```
|
||||||
|
|
||||||
|
### `ports-clear`
|
||||||
|
|
||||||
|
- Description: Clears the ports for a given app without triggering further restarts or rebuilds
|
||||||
|
- Invoked by: internally
|
||||||
|
- Arguments: `$APP`
|
||||||
|
- Example:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Symlink
+1
@@ -0,0 +1 @@
|
|||||||
|
hook
|
||||||
@@ -10,7 +10,8 @@ trigger-nginx-vhosts-pre-disable-vhost() {
|
|||||||
declare APP="$1"
|
declare APP="$1"
|
||||||
|
|
||||||
if [[ "$(plugn trigger proxy-type "$APP")" == "nginx" ]]; then
|
if [[ "$(plugn trigger proxy-type "$APP")" == "nginx" ]]; then
|
||||||
DOKKU_QUIET_OUTPUT=1 config_unset --no-restart "$APP" DOKKU_PROXY_PORT DOKKU_PROXY_SSL_PORT DOKKU_PROXY_PORT_MAP
|
DOKKU_QUIET_OUTPUT=1 config_unset --no-restart "$APP" DOKKU_PROXY_PORT DOKKU_PROXY_SSL_PORT
|
||||||
|
plugn trigger ports-clear "$APP"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ trigger-nginx-vhosts-pre-enable-vhost() {
|
|||||||
declare APP="$1"
|
declare APP="$1"
|
||||||
|
|
||||||
if [[ "$(plugn trigger proxy-type "$APP")" == "nginx" ]]; then
|
if [[ "$(plugn trigger proxy-type "$APP")" == "nginx" ]]; then
|
||||||
DOKKU_QUIET_OUTPUT=1 config_unset --no-restart "$APP" DOKKU_PROXY_PORT DOKKU_PROXY_SSL_PORT DOKKU_PROXY_PORT_MAP
|
DOKKU_QUIET_OUTPUT=1 config_unset --no-restart "$APP" DOKKU_PROXY_PORT DOKKU_PROXY_SSL_PORT
|
||||||
|
plugn trigger ports-clear "$APP"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,5 +3,6 @@
|
|||||||
/triggers/*
|
/triggers/*
|
||||||
/triggers
|
/triggers
|
||||||
/install
|
/install
|
||||||
|
/ports-*
|
||||||
/post-*
|
/post-*
|
||||||
/report
|
/report
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
SUBCOMMANDS = subcommands/list subcommands/add subcommands/clear subcommands/remove subcommands/set subcommands/report
|
SUBCOMMANDS = subcommands/list subcommands/add subcommands/clear subcommands/remove subcommands/set subcommands/report
|
||||||
TRIGGERS = triggers/ports-get triggers/post-certs-remove triggers/post-certs-update triggers/report
|
TRIGGERS = triggers/ports-clear triggers/ports-get triggers/post-certs-remove triggers/post-certs-update triggers/report
|
||||||
BUILD = commands subcommands triggers
|
BUILD = commands subcommands triggers
|
||||||
PLUGIN_NAME = ports
|
PLUGIN_NAME = ports
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,13 @@ func addPortMaps(appName string, portMaps []PortMap) error {
|
|||||||
return setPortMaps(appName, allPortMaps)
|
return setPortMaps(appName, allPortMaps)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func clearPorts(appName string) error {
|
||||||
|
return common.EnvWrap(func() error {
|
||||||
|
keys := []string{"DOKKU_PROXY_PORT_MAP"}
|
||||||
|
return config.UnsetMany(appName, keys, false)
|
||||||
|
}, map[string]string{"DOKKU_QUIET_OUTPUT": "1"})
|
||||||
|
}
|
||||||
|
|
||||||
func filterAppPortMaps(appName string, scheme string, hostPort int) []PortMap {
|
func filterAppPortMaps(appName string, scheme string, hostPort int) []PortMap {
|
||||||
var filteredPortMaps []PortMap
|
var filteredPortMaps []PortMap
|
||||||
for _, portMap := range getPortMaps(appName) {
|
for _, portMap := range getPortMaps(appName) {
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ func main() {
|
|||||||
case "ports-get":
|
case "ports-get":
|
||||||
appName := flag.Arg(0)
|
appName := flag.Arg(0)
|
||||||
err = ports.TriggerPortsGet(appName)
|
err = ports.TriggerPortsGet(appName)
|
||||||
|
case "ports-clear":
|
||||||
|
appName := flag.Arg(0)
|
||||||
|
err = ports.TriggerPortsClear(appName)
|
||||||
case "post-certs-remove":
|
case "post-certs-remove":
|
||||||
appName := flag.Arg(0)
|
appName := flag.Arg(0)
|
||||||
err = ports.TriggerPostCertsRemove(appName)
|
err = ports.TriggerPostCertsRemove(appName)
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/dokku/dokku/plugins/common"
|
"github.com/dokku/dokku/plugins/common"
|
||||||
"github.com/dokku/dokku/plugins/config"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// CommandList is a cmd wrapper to list port mappings for an app
|
// CommandList is a cmd wrapper to list port mappings for an app
|
||||||
@@ -45,8 +44,7 @@ func CommandClear(appName string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
keys := []string{"DOKKU_PROXY_PORT_MAP"}
|
if err := clearPorts(appName); err != nil {
|
||||||
if err := config.UnsetMany(appName, keys, false); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,11 @@ func TriggerPortsGet(appName string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TriggerPortsClear removes all ports for the specified app
|
||||||
|
func TriggerPortsClear(appName string) error {
|
||||||
|
return clearPorts(appName)
|
||||||
|
}
|
||||||
|
|
||||||
// TriggerPostCertsRemove unsets port config vars after SSL cert is added
|
// TriggerPostCertsRemove unsets port config vars after SSL cert is added
|
||||||
func TriggerPostCertsRemove(appName string) error {
|
func TriggerPostCertsRemove(appName string) error {
|
||||||
keys := []string{"DOKKU_PROXY_SSL_PORT"}
|
keys := []string{"DOKKU_PROXY_SSL_PORT"}
|
||||||
|
|||||||
Reference in new issue
Block a user