refactor: move all port management code to standalone ports plugin
This change makes interacting with port mappings more clear - folks might previously set the port mapping to the proxy type or vice-versa. The existing proxy:ports* commands still exist but will show a deprecation warning for a single minor release.
This commit is contained in:
@@ -2,7 +2,6 @@ package proxy
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
"github.com/dokku/dokku/plugins/common"
|
||||
"github.com/dokku/dokku/plugins/config"
|
||||
@@ -60,95 +59,6 @@ func CommandEnable(appName string, allApps bool, parallelCount int) error {
|
||||
return Enable(appName)
|
||||
}
|
||||
|
||||
// CommandPorts is a cmd wrapper to list proxy port mappings for an app
|
||||
func CommandPorts(appName string) error {
|
||||
if err := common.VerifyAppName(appName); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return listAppProxyPorts(appName)
|
||||
}
|
||||
|
||||
// CommandPortsAdd adds proxy port mappings to an app
|
||||
func CommandPortsAdd(appName string, portMaps []string) error {
|
||||
if err := common.VerifyAppName(appName); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(portMaps) == 0 {
|
||||
return errors.New("No port mapping specified")
|
||||
}
|
||||
|
||||
proxyPortMap, err := parseProxyPortMapString(strings.Join(portMaps, " "))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := addProxyPorts(appName, proxyPortMap); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return common.PlugnTrigger("post-proxy-ports-update", []string{appName, "add"}...)
|
||||
}
|
||||
|
||||
// CommandPortsClear clears all proxy port mappings for an app
|
||||
func CommandPortsClear(appName string) error {
|
||||
if err := common.VerifyAppName(appName); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
keys := []string{"DOKKU_PROXY_PORT_MAP"}
|
||||
if err := config.UnsetMany(appName, keys, false); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return common.PlugnTrigger("post-proxy-ports-update", []string{appName, "clear"}...)
|
||||
}
|
||||
|
||||
// CommandPortsRemove removes specific proxy port mappings from an app
|
||||
func CommandPortsRemove(appName string, portMaps []string) error {
|
||||
if err := common.VerifyAppName(appName); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(portMaps) == 0 {
|
||||
return errors.New("No port mapping specified")
|
||||
}
|
||||
|
||||
proxyPortMap, err := parseProxyPortMapString(strings.Join(portMaps, " "))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := removeProxyPorts(appName, proxyPortMap); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return common.PlugnTrigger("post-proxy-ports-update", []string{appName, "remove"}...)
|
||||
}
|
||||
|
||||
// CommandPortsSet sets proxy port mappings for an app
|
||||
func CommandPortsSet(appName string, portMaps []string) error {
|
||||
if err := common.VerifyAppName(appName); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(portMaps) == 0 {
|
||||
return errors.New("No port mapping specified")
|
||||
}
|
||||
|
||||
proxyPortMap, err := parseProxyPortMapString(strings.Join(portMaps, " "))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := setProxyPorts(appName, proxyPortMap); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return common.PlugnTrigger("post-proxy-ports-update", []string{appName, "set"}...)
|
||||
}
|
||||
|
||||
// CommandReport displays a proxy report for one or more apps
|
||||
func CommandReport(appName string, format string, infoFlag string) error {
|
||||
if len(appName) == 0 {
|
||||
|
||||
Reference in New Issue
Block a user