當前位置: 首頁>>代碼示例>>Golang>>正文


Golang api.Config類代碼示例

本文整理匯總了Golang中github.com/deis/deis/client/controller/api.Config的典型用法代碼示例。如果您正苦於以下問題:Golang Config類的具體用法?Golang Config怎麽用?Golang Config使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Config類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: LimitsSet

// 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)
}
開發者ID:CodeJuan,項目名稱:deis,代碼行數:34,代碼來源:limits.go

示例2: TagsSet

// 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)
}
開發者ID:ngpestelos,項目名稱:deis,代碼行數:29,代碼來源:tags.go

示例3: TagsUnset

// 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)
}
開發者ID:ngpestelos,項目名稱:deis,代碼行數:35,代碼來源:tags.go

示例4: ConfigUnset

// 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)
}
開發者ID:ngpestelos,項目名稱:deis,代碼行數:35,代碼來源:config.go

示例5: LimitsUnset

// 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)
}
開發者ID:CodeJuan,項目名稱:deis,代碼行數:39,代碼來源:limits.go


注:本文中的github.com/deis/deis/client/controller/api.Config類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。