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