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:
@@ -192,6 +192,76 @@ func main() {
|
||||
fmt.Fprintln(os.Stderr, err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
case "migrate-config-to-property":
|
||||
property := flag.Arg(2)
|
||||
configVar := flag.Arg(3)
|
||||
|
||||
globalConfigVar := ""
|
||||
transformName := ""
|
||||
listProperty := false
|
||||
for i := 4; i < flag.NArg(); i++ {
|
||||
arg := flag.Arg(i)
|
||||
switch {
|
||||
case arg == "--list":
|
||||
listProperty = true
|
||||
case arg == "--global-config-var" && i+1 < flag.NArg():
|
||||
i++
|
||||
globalConfigVar = flag.Arg(i)
|
||||
case arg == "--transform" && i+1 < flag.NArg():
|
||||
i++
|
||||
transformName = flag.Arg(i)
|
||||
}
|
||||
}
|
||||
|
||||
var transform func(string) string
|
||||
switch transformName {
|
||||
case "restore-bool":
|
||||
transform = func(value string) string {
|
||||
if value == "0" {
|
||||
return "false"
|
||||
}
|
||||
return "true"
|
||||
}
|
||||
case "non-empty-to-true":
|
||||
transform = func(value string) string {
|
||||
if value != "" {
|
||||
return "true"
|
||||
}
|
||||
return value
|
||||
}
|
||||
case "skip-all-checks-to-disabled":
|
||||
transform = func(value string) string {
|
||||
if value == "true" {
|
||||
return "_all_"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
case "checks-enabled-to-skipped":
|
||||
transform = func(value string) string {
|
||||
if value == "0" {
|
||||
return "_all_"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
case "":
|
||||
// no transform
|
||||
default:
|
||||
fmt.Fprintf(os.Stderr, "Unknown transform: %s\n", transformName)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
entry := common.MigrateConfigEntry{
|
||||
ConfigVar: configVar,
|
||||
GlobalConfigVar: globalConfigVar,
|
||||
Property: property,
|
||||
Transform: transform,
|
||||
ListProperty: listProperty,
|
||||
}
|
||||
|
||||
if err := common.MigrateConfigToProperties(pluginName, []common.MigrateConfigEntry{entry}); err != nil {
|
||||
fmt.Fprintln(os.Stderr, err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
case "set":
|
||||
appName := flag.Arg(2)
|
||||
property := flag.Arg(3)
|
||||
|
||||
Reference in New Issue
Block a user