feat: migrate environment variables to plugin properties
Standardize how environment variables are migrated to properties during install triggers and migrate all remaining DOKKU_* config vars to their appropriate plugin properties. Adds a reusable MigrateConfigToProperties() function in the common package with Transform callback and ListProperty support, plus a migrate-config-to-property subcommand for the prop binary so shell plugins can use the same code path. Migrated variables and their new property owners: - DOKKU_APP_PROXY_TYPE/DOKKU_PROXY_TYPE → proxy type - DOKKU_DISABLE_PROXY → proxy disabled - DOKKU_PROXY_PORT → ports proxy-port - DOKKU_PROXY_SSL_PORT → ports proxy-ssl-port - DOKKU_APP_RESTORE → ps restore - DOKKU_SKIP_DEPLOY → ps skip-deploy - DOKKU_START_CMD → ps start-cmd - DOKKU_DOCKERFILE_START_CMD → ps dockerfile-start-cmd - DOKKU_DISABLE_APP_AUTOCREATION → apps disable-autocreation - DOKKU_APP_SHELL → scheduler shell - DOKKU_SKIP_CLEANUP → builder skip-cleanup - DOKKU_CHECKS_DISABLED → checks disabled - DOKKU_CHECKS_SKIPPED → checks skipped - DOKKU_CHECKS_WAIT → checks wait - DOKKU_CHECKS_TIMEOUT → checks timeout - DOKKU_CHECKS_ATTEMPTS → checks attempts - DOKKU_DEFAULT_CHECKS_WAIT → checks default-wait - DOKKU_SKIP_ALL_CHECKS → checks disabled (legacy) - DOKKU_SKIP_DEFAULT_CHECKS → checks skipped (legacy) Also refactors existing bespoke migration loops in scheduler, ports, ps, builder, and nginx-vhosts plugins to use the standardized utility. Removes DOKKU_PARALLEL_ARGUMENTS from documentation (unused in core). Deprecates fn-migrate-config-to-property bash function. closes #1558
This commit is contained in:
45 files changed
+604
-468
No files matched your search
+20
-33
@@ -10,7 +10,6 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/dokku/dokku/plugins/common"
|
||||
"github.com/dokku/dokku/plugins/config"
|
||||
"github.com/ryanuber/columnize"
|
||||
)
|
||||
|
||||
@@ -162,11 +161,8 @@ func getDetectedPortMaps(appName string) []PortMap {
|
||||
// getGlobalProxyPort gets the global proxy port
|
||||
func getGlobalProxyPort() int {
|
||||
port := 0
|
||||
results, _ := common.CallPlugnTrigger(common.PlugnTriggerInput{
|
||||
Trigger: "config-get-global",
|
||||
Args: []string{"DOKKU_PROXY_PORT"},
|
||||
})
|
||||
if intVar, err := strconv.Atoi(results.StdoutContents()); err == nil {
|
||||
value := common.PropertyGet("ports", "--global", "proxy-port")
|
||||
if intVar, err := strconv.Atoi(value); err == nil {
|
||||
port = intVar
|
||||
}
|
||||
|
||||
@@ -176,11 +172,8 @@ func getGlobalProxyPort() int {
|
||||
// getGlobalProxySSLPort gets the global proxy ssl port
|
||||
func getGlobalProxySSLPort() int {
|
||||
port := 0
|
||||
results, _ := common.CallPlugnTrigger(common.PlugnTriggerInput{
|
||||
Trigger: "config-get-global",
|
||||
Args: []string{"DOKKU_PROXY_SSL_PORT"},
|
||||
})
|
||||
if intVar, err := strconv.Atoi(results.StdoutContents()); err == nil {
|
||||
value := common.PropertyGet("ports", "--global", "proxy-ssl-port")
|
||||
if intVar, err := strconv.Atoi(value); err == nil {
|
||||
port = intVar
|
||||
}
|
||||
|
||||
@@ -201,11 +194,8 @@ func getPortMaps(appName string) []PortMap {
|
||||
// getProxyPort gets the proxy port for an app
|
||||
func getProxyPort(appName string) int {
|
||||
port := 0
|
||||
results, _ := common.CallPlugnTrigger(common.PlugnTriggerInput{
|
||||
Trigger: "config-get",
|
||||
Args: []string{appName, "DOKKU_PROXY_PORT"},
|
||||
})
|
||||
if intVar, err := strconv.Atoi(results.StdoutContents()); err == nil {
|
||||
value := common.PropertyGet("ports", appName, "proxy-port")
|
||||
if intVar, err := strconv.Atoi(value); err == nil {
|
||||
port = intVar
|
||||
}
|
||||
|
||||
@@ -215,11 +205,8 @@ func getProxyPort(appName string) int {
|
||||
// getProxySSLPort gets the proxy ssl port for an app
|
||||
func getProxySSLPort(appName string) int {
|
||||
port := 0
|
||||
results, _ := common.CallPlugnTrigger(common.PlugnTriggerInput{
|
||||
Trigger: "config-get",
|
||||
Args: []string{appName, "DOKKU_PROXY_SSL_PORT"},
|
||||
})
|
||||
if intVar, err := strconv.Atoi(results.StdoutContents()); err == nil {
|
||||
value := common.PropertyGet("ports", appName, "proxy-ssl-port")
|
||||
if intVar, err := strconv.Atoi(value); err == nil {
|
||||
port = intVar
|
||||
}
|
||||
|
||||
@@ -445,22 +432,22 @@ func setPortMaps(appName string, portMaps []PortMap) error {
|
||||
|
||||
// setProxyPort sets the proxy port for an app
|
||||
func setProxyPort(appName string, port int) error {
|
||||
return common.EnvWrap(func() error {
|
||||
entries := map[string]string{
|
||||
"DOKKU_PROXY_PORT": fmt.Sprint(port),
|
||||
}
|
||||
return config.SetMany(appName, entries, false, false)
|
||||
}, map[string]string{"DOKKU_QUIET_OUTPUT": "1"})
|
||||
return common.PropertyWrite("ports", appName, "proxy-port", fmt.Sprint(port))
|
||||
}
|
||||
|
||||
// setProxySSLPort sets the proxy ssl port for an app
|
||||
func setProxySSLPort(appName string, port int) error {
|
||||
return common.EnvWrap(func() error {
|
||||
entries := map[string]string{
|
||||
"DOKKU_PROXY_SSL_PORT": fmt.Sprint(port),
|
||||
}
|
||||
return config.SetMany(appName, entries, false, false)
|
||||
}, map[string]string{"DOKKU_QUIET_OUTPUT": "1"})
|
||||
return common.PropertyWrite("ports", appName, "proxy-ssl-port", fmt.Sprint(port))
|
||||
}
|
||||
|
||||
// transformPortMap normalizes a port map string for migration to list properties
|
||||
func transformPortMap(value string) string {
|
||||
portMaps, _ := parsePortMapString(value)
|
||||
var parts []string
|
||||
for _, portMap := range portMaps {
|
||||
parts = append(parts, portMap.String())
|
||||
}
|
||||
return strings.Join(parts, " ")
|
||||
}
|
||||
|
||||
// uniquePortMaps returns a unique set of port maps
|
||||
|
||||
Reference in new issue
Block a user