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


Golang Service.SetCharm方法代碼示例

本文整理匯總了Golang中github.com/juju/juju/state.Service.SetCharm方法的典型用法代碼示例。如果您正苦於以下問題:Golang Service.SetCharm方法的具體用法?Golang Service.SetCharm怎麽用?Golang Service.SetCharm使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/juju/juju/state.Service的用法示例。


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

示例1: serviceSetCharm

// serviceSetCharm sets the charm for the given service.
func (api *API) serviceSetCharm(service *state.Service, url string, forceSeries, forceUnits bool) error {
	curl, err := charm.ParseURL(url)
	if err != nil {
		return errors.Trace(err)
	}
	sch, err := api.state.Charm(curl)
	if err != nil {
		return errors.Trace(err)
	}
	return service.SetCharm(sch, forceSeries, forceUnits)
}
開發者ID:exekias,項目名稱:juju,代碼行數:12,代碼來源:service.go

示例2: serviceSetCharm

// serviceSetCharm sets the charm for the given service.
func (c *Client) serviceSetCharm(service *state.Service, url string, force bool) error {
	curl, err := charm.ParseURL(url)
	if err != nil {
		return err
	}
	sch, err := c.api.state.Charm(curl)
	if errors.IsNotFound(err) {
		// Charms should be added before trying to use them, with
		// AddCharm or AddLocalCharm API calls. When they're not,
		// we're reverting to 1.16 compatibility mode.
		return c.serviceSetCharm1dot16(service, curl, force)
	}
	if err != nil {
		return err
	}
	return service.SetCharm(sch, force)
}
開發者ID:,項目名稱:,代碼行數:18,代碼來源:

示例3: serviceSetCharm1dot16

// serviceSetCharm1dot16 sets the charm for the given service in 1.16
// compatibility mode. Remove this when support for 1.16 is dropped.
func (c *Client) serviceSetCharm1dot16(service *state.Service, curl *charm.URL, force bool) error {
	if curl.Schema != "cs" {
		return fmt.Errorf(`charm url has unsupported schema %q`, curl.Schema)
	}
	if curl.Revision < 0 {
		return fmt.Errorf("charm url must include revision")
	}
	err := c.AddCharm(params.CharmURL{curl.String()})
	if err != nil {
		return err
	}
	ch, err := c.api.state.Charm(curl)
	if err != nil {
		return err
	}
	return service.SetCharm(ch, force)
}
開發者ID:,項目名稱:,代碼行數:19,代碼來源:

示例4: serviceSetCharm

// serviceSetCharm sets the charm for the given service.
func (api *API) serviceSetCharm(service *state.Service, url string, channel csparams.Channel, forceSeries, forceUnits bool, resourceIDs map[string]string) error {
	curl, err := charm.ParseURL(url)
	if err != nil {
		return errors.Trace(err)
	}
	sch, err := api.state.Charm(curl)
	if err != nil {
		return errors.Trace(err)
	}
	cfg := state.SetCharmConfig{
		Charm:       sch,
		Channel:     channel,
		ForceSeries: forceSeries,
		ForceUnits:  forceUnits,
		ResourceIDs: resourceIDs,
	}
	return service.SetCharm(cfg)
}
開發者ID:makyo,項目名稱:juju,代碼行數:19,代碼來源:service.go


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