Stub out the meta endpoint for resources. #563

Closed
wants to merge 14 commits into
from

Conversation

Projects
None yet
5 participants
Contributor

ericsnowcurrently commented Mar 7, 2016

The full implementation of the resources endpoints will be added later, after channels land.

Member

jujugui commented Mar 7, 2016

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
http://ci.jujugui.org:8080//job/charmstore/1610/
Test FAILed.

Member

jujugui commented Mar 7, 2016

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
http://ci.jujugui.org:8080//job/charmstore/1611/
Test FAILed.

Contributor

ericsnowcurrently commented Mar 7, 2016

Note that the test failure is due to a pending dep change: juju/charmrepo#67.

Member

jujugui commented Mar 7, 2016

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
http://ci.jujugui.org:8080//job/charmstore/1612/
Test FAILed.

+ description: get things started
+ for-upload:
+ Type: file
+ filename: config.xml
internal/v5/resources.go
+
+ var resources []resource.Resource
+ for _, meta := range entity.CharmMeta.Resources {
+ // We use an origin of "upload" since charms cannot be uploaded yet.
@natefinch

natefinch Mar 8, 2016

s/charms/resources/

dependencies.tsv
gopkg.in/juju/charmrepo.v2-unstable git f03e1b601c98ff4a97baeedac856a7a030e021f4 2016-01-11T16:59:27Z
-gopkg.in/juju/jujusvg.v1 git a60359df348ef2ca40ec3bcd58a01de54f05658e 2016-02-11T20:24:49Z
+gopkg.in/juju/jujusvg.v1 git a60359df348ef2ca40ec3bcd58a01de54f05658e 2016-02-11T10:02:50Z
@natefinch

natefinch Mar 8, 2016

this appears to be moving this repo to an earlier revision... that seems wrong.

@mhilton

mhilton Mar 8, 2016

Member

don't worry about this it seems to be an anomaly in godeps.

@ericsnowcurrently

ericsnowcurrently Mar 8, 2016

Contributor

Same revision but using a newer version of godeps. :)

LGTM aside from some small things.

internal/v5/api.go
@@ -235,6 +235,7 @@ func RouterHandlers(h *ReqHandler) *router.Handlers {
"perm": h.puttableBaseEntityHandler(h.metaPerm, h.putMetaPerm, "acls", "developmentacls"),
"perm/": h.puttableBaseEntityHandler(h.metaPermWithKey, h.putMetaPermWithKey, "acls", "developmentacls"),
"promulgated": h.baseEntityHandler(h.metaPromulgated, "promulgated"),
+ "resources": h.EntityHandler(h.metaResources, "_id", "charmmeta"),
@mhilton

mhilton Mar 8, 2016

Member

There is no need for "_id" in the list here.

@ericsnowcurrently

ericsnowcurrently Mar 8, 2016

Contributor

We use Entity.URL (which is _id in the doc). Do you mean that's always filled in? I noticed that most of the other handlers require _id.

@ericsnowcurrently

ericsnowcurrently Mar 8, 2016

Contributor

This line is strictly for meta-get. The doc comment below relates to the non-meta endpoint (which incidentally does not actually handle PUT).

@frankban

frankban Mar 9, 2016

Member

IIRC _id is only strictly required when no other fields are required, so that not all fields are retrieved.

@@ -1357,6 +1346,11 @@ func (h *ReqHandler) servePublish(id *charm.URL, w http.ResponseWriter, req *htt
return errgo.Mask(err, errgo.Any)
}
+ // TODO(ericsnow) Actually handle the resources.
+ if len(publish.Resources) > 0 {
@mhilton

mhilton Mar 8, 2016

Member

You'll probably find this one is very different in the new model.

@ericsnowcurrently

ericsnowcurrently Mar 8, 2016

Contributor

Ooh. Looking forward to it!

Member

jujugui commented Mar 8, 2016

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
http://ci.jujugui.org:8080//job/charmstore/1614/
Test FAILed.

+ switch req.Method {
+ case "GET":
+ return h.serveDownloadResource(id, w, req)
+ case "POST":
@mhilton

mhilton Mar 8, 2016

Member

meta endpoints currently don't allow POST. You might have to look at the how the router works to enable it.

@ericsnowcurrently

ericsnowcurrently Mar 8, 2016

Contributor

This is not the meta endpoint.

@mhilton

mhilton Mar 8, 2016

Member

Sorry that would be my misreading.

internal/v5/api_test.go
+ exclusive: charmOnly,
+ checkURL: newResolvedURL("cs:~charmers/utopic/starsay-17", 17),
+ assertCheckData: func(c *gc.C, data interface{}) {
+ //resources := data.([]params.Resource)
@frankban

frankban Mar 9, 2016

Member

Leftovers?

internal/v5/resources.go
+
+func basicListResources(entity *mongodoc.Entity) ([]resource.Resource, error) {
+ if entity.URL.Series == "bundle" {
+ return nil, errgo.Newf("bundles do not have resources")
@frankban

frankban Mar 9, 2016

Member

This should not really be an internal server error.

Member

frankban commented Mar 9, 2016

👍 with some comments, thank you!

Member

jujugui commented Mar 9, 2016

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
http://ci.jujugui.org:8080//job/charmstore/1624/
Test FAILed.

Contributor

ericsnowcurrently commented Mar 9, 2016

Re-submitting against the new-channels-model branch.

jujugui added a commit that referenced this pull request Mar 9, 2016

Merge pull request #566 from ericsnowcurrently/resources-endpoint-stubs
Stub out the meta endpoint for resources.

The full implementation of the resources endpoints will be added later, after channels land.

(already reviewed in #563)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment