Add an API data type for resources. #68

Merged
merged 9 commits into from Mar 9, 2016

Conversation

Projects
None yet
5 participants
Contributor

ericsnowcurrently commented Mar 7, 2016

This provides a stable over-the-wire format that maps onto the charm/resource.Resource type.

Member

jujugui commented Mar 7, 2016

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

+ // Size is the size of the resource, in bytes.
+ Size int64
+}
+
const (
@natefinch

natefinch Mar 8, 2016

Contributor

They explicitly don't lowercase the json in this package... we should follow suit. (also, IMO, it's better not to anyway).

+)
+
+// Resource2API converts a charm resource into an API Resource struct.
+func Resource2API(res resource.Resource) Resource {
@natefinch

natefinch Mar 8, 2016

Contributor

I'm not convinced this is the right package for the conversion helper. I think it's more appropriate in csclient or even the root charmrepo package. I think the whole point is for the params package to only know or care about API params.

@natefinch

natefinch Mar 8, 2016

Contributor

I take it back... given that we need a helper for both sides of the API... I guess it has to be here. Kinda wish it could live somewhere else and just import params... but I don't think it's worth creating a new package at this time.

@mhilton

mhilton Mar 9, 2016

Member

It'd be nice is a resource.Resource was just marshalable without the need for conversion. I assume there are solid reasons why it isn't though.

Member

jujugui commented Mar 8, 2016

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

Contributor

natefinch commented Mar 8, 2016

LGTM

csclient/params/helpers.go
+
+ rtype, err := resource.ParseType(apiInfo.Type)
+ if err != nil {
+ return res, err
@frankban

frankban Mar 9, 2016

Member

Use errgo to track errors in this function?

+ err = expected.Validate()
+ c.Assert(err, jc.ErrorIsNil)
+
+ c.Check(res, jc.DeepEquals, expected)
@frankban

frankban Mar 9, 2016

Member

What about testing the error cases, invalid type and origin?
Also a test for the case when the fingerprint is empty?

Member

frankban commented Mar 9, 2016

👍 with a couple of minor requests.

csclient/params/helpers.go
+ if len(fpSum) == 0 {
+ return resource.Fingerprint{}, nil
+ }
+ return resource.NewFingerprint(fpSum)
@mhilton

mhilton Mar 9, 2016

Member

I generally associate New with creating a pointer to a thing. This one produces a thing, I expect there is a more common go idiom for this, but I can't think of it right now.

Member

mhilton commented Mar 9, 2016

👍 when @frankban's concerns are addressed

Member

jujugui commented Mar 9, 2016

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

Member

jujugui commented Mar 9, 2016

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

Contributor

ericsnowcurrently commented Mar 9, 2016

:shipit:

Member

jujugui commented Mar 9, 2016

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

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

Merge pull request #68 from ericsnowcurrently/resources-resource-api-…
…type

Add an API data type for resources.

This provides a stable over-the-wire format that maps onto the charm/resource.Resource type.

@jujugui jujugui merged commit e6b798e into juju:v2-unstable Mar 9, 2016

1 check passed

default Merged build finished.
Details

@ericsnowcurrently ericsnowcurrently deleted the ericsnowcurrently:resources-resource-api-type branch Mar 9, 2016

@ericsnowcurrently ericsnowcurrently restored the ericsnowcurrently:resources-resource-api-type branch Mar 9, 2016

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

Merge pull request #69 from ericsnowcurrently/resources-resource-api-…
…type

Add an API data type for resources.

This provides a stable over-the-wire format that maps onto the charm/resource.Resource type.

(already reviewed in #68)

@ericsnowcurrently ericsnowcurrently deleted the ericsnowcurrently:resources-resource-api-type branch Mar 9, 2016

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