mirror of
https://github.com/dokku/dokku.git
synced 2026-08-29 10:08:53 +02:00
Merge pull request #8498 from dokku/migrate-env-vars-to-properties
Migrate environment variables to plugin properties
This commit is contained in:
@@ -4,10 +4,12 @@ var (
|
||||
// DefaultProperties is a map of all valid scheduler properties with corresponding default property values
|
||||
DefaultProperties = map[string]string{
|
||||
"selected": "docker-local",
|
||||
"shell": "",
|
||||
}
|
||||
|
||||
// GlobalProperties is a map of all valid global scheduler properties
|
||||
GlobalProperties = map[string]bool{
|
||||
"selected": true,
|
||||
"shell": true,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package scheduler
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/dokku/dokku/plugins/common"
|
||||
@@ -31,53 +30,19 @@ func TriggerInstall() error {
|
||||
return fmt.Errorf("Unable to install the scheduler plugin: %s", err.Error())
|
||||
}
|
||||
|
||||
apps, err := common.UnfilteredDokkuApps()
|
||||
if err != nil && !errors.Is(err, common.NoAppsExist) {
|
||||
return nil
|
||||
}
|
||||
|
||||
results, _ := common.CallPlugnTrigger(common.PlugnTriggerInput{
|
||||
Trigger: "config-get-global",
|
||||
Args: []string{"DOKKU_SCHEDULER"},
|
||||
})
|
||||
globalScheduler := results.StdoutContents()
|
||||
if globalScheduler != "" {
|
||||
common.LogVerboseQuiet(fmt.Sprintf("Setting scheduler property 'selected' to %v", globalScheduler))
|
||||
if err := common.PropertyWrite("scheduler", "--global", "selected", globalScheduler); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err := common.CallPlugnTrigger(common.PlugnTriggerInput{
|
||||
Trigger: "config-unset",
|
||||
Args: []string{"--global", "DOKKU_SCHEDULER"},
|
||||
})
|
||||
if err != nil {
|
||||
common.LogWarn(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
for _, appName := range apps {
|
||||
results, _ := common.CallPlugnTrigger(common.PlugnTriggerInput{
|
||||
Trigger: "config-get",
|
||||
Args: []string{appName, "DOKKU_SCHEDULER"},
|
||||
})
|
||||
scheduler := results.StdoutContents()
|
||||
if scheduler == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
common.LogVerboseQuiet(fmt.Sprintf("Setting %s scheduler property 'selected' to %v", appName, scheduler))
|
||||
if err := common.PropertyWrite("scheduler", appName, "selected", scheduler); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err := common.CallPlugnTrigger(common.PlugnTriggerInput{
|
||||
Trigger: "config-unset",
|
||||
Args: []string{appName, "DOKKU_SCHEDULER"},
|
||||
})
|
||||
if err != nil {
|
||||
common.LogWarn(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
|
||||
|
||||
Reference in New Issue
Block a user