本文整理汇总了Golang中gopkg/in/juju/charmrepo/v2-unstable/csclient.Client.WithChannel方法的典型用法代码示例。如果您正苦于以下问题:Golang Client.WithChannel方法的具体用法?Golang Client.WithChannel怎么用?Golang Client.WithChannel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gopkg/in/juju/charmrepo/v2-unstable/csclient.Client
的用法示例。
在下文中一共展示了Client.WithChannel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: SetPublicWithResources
// SetPublicWithResources sets the charm or bundle with the given id to be
// published with global read permissions to the stable channel.
//
// The named resources with their associated revision
// numbers are also published.
func SetPublicWithResources(c *gc.C, client *csclient.Client, id *charm.URL, resources map[string]int) {
// Publish to the stable channel.
err := client.Publish(id, []params.Channel{params.StableChannel}, resources)
c.Assert(err, jc.ErrorIsNil)
// Allow stable read permissions to everyone.
err = client.WithChannel(params.StableChannel).Put("/"+id.Path()+"/meta/perm/read", []string{params.Everyone})
c.Assert(err, jc.ErrorIsNil)
}
示例2: UploadCharm
// UploadCharm uploads a charm using the given charm store client, and returns
// the resulting charm URL and charm.
//
// It also adds any required resources that haven't already been uploaded
// with the content "<resourcename> content".
func UploadCharm(c *gc.C, client *csclient.Client, url, name string) (*charm.URL, charm.Charm) {
id := charm.MustParseURL(url)
promulgatedRevision := -1
if id.User == "" {
// We still need a user even if we are uploading a promulgated charm.
id.User = "who"
promulgatedRevision = id.Revision
}
ch := Repo.CharmArchive(c.MkDir(), name)
// Upload the charm.
err := client.UploadCharmWithRevision(id, ch, promulgatedRevision)
c.Assert(err, jc.ErrorIsNil)
// Upload any resources required for publishing.
var resources map[string]int
if len(ch.Meta().Resources) > 0 {
// The charm has resources.
// Ensure that all the required resources are uploaded
// before we publish.
resources = make(map[string]int)
current, err := client.WithChannel(params.UnpublishedChannel).ListResources(id)
c.Assert(err, gc.IsNil)
for _, r := range current {
if r.Revision == -1 {
// The resource doesn't exist so upload one.
_, err := client.UploadResource(id, r.Name, "", strings.NewReader(r.Name+" content"))
c.Assert(err, jc.ErrorIsNil)
r.Revision = 0
}
resources[r.Name] = r.Revision
}
}
SetPublicWithResources(c, client, id, resources)
return id, ch
}