Merge pull request #8498 from dokku/migrate-env-vars-to-properties
Migrate environment variables to plugin properties
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
SUBCOMMANDS = subcommands/clone subcommands/create subcommands/destroy subcommands/exists subcommands/list subcommands/lock subcommands/locked subcommands/rename subcommands/report subcommands/unlock
|
||||
SUBCOMMANDS = subcommands/clone subcommands/create subcommands/destroy subcommands/exists subcommands/list subcommands/lock subcommands/locked subcommands/rename subcommands/report subcommands/set subcommands/unlock
|
||||
TRIGGERS = triggers/app-create triggers/app-destroy triggers/app-exists triggers/app-maybe-create triggers/deploy-source-set triggers/install triggers/post-app-clone-setup triggers/post-app-rename triggers/post-app-rename-setup triggers/post-create triggers/post-delete triggers/report
|
||||
BUILD = commands subcommands triggers
|
||||
PLUGIN_NAME = apps
|
||||
|
||||
@@ -5,11 +5,13 @@ var (
|
||||
DefaultProperties = map[string]string{
|
||||
"deploy-source": "",
|
||||
"deploy-source-metadata": "",
|
||||
"disable-autocreation": "",
|
||||
}
|
||||
|
||||
// GlobalProperties is a map of all valid global apps properties
|
||||
GlobalProperties = map[string]bool{
|
||||
"deploy-source": true,
|
||||
"deploy-source-metadata": true,
|
||||
"disable-autocreation": true,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -132,11 +132,7 @@ func maybeCreateApp(appName string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
results, _ := common.CallPlugnTrigger(common.PlugnTriggerInput{
|
||||
Trigger: "config-get-global",
|
||||
Args: []string{"DOKKU_DISABLE_APP_AUTOCREATION"},
|
||||
})
|
||||
disableAutocreate := results.StdoutContents()
|
||||
disableAutocreate := common.PropertyGetDefault("apps", "--global", "disable-autocreation", "")
|
||||
if disableAutocreate == "true" {
|
||||
common.LogWarn("App auto-creation disabled.")
|
||||
return fmt.Errorf("Re-enable app auto-creation or create an app with 'dokku apps:create %s'", appName)
|
||||
|
||||
@@ -28,6 +28,7 @@ Additional commands:`
|
||||
apps:locked <app>, Checks if an app is locked for deployment
|
||||
apps:rename <old-app> <new-app>, Rename an app
|
||||
apps:report [<app>] [<flag>], Display report about an app
|
||||
apps:set <app>|--global <key> <value>, Set or clear an apps property
|
||||
apps:unlock <app>, Unlocks an app for deployment`
|
||||
)
|
||||
|
||||
|
||||
@@ -72,6 +72,19 @@ func main() {
|
||||
appName := args.Arg(0)
|
||||
err = apps.CommandReport(appName, *format, infoFlag)
|
||||
}
|
||||
case "set":
|
||||
args := flag.NewFlagSet("apps:set", flag.ExitOnError)
|
||||
global := args.Bool("global", false, "--global: set a global property")
|
||||
args.Parse(os.Args[2:])
|
||||
appName := args.Arg(0)
|
||||
property := args.Arg(1)
|
||||
value := args.Arg(2)
|
||||
if *global {
|
||||
appName = "--global"
|
||||
property = args.Arg(0)
|
||||
value = args.Arg(1)
|
||||
}
|
||||
err = apps.CommandSet(appName, property, value)
|
||||
case "unlock":
|
||||
args := flag.NewFlagSet("apps:unlock", flag.ExitOnError)
|
||||
args.Parse(os.Args[2:])
|
||||
|
||||
@@ -226,6 +226,12 @@ func CommandReport(appName string, format string, infoFlag string) error {
|
||||
return ReportSingleApp(appName, format, infoFlag)
|
||||
}
|
||||
|
||||
// CommandSet set or clear an apps property for an app
|
||||
func CommandSet(appName string, property string, value string) error {
|
||||
common.CommandPropertySet("apps", appName, property, value, DefaultProperties, GlobalProperties)
|
||||
return nil
|
||||
}
|
||||
|
||||
// CommandUnlock unlocks an app for deployment
|
||||
func CommandUnlock(appName string) error {
|
||||
if err := common.VerifyAppName(appName); err != nil {
|
||||
|
||||
@@ -53,6 +53,15 @@ func TriggerInstall() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := common.MigrateConfigToProperties("apps", []common.MigrateConfigEntry{
|
||||
{
|
||||
GlobalConfigVar: "DOKKU_DISABLE_APP_AUTOCREATION",
|
||||
Property: "disable-autocreation",
|
||||
},
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// migrate all created-at values from app mod-time to property
|
||||
for _, appName := range apps {
|
||||
if common.PropertyExists("apps", appName, "created-at") {
|
||||
|
||||
Reference in New Issue
Block a user