本文整理汇总了Golang中github.com/juju/juju/environs/simplestreams.LookupConstraint类的典型用法代码示例。如果您正苦于以下问题:Golang LookupConstraint类的具体用法?Golang LookupConstraint怎么用?Golang LookupConstraint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LookupConstraint类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: appendMatchingImages
// appendMatchingImages updates matchingImages with image metadata records from images which belong to the
// specified region. If an image already exists in matchingImages, it is not overwritten.
func appendMatchingImages(source simplestreams.DataSource, matchingImages []interface{},
images map[string]interface{}, cons simplestreams.LookupConstraint) ([]interface{}, error) {
imagesMap := make(map[imageKey]*ImageMetadata, len(matchingImages))
for _, val := range matchingImages {
im := val.(*ImageMetadata)
imagesMap[imageKey{im.VirtType, im.Arch, im.Version, im.RegionName, im.Storage}] = im
}
for _, val := range images {
im := val.(*ImageMetadata)
if cons != nil && cons.Params().Region != "" && cons.Params().Region != im.RegionName {
continue
}
if _, ok := imagesMap[imageKey{im.VirtType, im.Arch, im.Version, im.RegionName, im.Storage}]; !ok {
matchingImages = append(matchingImages, im)
}
}
return matchingImages, nil
}
开发者ID:bac,项目名称:juju,代码行数:21,代码来源:simplestreams.go
示例2: appendMatchingTools
// appendMatchingTools updates matchingTools with tools metadata records from tools which belong to the
// specified series. If a tools record already exists in matchingTools, it is not overwritten.
func appendMatchingTools(source simplestreams.DataSource, matchingTools []interface{},
tools map[string]interface{}, cons simplestreams.LookupConstraint) ([]interface{}, error) {
toolsMap := make(map[version.Binary]*ToolsMetadata, len(matchingTools))
for _, val := range matchingTools {
tm := val.(*ToolsMetadata)
binary, err := tm.binary()
if err != nil {
return nil, errors.Trace(err)
}
toolsMap[binary] = tm
}
for _, val := range tools {
tm := val.(*ToolsMetadata)
if !set.NewStrings(cons.Params().Series...).Contains(tm.Release) {
continue
}
if toolsConstraint, ok := cons.(*ToolsConstraint); ok {
tmNumber := version.MustParse(tm.Version)
if toolsConstraint.Version == version.Zero {
if toolsConstraint.MajorVersion >= 0 && toolsConstraint.MajorVersion != tmNumber.Major {
continue
}
if toolsConstraint.MinorVersion >= 0 && toolsConstraint.MinorVersion != tmNumber.Minor {
continue
}
} else {
if toolsConstraint.Version != tmNumber {
continue
}
}
}
binary, err := tm.binary()
if err != nil {
return nil, errors.Trace(err)
}
if _, ok := toolsMap[binary]; !ok {
tm.FullPath, _ = source.URL(tm.Path)
matchingTools = append(matchingTools, tm)
}
}
return matchingTools, nil
}
开发者ID:bac,项目名称:juju,代码行数:45,代码来源:simplestreams.go
注:本文中的github.com/juju/juju/environs/simplestreams.LookupConstraint类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论