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
78 lines
1.9 KiB
Go
78 lines
1.9 KiB
Go
package scheduler
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/dokku/dokku/plugins/common"
|
|
)
|
|
|
|
// TriggerSchedulerDetect outputs a manually selected scheduler for the app
|
|
func TriggerSchedulerDetect(appName string) error {
|
|
if appName != "--global" {
|
|
if scheduler := common.PropertyGet("scheduler", appName, "selected"); scheduler != "" {
|
|
fmt.Println(scheduler)
|
|
return nil
|
|
}
|
|
}
|
|
|
|
if scheduler := common.PropertyGet("scheduler", "--global", "selected"); scheduler != "" {
|
|
fmt.Println(scheduler)
|
|
return nil
|
|
}
|
|
|
|
fmt.Println("docker-local")
|
|
return nil
|
|
}
|
|
|
|
// TriggerInstall runs the install step for the scheduler plugin
|
|
func TriggerInstall() error {
|
|
if err := common.PropertySetup("scheduler"); err != nil {
|
|
return fmt.Errorf("Unable to install the scheduler plugin: %s", err.Error())
|
|
}
|
|
|
|
if err := common.MigrateConfigToProperties("scheduler", []common.MigrateConfigEntry{
|
|
{
|
|
ConfigVar: "DOKKU_SCHEDULER",
|
|
GlobalConfigVar: "DOKKU_SCHEDULER",
|
|
Property: "selected",
|
|
},
|
|
{
|
|
ConfigVar: "DOKKU_APP_SHELL",
|
|
GlobalConfigVar: "DOKKU_APP_SHELL",
|
|
Property: "shell",
|
|
},
|
|
}); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// TriggerPostAppCloneSetup creates new scheduler files
|
|
func TriggerPostAppCloneSetup(oldAppName string, newAppName string) error {
|
|
err := common.PropertyClone("scheduler", oldAppName, newAppName)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// TriggerPostAppRenameSetup renames scheduler files
|
|
func TriggerPostAppRenameSetup(oldAppName string, newAppName string) error {
|
|
if err := common.PropertyClone("scheduler", oldAppName, newAppName); err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := common.PropertyDestroy("scheduler", oldAppName); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// TriggerPostDelete destroys the scheduler property for a given app container
|
|
func TriggerPostDelete(appName string) error {
|
|
return common.PropertyDestroy("scheduler", appName)
|
|
}
|