// UploadCharmWithMeta pushes a new charm to the charmstore. // The uploaded charm takes the supplied charmURL with metadata.yaml and metrics.yaml // to define the charm, rather than relying on the charm to exist on disk. // This allows you to create charm definitions directly in yaml and have them uploaded // here for us in tests. // // For convenience the charm is also made public func UploadCharmWithMeta(c *gc.C, client *csclient.Client, charmURL, meta, metrics string, revision int) (*charm.URL, charm.Charm) { ch := testing.NewCharm(c, testing.CharmSpec{ Meta: meta, Metrics: metrics, Revision: revision, }) chURL, err := client.UploadCharm(charm.MustParseURL(charmURL), ch) c.Assert(err, jc.ErrorIsNil) SetPublic(c, client, chURL) return chURL, ch }
// UploadCharmMultiSeries uploads a charm with revision using the given charm store client, // and returns the resulting charm URL and charm. This API caters for new multi-series charms // which do not specify a series in the URL. func UploadCharmMultiSeries(c *gc.C, client *csclient.Client, url, name string) (*charm.URL, charm.Charm) { id := charm.MustParseURL(url) if id.User == "" { // We still need a user even if we are uploading a promulgated charm. id.User = "******" } ch := Repo.CharmArchive(c.MkDir(), name) // Upload the charm. curl, err := client.UploadCharm(id, ch) c.Assert(err, jc.ErrorIsNil) SetPublic(c, client, curl) // Return the charm and its URL. return curl, ch }
// UploadCharmMultiSeries uploads a charm with revision using the given charm store client, // and returns the resulting charm URL and charm. This API caters for new multi-series charms // which do not specify a series in the URL. func UploadCharmMultiSeries(c *gc.C, client *csclient.Client, url, name string) (*charm.URL, charm.Charm) { id := charm.MustParseURL(url) if id.User == "" { // We still need a user even if we are uploading a promulgated charm. id.User = "******" } ch := Repo.CharmArchive(c.MkDir(), name) // Upload the charm. curl, err := client.UploadCharm(id, ch) c.Assert(err, jc.ErrorIsNil) // Allow read permissions to everyone. err = client.Put("/"+curl.Path()+"/meta/perm/read", []string{params.Everyone}) c.Assert(err, jc.ErrorIsNil) // Return the charm and its URL. return curl, ch }