Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bundle validation: verify with charms. #70

Merged
merged 8 commits into from Aug 13, 2014

Conversation

frankban
Copy link
Member

Validate the bundle with respect to charms in the store.

@jujugui
Copy link
Contributor

jujugui commented Aug 13, 2014

Test PASSed.
Refer to this link for build results: http://ci.jujugui.org:8080/job/charmstore/107/

}
return nil, err
}
r, size, err := h.openBlob(url)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's necessary to open the blob. All the information is available in the
Entity document. I'd define a type, say entityCharm, which implements the
methods required by the charm.Charm interface.

e.g.
type entityCharm mongodoc.Entity
func (e *entityCharm) Meta() *charm.Meta {
return e.CharmMeta
}
... etc

Then you can just retrieve all the entities from the entities collection with the
appropriate ids (entities.Find(bson.D{{"_id", bson.D{{"$in", ids}}}}).All(&found)
might work ok) put them into a map and return them as is.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@rogpeppe
Copy link
Contributor

Excellent direction, thanks, but with some suggested simplifications above.

@jujugui
Copy link
Contributor

jujugui commented Aug 13, 2014

Test PASSed.
Refer to this link for build results: http://ci.jujugui.org:8080/job/charmstore/108/

@jujugui
Copy link
Contributor

jujugui commented Aug 13, 2014

Test PASSed.
Refer to this link for build results: http://ci.jujugui.org:8080/job/charmstore/109/

func (h *handler) bundleCharms(ids []string) (map[string]charm.Charm, error) {
urls := make([]*charm.Reference, len(ids))
urlIdmap := make(map[charm.Reference]string, len(ids))
for i, id := range ids {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// TODO resolve ids concurrently

?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@jujugui
Copy link
Contributor

jujugui commented Aug 13, 2014

Test PASSed.
Refer to this link for build results: http://ci.jujugui.org:8080/job/charmstore/110/

@jujugui
Copy link
Contributor

jujugui commented Aug 13, 2014

Test PASSed.
Refer to this link for build results: http://ci.jujugui.org:8080/job/charmstore/111/

}

func (h *handler) bundleCharms(ids []string) (map[string]charm.Charm, error) {
urls := make([]*charm.Reference, len(ids))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem quite right. If URL resolving fails, we can be left
with empty slots here.

I'd suggest:
urls := make([]*charm.Reference, 0, len(ids))

and then append to urls after parsing each one.

It would be good to have some better test coverage in this area. Perhaps
a unit test of bundleCharms itself?

@rogpeppe
Copy link
Contributor

Nicer, thanks. A few further suggestions above.

@jrwren
Copy link
Contributor

jrwren commented Aug 13, 2014

👍

@jujugui
Copy link
Contributor

jujugui commented Aug 13, 2014

Test PASSed.
Refer to this link for build results: http://ci.jujugui.org:8080/job/charmstore/112/

@jujugui
Copy link
Contributor

jujugui commented Aug 13, 2014

Test PASSed.
Refer to this link for build results: http://ci.jujugui.org:8080/job/charmstore/113/

@@ -208,3 +214,82 @@ func (h *handler) openBlob(id *charm.Reference) (blobstore.ReadSeekCloser, int64
}
return r, size, nil
}

// entityCharm implements charm.Charm.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps move this (and the methods) after bundleCharms?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@rogpeppe
Copy link
Contributor

LGTM with a few minor suggestions, thanks!

@jujugui
Copy link
Contributor

jujugui commented Aug 13, 2014

Test PASSed.
Refer to this link for build results: http://ci.jujugui.org:8080/job/charmstore/114/

@frankban
Copy link
Member Author

:shipit: thank you for the great reviews!

@jujugui
Copy link
Contributor

jujugui commented Aug 13, 2014

Status: merge request accepted. Url: http://ci.jujugui.org:8080/job/charmstore-merge

jujugui added a commit that referenced this pull request Aug 13, 2014
Bundle validation: verify with charms.

Validate the bundle with respect to charms in the store.
@jujugui jujugui merged commit 3f74576 into juju:v4 Aug 13, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants