本文整理汇总了Golang中github.com/juju/juju/environs/simplestreams.DataSource.Priority方法的典型用法代码示例。如果您正苦于以下问题:Golang DataSource.Priority方法的具体用法?Golang DataSource.Priority怎么用?Golang DataSource.Priority使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/juju/juju/environs/simplestreams.DataSource
的用法示例。
在下文中一共展示了DataSource.Priority方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: storeImageMetadataFromFiles
// storeImageMetadataFromFiles puts image metadata found in sources into state.
func storeImageMetadataFromFiles(st *state.State, env environs.Environ, source simplestreams.DataSource) error {
// Read the image metadata, as we'll want to upload it to the environment.
imageConstraint := imagemetadata.NewImageConstraint(simplestreams.LookupParams{})
if inst, ok := env.(simplestreams.HasRegion); ok {
// If we can determine current region,
// we want only metadata specific to this region.
cloud, err := inst.Region()
if err != nil {
return err
}
imageConstraint.CloudSpec = cloud
}
existingMetadata, info, err := imagemetadata.Fetch([]simplestreams.DataSource{source}, imageConstraint)
if err != nil && !errors.IsNotFound(err) {
return errors.Annotate(err, "cannot read image metadata")
}
return storeImageMetadataInState(st, info.Source, source.Priority(), existingMetadata)
}