本文整理匯總了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)
}
示例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)
}
示例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)
}
示例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)
}