本文整理汇总了Golang中github.com/juju/juju/environs/simplestreams.MetadataLookupParams.Architectures方法的典型用法代码示例。如果您正苦于以下问题:Golang MetadataLookupParams.Architectures方法的具体用法?Golang MetadataLookupParams.Architectures怎么用?Golang MetadataLookupParams.Architectures使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/juju/juju/environs/simplestreams.MetadataLookupParams
的用法示例。
在下文中一共展示了MetadataLookupParams.Architectures方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Run
func (c *validateToolsMetadataCommand) Run(context *cmd.Context) error {
var params *simplestreams.MetadataLookupParams
if c.providerType == "" {
environ, err := c.prepare(context)
if err == nil {
mdLookup, ok := environ.(simplestreams.MetadataValidator)
if !ok {
return errors.Errorf("%s provider does not support tools metadata validation", environ.Config().Type())
}
params, err = mdLookup.MetadataLookupParams(c.region)
if err != nil {
return err
}
params.Sources, err = tools.GetMetadataSources(environ)
if err != nil {
return err
}
} else {
if c.metadataDir == "" {
return err
}
params = &simplestreams.MetadataLookupParams{}
}
} else {
prov, err := environs.Provider(c.providerType)
if err != nil {
return err
}
mdLookup, ok := prov.(simplestreams.MetadataValidator)
if !ok {
return errors.Errorf("%s provider does not support tools metadata validation", c.providerType)
}
params, err = mdLookup.MetadataLookupParams(c.region)
if err != nil {
return err
}
}
if len(params.Architectures) == 0 {
params.Architectures = arch.AllSupportedArches
}
if c.series != "" {
params.Series = c.series
}
if c.region != "" {
params.Region = c.region
}
if c.endpoint != "" {
params.Endpoint = c.endpoint
}
if c.metadataDir != "" {
if _, err := os.Stat(c.metadataDir); err != nil {
return err
}
toolsURL, err := tools.ToolsURL(c.metadataDir)
if err != nil {
return err
}
params.Sources = toolsDataSources(toolsURL)
}
params.Stream = c.stream
versions, resolveInfo, err := tools.ValidateToolsMetadata(&tools.ToolsMetadataLookupParams{
MetadataLookupParams: *params,
Version: c.exactVersion,
Major: c.major,
Minor: c.minor,
})
if err != nil {
if resolveInfo != nil {
metadata := map[string]interface{}{
"Resolve Metadata": *resolveInfo,
}
buff := &bytes.Buffer{}
if yamlErr := cmd.FormatYaml(buff, metadata); yamlErr == nil {
err = errors.Errorf("%v\n%v", err, buff.String())
}
}
return err
}
if len(versions) > 0 {
metadata := map[string]interface{}{
"Matching Tools Versions": versions,
"Resolve Metadata": *resolveInfo,
}
c.out.Write(context, metadata)
} else {
var sources []string
for _, s := range params.Sources {
url, err := s.URL("")
if err == nil {
sources = append(sources, fmt.Sprintf("- %s (%s)", s.Description(), url))
}
}
return errors.Errorf("no matching tools using sources:\n%s", strings.Join(sources, "\n"))
}
return nil
//.........这里部分代码省略.........