本文整理汇总了Golang中github.com/juju/juju/environs/tools.MetadataFromTools函数的典型用法代码示例。如果您正苦于以下问题:Golang MetadataFromTools函数的具体用法?Golang MetadataFromTools怎么用?Golang MetadataFromTools使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MetadataFromTools函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestMetadataFromTools
func (*metadataHelperSuite) TestMetadataFromTools(c *gc.C) {
metadata := tools.MetadataFromTools(nil, "proposed")
c.Assert(metadata, gc.HasLen, 0)
toolsList := coretools.List{{
Version: version.MustParseBinary("1.2.3-precise-amd64"),
Size: 123,
SHA256: "abc",
}, {
Version: version.MustParseBinary("2.0.1-raring-amd64"),
URL: "file:///tmp/proposed/juju-2.0.1-raring-amd64.tgz",
Size: 456,
SHA256: "xyz",
}}
metadata = tools.MetadataFromTools(toolsList, "proposed")
c.Assert(metadata, gc.HasLen, len(toolsList))
for i, t := range toolsList {
md := metadata[i]
c.Assert(md.Release, gc.Equals, t.Version.Series)
c.Assert(md.Version, gc.Equals, t.Version.Number.String())
c.Assert(md.Arch, gc.Equals, t.Version.Arch)
// FullPath is only filled out when reading tools using simplestreams.
// It's not needed elsewhere and requires a URL() call.
c.Assert(md.FullPath, gc.Equals, "")
c.Assert(md.Path, gc.Equals, tools.StorageName(t.Version, "proposed")[len("tools/"):])
c.Assert(md.FileType, gc.Equals, "tar.gz")
c.Assert(md.Size, gc.Equals, t.Size)
c.Assert(md.SHA256, gc.Equals, t.SHA256)
}
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:30,代码来源:simplestreams_test.go
示例2: TestResolveMetadata
func (*metadataHelperSuite) TestResolveMetadata(c *gc.C) {
var versionStrings = []string{"1.2.3-precise-amd64"}
dir := c.MkDir()
toolstesting.MakeTools(c, dir, "released", versionStrings)
toolsList := coretools.List{{
Version: version.MustParseBinary(versionStrings[0]),
Size: 123,
SHA256: "abc",
}}
stor, err := filestorage.NewFileStorageReader(dir)
c.Assert(err, jc.ErrorIsNil)
err = tools.ResolveMetadata(stor, "released", nil)
c.Assert(err, jc.ErrorIsNil)
// We already have size/sha256, so ensure that storage isn't consulted.
countingStorage := &countingStorage{StorageReader: stor}
metadata := tools.MetadataFromTools(toolsList, "released")
err = tools.ResolveMetadata(countingStorage, "released", metadata)
c.Assert(err, jc.ErrorIsNil)
c.Assert(countingStorage.counter, gc.Equals, 0)
// Now clear size/sha256, and check that it is called, and
// the size/sha256 sum are updated.
metadata[0].Size = 0
metadata[0].SHA256 = ""
err = tools.ResolveMetadata(countingStorage, "released", metadata)
c.Assert(err, jc.ErrorIsNil)
c.Assert(countingStorage.counter, gc.Equals, 1)
c.Assert(metadata[0].Size, gc.Not(gc.Equals), 0)
c.Assert(metadata[0].SHA256, gc.Not(gc.Equals), "")
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:32,代码来源:simplestreams_test.go
示例3: mergeAndWriteMetadata
// This is essentially the same as tools.MergeAndWriteMetadata, but also
// resolves metadata for existing tools by fetching them and computing
// size/sha256 locally.
func mergeAndWriteMetadata(stor storage.Storage, toolsList coretools.List, writeMirrors envtools.ShouldWriteMirrors) error {
existing, err := envtools.ReadMetadata(stor)
if err != nil {
return err
}
metadata := envtools.MetadataFromTools(toolsList)
if metadata, err = envtools.MergeMetadata(metadata, existing); err != nil {
return err
}
if err = envtools.ResolveMetadata(stor, metadata); err != nil {
return err
}
return envtools.WriteMetadata(stor, metadata, writeMirrors)
}
开发者ID:kapilt,项目名称:juju,代码行数:17,代码来源:toolsmetadata.go
示例4: TestResolveMetadataLegacyPPC64
func (*metadataHelperSuite) TestResolveMetadataLegacyPPC64(c *gc.C) {
var versionStrings = []string{"1.2.3-precise-amd64", "1.2.3-precise-ppc64el"}
dir := c.MkDir()
toolstesting.MakeTools(c, dir, "released", versionStrings)
toolsList := coretools.List{
{
Version: version.MustParseBinary(versionStrings[0]),
}, {
Version: version.MustParseBinary(versionStrings[1]),
}, {
Version: version.MustParseBinary("1.2.3-precise-ppc64"),
},
}
toolsMetadata := tools.MetadataFromTools(toolsList, dir)
stor, err := filestorage.NewFileStorageReader(dir)
c.Assert(err, jc.ErrorIsNil)
err = tools.ResolveMetadata(stor, "released", toolsMetadata)
c.Assert(err, jc.ErrorIsNil)
c.Assert(toolsMetadata, gc.DeepEquals, []*tools.ToolsMetadata{
{
Release: "precise",
Version: "1.2.3",
Arch: "amd64",
Size: 19,
FileType: "tar.gz",
SHA256: "dcdd65b962b804a3d63b108d670290ee95a867a97fe9b9f99b2b77b5c7173e59",
Path: fmt.Sprintf("%s/juju-1.2.3-precise-amd64.tgz", dir),
},
{
Release: "precise",
Version: "1.2.3",
Arch: "ppc64el",
Size: 21,
FileType: "tar.gz",
SHA256: "a3460ed45eb07a69adfcd541413a495f988c5842d715c6a40353075c3ad47af2",
Path: fmt.Sprintf("%s/juju-1.2.3-precise-ppc64el.tgz", dir),
},
{
Release: "precise",
Version: "1.2.3",
Arch: "ppc64",
Size: 21,
FileType: "tar.gz",
SHA256: "a3460ed45eb07a69adfcd541413a495f988c5842d715c6a40353075c3ad47af2",
Path: fmt.Sprintf("%s/juju-1.2.3-precise-ppc64el.tgz", dir),
},
})
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:49,代码来源:simplestreams_test.go
示例5: mergeAndWriteMetadata
// This is essentially the same as tools.MergeAndWriteMetadata, but also
// resolves metadata for existing tools by fetching them and computing
// size/sha256 locally.
func mergeAndWriteMetadata(
stor storage.Storage, toolsDir, stream string, clean bool, toolsList coretools.List, writeMirrors envtools.ShouldWriteMirrors,
) error {
existing, err := envtools.ReadAllMetadata(stor)
if err != nil {
return err
}
if clean {
delete(existing, stream)
}
metadata := envtools.MetadataFromTools(toolsList, toolsDir)
var mergedMetadata []*envtools.ToolsMetadata
if mergedMetadata, err = envtools.MergeMetadata(metadata, existing[stream]); err != nil {
return err
}
if err = envtools.ResolveMetadata(stor, toolsDir, mergedMetadata); err != nil {
return err
}
existing[stream] = mergedMetadata
return envtools.WriteMetadata(stor, existing, []string{stream}, writeMirrors)
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:24,代码来源:toolsmetadata.go
注:本文中的github.com/juju/juju/environs/tools.MetadataFromTools函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论