Bundle deployment base structure. #3249

Merged
merged 3 commits into from Sep 11, 2015

Conversation

Projects
None yet
3 participants
Member

frankban commented Sep 10, 2015

For now, the system just ads the charms, but local and cs bundles are
supported, and also bundles including non-public charms.

(Review request: http://reviews.vapour.ws/r/2628/)

Bundle deployment base structure.
For now, the system just ads the charms, but local and cs bundles are
supported, and also bundles including non-public charms.
Member

frankban commented Sep 10, 2015

QA:

  • juju bootstrap and environment (local is ok);
  • run juju deploy openstack-base and check the output: all the
    bundle charms should be added to the environment;
  • create a local repository with a single bundle, e.g.:
    mkdir -p /tmp/charmrepo/bundle/landwiki and then copy the contents
    of the bundle in https://pastebin.canonical.com/139340/ to
    /tmp/charmrepo/bundle/landwiki/bundle.yaml;
  • also add a readme file for a bundle, e.g.
    echo > /tmp/charmrepo/bundle/landwiki/README.md;
  • run juju deploy --repository /tmp/charmrepo local:bundle/landwiki and
    ensure you are able to authorize the bundle deployment.
cmd/juju/commands/bundle.go
+// deployBundle deploys the given bundle data using the given API client and
+// charm store client. The deployment is not transactional, and its progress is
+// notified using the given command context.
+func deployBundle(data *charm.BundleData, client *api.Client, csclient *csClient, repoPath string, conf *config.Config, ctx *cmd.Context) error {
@rogpeppe

rogpeppe Sep 10, 2015

Owner

I wonder whether it might be better to provide notifications through an interface rather than directly to a cmd.Context - that way this function is potentially usable server-side too.

cmd/juju/commands/bundle.go
+// notified using the given command context.
+func deployBundle(data *charm.BundleData, client *api.Client, csclient *csClient, repoPath string, conf *config.Config, ctx *cmd.Context) error {
+ // TODO frankban: provide a verifyConstraints function.
+ if err := data.Verify(nil); err != nil {
@rogpeppe

rogpeppe Sep 10, 2015

Owner

or just:

data.Verify(func(s string) error {
     _, err := constraints.Parse(s)
     return err
})
@frankban

frankban Sep 10, 2015

Member

Great! Done thank you!

cmd/juju/commands/common.go
@@ -112,19 +112,19 @@ func environFromNameProductionFunc(
return env, cleanup, err
}
-// resolveCharmURL resolves the given charm URL string
+// resolveEntityURL resolves the given charm or bundle URL string
@rogpeppe

rogpeppe Sep 10, 2015

Owner

There's an unfortunate conflict of naming between the charm store and juju-core. In the charm store, an "entity" refers to a charm or a bundle, but in juju-core, it refers to something with a Tag method (a unit, machine, user etc).

Although this method name would be fine in charmstore context, I suspect it will be confusing when read in the context of juju-core. I'm thinking that instead of "entity" we should use "charmOrBundle" instead. Alternatively "charmStoreEntity" might work (which has the advantage that it will still be accurate if we add another kind of thing to the charm store).

What do you think?

@frankban

frankban Sep 10, 2015

Member

I agree, this is a good point. resolveCharmStoreEntityURL seems good to me, renamed.

cmd/juju/commands/common.go
@@ -148,24 +148,24 @@ func resolveCharmURL(curlStr string, csParams charmrepo.NewCharmStoreParams, rep
// The URL is already fully resolved; do not
// bother with an unnecessary round-trip to the
// charm store.
- curl, err := ref.URL("")
+ url, err := ref.URL("")
@rogpeppe

rogpeppe Sep 10, 2015

Owner

I don't mind it called curl actually. It means that it doesn't alias with the net/url package. It's still a charm.URL (and there are other instances of the curl name in this package too).

cmd/juju/commands/common.go
if err != nil {
return nil, nil, errors.Trace(err)
}
- return curl, repo, nil
+ return url, repo, nil
}
// addCharmViaAPI calls the appropriate client API calls to add the
// given charm URL to state. For non-public charm URLs, this function also
// handles the macaroon authorization process using the given csClient.
// The resulting charm URL of the added charm is displayed on stdout.
@rogpeppe

rogpeppe Sep 10, 2015

Owner

Is this last sentence still true?

@frankban

frankban Sep 10, 2015

Member

No it isn't. Good catch!

cmd/juju/commands/deploy.go
- curl, repo, err := resolveCharmURL(c.CharmName, csClient.params, ctx.AbsPath(c.RepoPath), conf)
+
+ repoPath := ctx.AbsPath(c.RepoPath)
+ url, repo, err := resolveEntityURL(c.CharmName, csClient.params, repoPath, conf)
@rogpeppe

rogpeppe Sep 10, 2015

Owner

Again I think it's fine to keep the "curl" name.

Owner

rogpeppe commented Sep 10, 2015

Great stuff, LGTM thanks!

Member

frankban commented Sep 11, 2015

$$merge$$

Contributor

jujubot commented Sep 11, 2015

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju

Contributor

jujubot commented Sep 11, 2015

Build failed: Tests failed
build url: http://juju-ci.vapour.ws:8080/job/github-merge-juju/4685

Member

frankban commented Sep 11, 2015

$$merge$$

Contributor

jujubot commented Sep 11, 2015

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju

jujubot added a commit that referenced this pull request Sep 11, 2015

Merge pull request #3249 from frankban/deploy-bundle-base
Bundle deployment base structure.

For now, the system just ads the charms, but local and cs bundles are
supported, and also bundles including non-public charms.

(Review request: http://reviews.vapour.ws/r/2628/)

@jujubot jujubot merged commit 25596c1 into juju:guibundles Sep 11, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment