Exemplo n.º 1
0
// 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)
}
Exemplo n.º 2
0
// 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)
}
Exemplo n.º 3
0
// 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)
}
Exemplo n.º 4
0
// 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)
}
Exemplo n.º 5
0
// 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)
}