本文整理汇总了Golang中launchpad/net/juju-core/version.Binary.String方法的典型用法代码示例。如果您正苦于以下问题:Golang Binary.String方法的具体用法?Golang Binary.String怎么用?Golang Binary.String使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类launchpad/net/juju-core/version.Binary
的用法示例。
在下文中一共展示了Binary.String方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: putBinary
// putBinary stores a faked binary in the test directory.
func putBinary(c *gc.C, storagePath string, v version.Binary) {
data := v.String()
name := tools.StorageName(v)
filename := filepath.Join(storagePath, name)
dir := filepath.Dir(filename)
err := os.MkdirAll(dir, 0755)
c.Assert(err, gc.IsNil)
err = ioutil.WriteFile(filename, []byte(data), 0666)
c.Assert(err, gc.IsNil)
}
示例2: uploadTools
func (s *agentSuite) uploadTools(c *C, vers version.Binary) *tools.Tools {
tgz := coretesting.TarGz(
coretesting.NewTarFile("jujud", 0777, "jujud contents "+vers.String()),
)
storage := s.Conn.Environ.Storage()
err := storage.Put(tools.StorageName(vers), bytes.NewReader(tgz), int64(len(tgz)))
c.Assert(err, IsNil)
url, err := s.Conn.Environ.Storage().URL(tools.StorageName(vers))
c.Assert(err, IsNil)
return &tools.Tools{URL: url, Binary: vers}
}
示例3: uploadFakeToolsVersion
func uploadFakeToolsVersion(storage environs.Storage, vers version.Binary) (*state.Tools, error) {
data := vers.String()
name := tools.StorageName(vers)
log.Noticef("environs/testing: uploading FAKE tools %s", vers)
if err := storage.Put(name, strings.NewReader(data), int64(len(data))); err != nil {
return nil, err
}
url, err := storage.URL(name)
if err != nil {
return nil, err
}
return &state.Tools{Binary: vers, URL: url}, nil
}
示例4: uploadTools
// uploadTools uploads fake tools with the given version number
// to the dummy environment's storage and returns a tools
// value describing them.
func (s *UpgraderSuite) uploadTools(c *gc.C, vers version.Binary) *tools.Tools {
// TODO(rog) make UploadFakeToolsVersion in environs/testing
// sufficient for this use case.
tgz := coretesting.TarGz(
coretesting.NewTarFile("jujud", 0777, "jujud contents "+vers.String()),
)
storage := s.Conn.Environ.Storage()
err := storage.Put(tools.StorageName(vers), bytes.NewReader(tgz), int64(len(tgz)))
c.Assert(err, gc.IsNil)
url, err := s.Conn.Environ.Storage().URL(tools.StorageName(vers))
c.Assert(err, gc.IsNil)
return &tools.Tools{URL: url, Version: vers}
}
示例5: PutBinary
// PutBinary stores a faked binary in the HTTP test storage.
func (s *EC2HTTPTestStorage) PutBinary(v version.Binary) {
data := v.String()
name := tools.StorageName(v)
parts := strings.Split(name, "/")
if len(parts) > 1 {
// Also create paths as entries. Needed for
// the correct contents of the list bucket result.
path := ""
for i := 0; i < len(parts)-1; i++ {
path = path + parts[i] + "/"
s.files[path] = []byte{}
}
}
s.files[name] = []byte(data)
}
示例6: SharedToolsDir
// SharedToolsDir returns the directory that is used to
// store binaries for the given version of the juju tools
// within the dataDir directory.
func SharedToolsDir(dataDir string, vers version.Binary) string {
return path.Join(dataDir, "tools", vers.String())
}
示例7: ToolsStoragePath
// ToolsStoragePath returns the path that is used to store and
// retrieve the given version of the juju tools in a Storage.
func ToolsStoragePath(vers version.Binary) string {
return toolPrefix + vers.String() + ".tgz"
}
示例8: StorageName
// StorageName returns the name that is used to store and retrieve the
// given version of the juju tools.
func StorageName(vers version.Binary) string {
return toolPrefix + vers.String() + toolSuffix
}