// LimitsSet sets an app's limits. func LimitsSet(appID string, limits []string, limitType string) error { c, appID, err := load(appID) if err != nil { return err } limitsMap := parseLimits(limits) fmt.Print("Applying limits... ") quit := progress() configObj := api.Config{} if limitType == "cpu" { configObj.CPU = limitsMap } else { configObj.Memory = limitsMap } _, err = config.Set(c, appID, configObj) quit <- true <-quit if err != nil { return err } fmt.Print("done\n\n") return LimitsList(appID) }
// TagsUnset removes an app's tags. func TagsUnset(appID string, tags []string) error { c, appID, err := load(appID) if err != nil { return err } fmt.Print("Applying tags... ") quit := progress() configObj := api.Config{} tagsMap := make(map[string]interface{}) for _, tag := range tags { tagsMap[tag] = nil } configObj.Tags = tagsMap _, err = config.Set(c, appID, configObj) quit <- true <-quit if err != nil { return err } fmt.Print("done\n\n") return TagsList(appID) }
// ConfigUnset removes a config variable from an app. func ConfigUnset(appID string, configVars []string) error { c, appID, err := load(appID) if err != nil { return err } fmt.Print("Removing config... ") quit := progress() configObj := api.Config{} valuesMap := make(map[string]interface{}) for _, configVar := range configVars { valuesMap[configVar] = nil } configObj.Values = valuesMap _, err = config.Set(c, appID, configObj) quit <- true <-quit if err != nil { return err } fmt.Print("done\n\n") return ConfigList(appID, false) }
// TagsSet sets an app's tags. func TagsSet(appID string, tags []string) error { c, appID, err := load(appID) if err != nil { return err } tagsMap := parseTags(tags) fmt.Print("Applying tags... ") quit := progress() configObj := api.Config{} configObj.Tags = tagsMap _, err = config.Set(c, appID, configObj) quit <- true <-quit if err != nil { return err } fmt.Print("done\n\n") return TagsList(appID) }
// LimitsUnset removes an app's limits. func LimitsUnset(appID string, limits []string, limitType string) error { c, appID, err := load(appID) if err != nil { return err } fmt.Print("Applying limits... ") quit := progress() configObj := api.Config{} valuesMap := make(map[string]interface{}) for _, limit := range limits { valuesMap[limit] = nil } if limitType == "cpu" { configObj.CPU = valuesMap } else { configObj.Memory = valuesMap } _, err = config.Set(c, appID, configObj) quit <- true <-quit if err != nil { return err } fmt.Print("done\n\n") return LimitsList(appID) }