本文整理汇总了Golang中github.com/juju/juju/environs/simplestreams.GetMetadata函数的典型用法代码示例。如果您正苦于以下问题:Golang GetMetadata函数的具体用法?Golang GetMetadata怎么用?Golang GetMetadata使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetMetadata函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Fetch
// Fetch returns a list of images for the specified cloud matching the constraint.
// The base URL locations are as specified - the first location which has a file is the one used.
// Signed data is preferred, but if there is no signed data available and onlySigned is false,
// then unsigned data is used.
func Fetch(
sources []simplestreams.DataSource, cons *ImageConstraint,
) ([]*ImageMetadata, *simplestreams.ResolveInfo, error) {
params := simplestreams.GetMetadataParams{
StreamsVersion: currentStreamsVersion,
LookupConstraint: cons,
ValueParams: simplestreams.ValueParams{
DataType: ImageIds,
FilterFunc: appendMatchingImages,
ValueTemplate: ImageMetadata{},
},
}
items, resolveInfo, err := simplestreams.GetMetadata(sources, params)
if err != nil {
return nil, resolveInfo, err
}
metadata := make([]*ImageMetadata, len(items))
for i, md := range items {
metadata[i] = md.(*ImageMetadata)
}
// Sorting the metadata is not strictly necessary, but it ensures consistent ordering for
// all compilers, and it just makes it easier to look at the data.
Sort(metadata)
return metadata, resolveInfo, nil
}
开发者ID:bac,项目名称:juju,代码行数:30,代码来源:simplestreams.go
示例2: Fetch
// Fetch returns a list of tools for the specified cloud matching the constraint.
// The base URL locations are as specified - the first location which has a file is the one used.
// Signed data is preferred, but if there is no signed data available and onlySigned is false,
// then unsigned data is used.
func Fetch(
sources []simplestreams.DataSource, cons *ToolsConstraint,
onlySigned bool) ([]*ToolsMetadata, *simplestreams.ResolveInfo, error) {
params := simplestreams.GetMetadataParams{
StreamsVersion: currentStreamsVersion,
OnlySigned: onlySigned,
LookupConstraint: cons,
ValueParams: simplestreams.ValueParams{
DataType: ContentDownload,
FilterFunc: appendMatchingTools,
MirrorContentId: ToolsContentId(cons.Stream),
ValueTemplate: ToolsMetadata{},
PublicKey: simplestreamsToolsPublicKey,
},
}
items, resolveInfo, err := simplestreams.GetMetadata(sources, params)
if err != nil {
return nil, nil, err
}
metadata := make([]*ToolsMetadata, len(items))
for i, md := range items {
metadata[i] = md.(*ToolsMetadata)
}
// Sorting the metadata is not strictly necessary, but it ensures consistent ordering for
// all compilers, and it just makes it easier to look at the data.
Sort(metadata)
return metadata, resolveInfo, nil
}
开发者ID:snailwalker,项目名称:juju,代码行数:33,代码来源:simplestreams.go
示例3: FetchMetadata
// FetchMetadata fetches and returns Juju GUI metadata from simplestreams,
// sorted by version descending.
func FetchMetadata(stream string, sources ...simplestreams.DataSource) ([]*Metadata, error) {
params := simplestreams.GetMetadataParams{
StreamsVersion: streamsVersion,
LookupConstraint: &constraint{
LookupParams: simplestreams.LookupParams{Stream: stream},
majorVersion: jujuversion.Current.Major,
},
ValueParams: simplestreams.ValueParams{
DataType: downloadType,
MirrorContentId: contentId(stream),
FilterFunc: appendArchives,
ValueTemplate: Metadata{},
},
}
items, _, err := simplestreams.GetMetadata(sources, params)
if err != nil {
return nil, errors.Annotate(err, "error fetching simplestreams metadata")
}
allMeta := make([]*Metadata, len(items))
for i, item := range items {
allMeta[i] = item.(*Metadata)
}
sort.Sort(byVersion(allMeta))
return allMeta, nil
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:27,代码来源:simplestreams.go
示例4: TestGetMetadataNoMatching
func (s *simplestreamsSuite) TestGetMetadataNoMatching(c *gc.C) {
source := &countingSource{
DataSource: simplestreams.NewURLDataSource(
"test", "test:/daily", utils.VerifySSLHostnames,
),
}
sources := []simplestreams.DataSource{source, source, source}
constraint := sstesting.NewTestConstraint(simplestreams.LookupParams{
CloudSpec: simplestreams.CloudSpec{
Region: "us-east-1",
Endpoint: "https://ec2.us-east-1.amazonaws.com",
},
Series: []string{"precise"},
Arches: []string{"not-a-real-arch"}, // never matches
})
params := simplestreams.GetMetadataParams{
StreamsVersion: s.StreamsVersion,
LookupConstraint: constraint,
ValueParams: simplestreams.ValueParams{DataType: "image-ids"},
}
items, resolveInfo, err := simplestreams.GetMetadata(sources, params)
c.Assert(err, jc.ErrorIsNil)
c.Assert(items, gc.HasLen, 0)
c.Assert(resolveInfo, gc.DeepEquals, &simplestreams.ResolveInfo{
Source: "test",
Signed: false,
IndexURL: "test:/daily/streams/v1/index.json",
MirrorURL: "",
})
// There should be 4 calls to each data-source:
// one for .sjson, one for .json, repeated for legacy vs new index files.
c.Assert(source.count, gc.Equals, 4*len(sources))
}
开发者ID:Pankov404,项目名称:juju,代码行数:35,代码来源:simplestreams_test.go
示例5: imageMetadataFetch
func imageMetadataFetch(sources []simplestreams.DataSource, cons *imagemetadata.ImageConstraint) ([]*OvaFileMetadata, error) {
params := simplestreams.GetMetadataParams{
StreamsVersion: imagemetadata.StreamsVersionV1,
LookupConstraint: cons,
ValueParams: simplestreams.ValueParams{
DataType: "image-downloads",
FilterFunc: appendMatchingFunc,
ValueTemplate: OvaFileMetadata{},
},
}
items, _, err := simplestreams.GetMetadata(sources, params)
if err != nil {
return nil, errors.Trace(err)
}
metadata := make([]*OvaFileMetadata, len(items))
for i, md := range items {
metadata[i] = md.(*OvaFileMetadata)
}
return metadata, nil
}
开发者ID:imoapps,项目名称:juju,代码行数:20,代码来源:image_metadata.go
注:本文中的github.com/juju/juju/environs/simplestreams.GetMetadata函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论