refactor: rename command to :set-property
This will allow us to set other property values for the buildpacks plugin.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
SUBCOMMANDS = subcommands/add subcommands/clear subcommands/list subcommands/remove subcommands/report subcommands/set subcommands/stack-set
|
||||
SUBCOMMANDS = subcommands/add subcommands/clear subcommands/list subcommands/remove subcommands/report subcommands/set subcommands/set-property
|
||||
TRIGGERS = triggers/buildpack-stack-name triggers/install triggers/post-app-clone-setup triggers/post-app-rename-setup triggers/post-delete triggers/post-extract triggers/report
|
||||
BUILD = commands subcommands triggers
|
||||
PLUGIN_NAME = buildpacks
|
||||
|
||||
@@ -42,7 +42,7 @@ func reportComputedStack(appName string) string {
|
||||
|
||||
b, _ := common.PlugnTriggerOutput("config-get", []string{appName, "DOKKU_IMAGE"}...)
|
||||
if dokkuImage := strings.TrimSpace(string(b[:])); dokkuImage != "" {
|
||||
common.LogWarn("Deprecated: use buildpacks:stack-set instead of specifying DOKKU_IMAGE environment variable")
|
||||
common.LogWarn("Deprecated: use buildpacks:set-property instead of specifying DOKKU_IMAGE environment variable")
|
||||
return dokkuImage
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ Additional commands:`
|
||||
buildpacks:remove <app> <buildpack>, Remove a buildpack set on the app
|
||||
buildpacks:report [<app>] [<flag>], Displays a buildpack report for one or more apps
|
||||
buildpacks:set [--index 1] <app> <buildpack>, Set new app buildpack at a given position defaulting to the first buildpack if no index is specified
|
||||
buildpacks:stack-set <app> <stack>, Sets the stack of an app
|
||||
buildpacks:set-property [--global|<app>] <key> <value>, Set or clear a buildpacks property for an app
|
||||
`
|
||||
)
|
||||
|
||||
|
||||
@@ -57,17 +57,19 @@ func main() {
|
||||
appName := args.Arg(0)
|
||||
buildpack := args.Arg(1)
|
||||
err = buildpacks.CommandSet(appName, buildpack, *index)
|
||||
case "stack-set":
|
||||
args := flag.NewFlagSet("buildpacks:stack-set", flag.ExitOnError)
|
||||
case "set-property":
|
||||
args := flag.NewFlagSet("buildpacks:set-property", flag.ExitOnError)
|
||||
global := args.Bool("global", false, "--global: set a global property")
|
||||
args.Parse(os.Args[2:])
|
||||
appName := args.Arg(0)
|
||||
stack := args.Arg(1)
|
||||
property := args.Arg(1)
|
||||
value := args.Arg(2)
|
||||
if *global {
|
||||
appName = "--global"
|
||||
stack = args.Arg(0)
|
||||
property = args.Arg(0)
|
||||
value = args.Arg(1)
|
||||
}
|
||||
err = buildpacks.CommandStackSet(appName, stack)
|
||||
err = buildpacks.CommandSetProperty(appName, property, value)
|
||||
default:
|
||||
common.LogFail(fmt.Sprintf("Invalid plugin subcommand call: %s", subcommand))
|
||||
}
|
||||
|
||||
@@ -139,12 +139,16 @@ func CommandSet(appName string, buildpack string, index int) error {
|
||||
return common.PropertyListSet("buildpacks", appName, "buildpacks", buildpack, index)
|
||||
}
|
||||
|
||||
// CommandStackSet implements buildpacks:stack-set
|
||||
func CommandStackSet(appName string, stack string) error {
|
||||
oldStack := common.PropertyGet("buildpacks", appName, "stack")
|
||||
common.CommandPropertySet("buildpacks", appName, "stack", stack, DefaultProperties, GlobalProperties)
|
||||
if oldStack != stack {
|
||||
return common.PlugnTrigger("post-stack-set", []string{appName, stack}...)
|
||||
// CommandSetProperty implements buildpacks:set-property
|
||||
func CommandSetProperty(appName string, property string, value string) error {
|
||||
oldStack := ""
|
||||
if property == "stack" {
|
||||
oldStack = common.PropertyGet("buildpacks", appName, "stack")
|
||||
}
|
||||
|
||||
common.CommandPropertySet("buildpacks", appName, property, value, DefaultProperties, GlobalProperties)
|
||||
if property == "stack" && oldStack != value {
|
||||
return common.PlugnTrigger("post-stack-set", []string{appName, value}...)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -25,7 +25,7 @@ func TriggerBuildpackStackName(appName string) error {
|
||||
b, _ := common.PlugnTriggerOutput("config-get", []string{appName, "DOKKU_IMAGE"}...)
|
||||
dokkuImage := strings.TrimSpace(string(b[:]))
|
||||
if dokkuImage != "" {
|
||||
common.LogWarn("Deprecated: use buildpacks:stack-set instead of specifying DOKKU_IMAGE environment variable")
|
||||
common.LogWarn("Deprecated: use buildpacks:set-property instead of specifying DOKKU_IMAGE environment variable")
|
||||
fmt.Println(dokkuImage)
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user