refactor: drop -defaults command in favor of --global flag

This makes usage a bit simpler, at the cost of interface complexity.
This commit is contained in:
Jose Diaz-Gonzalez
2019-03-13 20:53:38 -04:00
parent bdfde9a481
commit 04a6e30e45
10 changed files with 114 additions and 122 deletions

View File

@@ -7,55 +7,49 @@ import (
)
// CommandLimit implements resource:limit
func CommandLimit(args []string, processType string, r Resource) (err error) {
var appName string
appName, err = getAppName(args)
if err != nil {
return
}
func CommandLimit(args []string, processType string, r Resource, global bool) (err error) {
appName := "_all_"
if !global {
appName, err = getAppName(args)
if err != nil {
return
}
if err = common.VerifyAppName(appName); err != nil {
common.LogFail(err.Error())
if err = common.VerifyAppName(appName); err != nil {
common.LogFail(err.Error())
}
}
return setRequestType(appName, processType, r, "limit")
}
// CommandLimitClear implements resource:limit-clear
func CommandLimitClear(args []string, processType string) (err error) {
func CommandLimitClear(args []string, processType string, global bool) (err error) {
return nil
}
// CommandLimitDefaults implements resource:limit-defaults
func CommandLimitDefaults(args []string, processType string, r Resource) (err error) {
return setRequestType("_all_", "", r, "limit")
}
// CommandReserve implements resource:reserve
func CommandReserve(args []string, processType string, r Resource) (err error) {
var appName string
appName, err = getAppName(args)
if err != nil {
return
}
func CommandReserve(args []string, processType string, r Resource, global bool) (err error) {
appName := "_all_"
if !global {
appName, err = getAppName(args)
if err != nil {
return
}
if err = common.VerifyAppName(appName); err != nil {
common.LogFail(err.Error())
if err = common.VerifyAppName(appName); err != nil {
common.LogFail(err.Error())
}
}
return setRequestType(appName, processType, r, "reserve")
}
// CommandReserveClear implements resource:reserve-clear
func CommandReserveClear(args []string, processType string) (err error) {
func CommandReserveClear(args []string, processType string, global bool) (err error) {
return nil
}
// CommandReserveDefaults implements resource:reserve-defaults
func CommandReserveDefaults(args []string, processType string, r Resource) (err error) {
return setRequestType("_all_", "", r, "reserve")
}
func setRequestType(appName string, processType string, r Resource, requestType string) (err error) {
if len(processType) == 0 {
processType = "_all_"