Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Added support for Cinder. #3
Conversation
axw
reviewed
Mar 9, 2015
| @@ -0,0 +1,1821 @@ | ||
| +package cinder |
kat-co
Mar 9, 2015
Contributor
Corrected.
Just FYI, it looks like no other files have the copyright. We might want a separate PR to correct that.
axw
reviewed
Mar 9, 2015
| + | ||
| +type TokenFn func() string | ||
| + | ||
| +func SetEndpointFn(endpoint *url.URL, wrappedHandler RequestHandlerFn) RequestHandlerFn { |
axw
Mar 9, 2015
Member
Seeing as the Host field is the only part of endpoint that is used, just pass in host?
kat-co
Mar 9, 2015
Contributor
Documentation corrected.
Regarding the endpoint parameter, I had this same debate with myself. The reason I went with URL is because I wanted a well-formed host, and URL guarantees this. I could take in a string and validate in this function, but that breaks the desired signature by returning an error (this makes it less "nice" to chain wrapper functions).
It's definitely debatable... given that new information, do you have any opinions/suggestions?
axw
reviewed
Mar 9, 2015
| + "time" | ||
| +) | ||
| + | ||
| +type TokenFn func() string |
axw
reviewed
Mar 9, 2015
| + } | ||
| +} | ||
| + | ||
| +func SetAuthHeaderFn(token TokenFn, wrappedHandler RequestHandlerFn) RequestHandlerFn { |
axw
reviewed
Mar 9, 2015
| + handleRequest RequestHandlerFn | ||
| +} | ||
| + | ||
| +// Shows information for a specified snapshot. |
axw
Mar 9, 2015
Member
These aren't auto-generated, right? Would prefer to stick with conventional "GetSnapshot ..."
kat-co
Mar 9, 2015
Contributor
No they are not. Apologies, I think I just copied the documentation from the WADL and forgot to convert to Go format.
axw
reviewed
Mar 9, 2015
| + | ||
| +type StatusResultFn func() (string, error) | ||
| + | ||
| +// VolumeStatusNotifier will check a volume's status to determine |
axw
reviewed
Mar 9, 2015
| +// "waitDur" before attempting again. If the status does not match | ||
| +// after "numAttempts", an error is returned. | ||
| +func (c *Client) StatusNotifier( | ||
| + getStatus StatusResultFn, |
axw
Mar 9, 2015
Member
I suspect the two first params would be better as a single predicate that returns (bool, error). That'll allow for alternative strategies, like waiting for the status to be in a set, or not equal to something, etc.
axw
reviewed
Mar 9, 2015
| + | ||
| +// | ||
| +// Updates a volume type. | ||
| +func updateVolumeType(request RequestHandlerFn, args UpdateVolumeTypeParams) (*UpdateVolumeTypeResults, error) { |
axw
Mar 9, 2015
Member
I wonder if these shouldn't be exported. We might periodically regenerate these, but not add exported methods on Client for every function. Then, others can make use of these auto-generated functions without having to go through the process of adding an exported method, writing tests, etc.
wallyworld
Mar 9, 2015
Owner
In my view, I'd like to refrain from exporting these at the moment. The user facing, exported functions take params divorced from the params structs used on the wire etc. I think it's good to be able to explicitly control the user facing interface.
kat-co
Mar 9, 2015
Contributor
@axw: Originally I did have these exported. I agree that it would probably be helpful to give the user flexibility in how they interact with the API.
@wallyworld: These are the same types that are utilized in the public functions, and they will always represent the information the user must specify in order to make a request. I agree that we should offer a curated experience, but I think I disagree that we should try and hide the raw calls from developers. If we make a breaking change, we can always use a version bump.
I am open to this idea. Can you give me an example of where this might be problematic to help clarify?
axw
Mar 9, 2015
Member
@katco-: If you do go ahead and export them, I think it'd be nice to have the generated and hand-written code in separate packages. Along the lines of the "gen" subpackage in https://github.com/awslabs/aws-sdk-go. Doing that would make it very clear that the functions are auto-generated, as opposed to part of a well-tested, curated set of functions.
kat-co
Mar 17, 2015
Contributor
@wallyworld and I discussed this at one point. I think it's a good idea, and the only reason I can see to keep it in the same package is that we make extensive use of the autogenerated types. I'm not sure if it makes sense to have to reference a 2nd package for that. Any opinion on that?
axw
reviewed
Mar 9, 2015
| + "strings" | ||
| +) | ||
| + | ||
| +type RequestHandlerFn func(*http.Request) (*http.Response, error) |
axw
Mar 9, 2015
Member
It'd be good to document this, and describe that the auto-generated functions will have a hard-coded URL that needs to be overridden by the RequestHandlerFn. Maybe move it out of the auto-generated file as well.
wallyworld
Mar 9, 2015
Owner
I'd like to see a bunch of doc describing the auto generation process, a link to the generation utility, where the WADL is sourced from etc.
axw
reviewed
Mar 9, 2015
| +) <-chan error { | ||
| + notifierChan := make(chan error) | ||
| + go func() { | ||
| + for attemptNum := 0; attemptNum < numAttempts; attemptNum++ { |
axw
Mar 9, 2015
Member
defer close(notifierChan) prior to the for loop
No need for the notifierChan <- nil below then.
|
Generally looking good, just a few comments. I'd like to see the code generator checked into go-goose (or a separate repo), and a |
wallyworld
reviewed
Mar 9, 2015
| @@ -146,6 +152,11 @@ func (c *client) MakeServiceURL(serviceType string, parts []string) (string, err | ||
| return makeURL(c.baseURL, parts), nil | ||
| } | ||
| +func (c *authenticatingClient) HostForRegion(region string) string { | ||
| + return "" | ||
| + //return c.regionServiceURLs[region] |
dimitern
commented
Mar 9, 2015
|
@katco- do you plan on adding a cinder test double package later to support local/live tests needed for juju, like we have for nova and others? |
|
@axw Regarding the auto-generation, and the inclusion of a go:generate directive. I'm going to look into this a bit, but one thing that immediately strikes me as problematic is referencing the external WADL files. I'm not immediately sure how to responsibly do that. Vendoring seems problematic at first glance. |
Is there a URL for the WADL file(s)? The generate command can be arbitrarily complex, so it can grab external files if necessary. I'm not sure about vendoring. go-aws does do that, from what it looks like. It may also make sense to vendor the version of the WADL files that were used to generate the source files in the repo. |
axw
reviewed
Mar 16, 2015
| @@ -0,0 +1,1704 @@ | ||
| +// Copyright 2015 Canonical Ltd. | ||
| +// Licensed under the AGPLv3, see LICENCE file for details. |
axw
Mar 16, 2015
Member
Eep. Libraries should be using LGPLv3, and the root LICENSE file confirms that.
|
With license header fix, LGTM. |
dimitern
commented
Mar 18, 2015
|
@kat-co let's try merging this with the bot! :) |
wallyworld
reviewed
Mar 24, 2015
| + err := c.client.SendRequest(client.POST, "compute", url, &requestData) | ||
| + if errors.IsNotFound(err) { | ||
| + return nil, errors.NewNotImplementedf( | ||
| + err, nil, "the server does not support availability zones", |
wallyworld
reviewed
Mar 24, 2015
| + VolumeId string `json:"volumeId"` | ||
| +} | ||
| + | ||
| +func (c *Client) AttachVolume(serverId, volumeId string) (*VolumeAttachment, error) { |
wallyworld
reviewed
Mar 24, 2015
| @@ -706,3 +707,32 @@ func (c *Client) ListAvailabilityZones() ([]AvailabilityZone, error) { | ||
| } | ||
| return resp.AvailabilityZoneInfo, nil | ||
| } | ||
| + | ||
| +func (c *Client) ListExtensions() { |
|
$$merge$$ |
|
Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-goose |
|
Build failed: Merging failed |
kat-co commentedMar 8, 2015
No description provided.