本文整理汇总了Golang中github.com/juju/juju/api.Client.ResolveCharm方法的典型用法代码示例。如果您正苦于以下问题:Golang Client.ResolveCharm方法的具体用法?Golang Client.ResolveCharm怎么用?Golang Client.ResolveCharm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/juju/juju/api.Client
的用法示例。
在下文中一共展示了Client.ResolveCharm方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: resolveCharmURL
// resolveCharmURL returns a resolved charm URL, given a charm location string.
// If the series is not resolved, the environment default-series is used, or if
// not set, the series is resolved with the state server.
func resolveCharmURL(url string, client *api.Client, conf *config.Config) (*charm.URL, error) {
ref, err := charm.ParseReference(url)
if err != nil {
return nil, err
}
// If series is not set, use configured default series
if ref.Series == "" {
if defaultSeries, ok := conf.DefaultSeries(); ok {
ref.Series = defaultSeries
}
}
if ref.Series != "" {
return ref.URL("")
}
// Otherwise, look up the best supported series for this charm
if ref.Schema != "local" {
return client.ResolveCharm(ref)
}
possibleURL := *ref
possibleURL.Series = "precise"
logger.Errorf("The series is not specified in the environment (default-series) or with the charm. Did you mean:\n\t%s", &possibleURL)
return nil, fmt.Errorf("cannot resolve series for charm: %q", ref)
}