本文整理汇总了Golang中github.com/juju/juju/charmstore.CharmID.Channel方法的典型用法代码示例。如果您正苦于以下问题:Golang CharmID.Channel方法的具体用法?Golang CharmID.Channel怎么用?Golang CharmID.Channel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/juju/juju/charmstore.CharmID
的用法示例。
在下文中一共展示了CharmID.Channel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: addCharm
// addCharm interprets the new charmRef and adds the specified charm if the new charm is different
// to what's already deployed as specified by oldURL.
func (c *upgradeCharmCommand) addCharm(
oldURL *charm.URL,
charmRef string,
client *api.Client,
resolver *charmURLResolver,
) (charmstore.CharmID, *macaroon.Macaroon, error) {
var id charmstore.CharmID
// Charm may have been supplied via a path reference.
ch, newURL, err := charmrepo.NewCharmAtPathForceSeries(charmRef, oldURL.Series, c.ForceSeries)
if err == nil {
_, newName := filepath.Split(charmRef)
if newName != oldURL.Name {
return id, nil, fmt.Errorf("cannot upgrade %q to %q", oldURL.Name, newName)
}
addedURL, err := client.AddLocalCharm(newURL, ch)
id.URL = addedURL
return id, nil, err
}
if _, ok := err.(*charmrepo.NotFoundError); ok {
return id, nil, errors.Errorf("no charm found at %q", charmRef)
}
// If we get a "not exists" or invalid path error then we attempt to interpret
// the supplied charm reference as a URL below, otherwise we return the error.
if err != os.ErrNotExist && !charmrepo.IsInvalidPathError(err) {
return id, nil, err
}
// Charm has been supplied as a URL so we resolve and deploy using the store.
newURL, channel, supportedSeries, repo, err := resolver.resolve(charmRef)
if err != nil {
return id, nil, errors.Trace(err)
}
id.Channel = channel
if !c.ForceSeries && oldURL.Series != "" && newURL.Series == "" && !isSeriesSupported(oldURL.Series, supportedSeries) {
series := []string{"no series"}
if len(supportedSeries) > 0 {
series = supportedSeries
}
return id, nil, errors.Errorf(
"cannot upgrade from single series %q charm to a charm supporting %q. Use --force-series to override.",
oldURL.Series, series,
)
}
// If no explicit revision was set with either SwitchURL
// or Revision flags, discover the latest.
if *newURL == *oldURL {
newRef, _ := charm.ParseURL(charmRef)
if newRef.Revision != -1 {
return id, nil, fmt.Errorf("already running specified charm %q", newURL)
}
if newURL.Schema == "cs" {
// No point in trying to upgrade a charm store charm when
// we just determined that's the latest revision
// available.
return id, nil, fmt.Errorf("already running latest charm %q", newURL)
}
}
curl, csMac, err := addCharmFromURL(client, newURL, channel, repo)
if err != nil {
return id, nil, errors.Trace(err)
}
id.URL = curl
return id, csMac, nil
}