Implement the repo.Latest method of the new charm store. #94

Merged
merged 2 commits into from Mar 18, 2015

Conversation

Projects
None yet
3 participants
Member

frankban commented Mar 17, 2015

No description provided.

charmrepo/charmstore.go
+ urls[i] = url
+ ids[i] = "id=" + url
+ }
+ path := "/meta/any?include=id-revision&include=hash256&" + strings.Join(ids, "&")
@mhilton

mhilton Mar 18, 2015

Member

Perhaps you could build this with a URL e.g.

var u url.URL
u.Path = "/meta/any"
var v url.Values
v.Add("include", "id-revision")
v.Add("include", "hash256")
for i, curl := range curls {
        url := curl.WithRevision(-1).String()
        urls[i] = url
        v.Add("id", url)
}
u.RawQuery = v.Encode()
path = u.String()

?

@rogpeppe

rogpeppe Mar 18, 2015

Owner

I had been thinking something similar.

@frankban

frankban Mar 18, 2015

Member

Nice, Done.

Member

mhilton commented Mar 18, 2015

👍 LGTM with a suggestion.

charmrepo/charmstore.go
+ path := "/meta/any?include=id-revision&include=hash256&" + strings.Join(ids, "&")
+
+ // Execute the request and retrieve results.
+ var results map[string]struct {
@rogpeppe

rogpeppe Mar 18, 2015

Owner

I think you could avoid some work here by declaring
the retrieved fields explicitly:

var results map[string] struct {
  Meta struct {
       IdRevision params.IdRevisionResponse `json:"id-revision"`
       Hash256 params.HashResponse `json:"hash256"`
  }
}

Even better would be to add a bulk meta method as a companion
to csclient.Client.Meta.

@frankban

frankban Mar 18, 2015

Member

Nice suggestion! Done.
csclient.BulkMeta is also a good idea, I'll investigate that later.

Owner

rogpeppe commented Mar 18, 2015

LGTM with one suggestion, thanks!

frankban added a commit that referenced this pull request Mar 18, 2015

Merge pull request #94 from frankban/implement-latest
Implement the repo.Latest method of the new charm store.

@frankban frankban merged commit 979541a into juju:v5-unstable Mar 18, 2015

Member

frankban commented Mar 18, 2015

Thanks for the reviews!

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