Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1090)

Issue 43330043: api: AddLocalCharm method to upload charms via API (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 4 months ago by dimitern
Modified:
10 years, 4 months ago
Reviewers:
mp+199251, rog
Visibility:
Public.

Description

api: AddLocalCharm method to upload charms via API This introduces api.Client.AddLocalCharm that takes care of all the internals about uploading a local charm through the API server. Because charm upload needs authentication, caching of API client credentials is introduced, so after Login succeeds the client can upload charms without asking for credentials. Also introduced a NotImplementedError, which is returned by UploadCharm when the API server is detected to not support charm uploads (needed for 1.16 compatibility later on). Next, we'll use this instead of Conn.PutCharm in deploy and upgrade-charm commands. https://code.launchpad.net/~dimitern/juju-core/225-upload-charm-via-api/+merge/199251 (do not edit description out of merge proposal)

Patch Set 1 #

Total comments: 9

Patch Set 2 : api: AddLocalCharm method to upload charms via API #

Patch Set 3 : api: AddLocalCharm method to upload charms via API #

Unified diffs Side-by-side diffs Delta from patch set Stats (+204 lines, -12 lines) Patch
A [revision details] View 1 2 1 chunk +2 lines, -0 lines 0 comments Download
M state/api/apiclient.go View 1 2 2 chunks +12 lines, -2 lines 0 comments Download
M state/api/client.go View 1 2 2 chunks +114 lines, -0 lines 0 comments Download
M state/api/client_test.go View 1 2 2 chunks +55 lines, -0 lines 0 comments Download
A state/api/export_test.go View 1 2 1 chunk +10 lines, -0 lines 0 comments Download
M state/api/params/internal.go View 1 chunk +6 lines, -0 lines 0 comments Download
M state/apiserver/charms.go View 4 chunks +3 lines, -9 lines 0 comments Download
M state/apiserver/charms_test.go View 2 chunks +2 lines, -1 line 0 comments Download

Messages

Total messages: 6
dimitern
Please take a look.
10 years, 4 months ago (2013-12-17 10:08:15 UTC) #1
rog
LGTM modulo the below. Thanks! https://codereview.appspot.com/43330043/diff/1/state/api/apiclient.go File state/api/apiclient.go (right): https://codereview.appspot.com/43330043/diff/1/state/api/apiclient.go#newcode39 state/api/apiclient.go:39: // address holds the ...
10 years, 4 months ago (2013-12-17 12:21:31 UTC) #2
rog
https://codereview.appspot.com/43330043/diff/1/state/api/client.go File state/api/client.go (right): https://codereview.appspot.com/43330043/diff/1/state/api/client.go#newcode420 state/api/client.go:420: resp, err := utils.GetNonValidatingHTTPClient().Do(req) This seems wrong to me. ...
10 years, 4 months ago (2013-12-17 13:23:14 UTC) #3
dimitern
Please take a look. https://codereview.appspot.com/43330043/diff/1/state/api/apiclient.go File state/api/apiclient.go (right): https://codereview.appspot.com/43330043/diff/1/state/api/apiclient.go#newcode39 state/api/apiclient.go:39: // address holds the cached ...
10 years, 4 months ago (2013-12-17 15:20:09 UTC) #4
dimitern
Please take a look.
10 years, 4 months ago (2013-12-17 15:31:58 UTC) #5
rog
10 years, 4 months ago (2013-12-17 16:00:49 UTC) #6
Message was sent while issue was closed.
https://codereview.appspot.com/43330043/diff/1/state/api/client.go
File state/api/client.go (right):

https://codereview.appspot.com/43330043/diff/1/state/api/client.go#newcode362
state/api/client.go:362: type NotImplementedError struct {
On 2013/12/17 15:20:10, dimitern wrote:
> On 2013/12/17 12:21:32, rog wrote:
> > I think we should probably be consistent with the rest of the API error
> handling
> > here and use an error code.
> 
> Done.

Sorry, that wasn't quite what I had in mind.
api clients are currently using rpc.IsNoSuchRequest
to determine whether an api call is unimplemented.

I think it would be good if all api calls returned
the same kind of error when they're unimplemented,
otherwise we've got two ways of finding out if something
is unimplemented depending on the underlying implementation.

I can see at least two possibilities for doing that:

1)
return &rpc.RequestError{Message: `no such request "POST /charms"`}

2)
rpc.CodeNoSuchRequest = "no such request"
params.CodeNotImplemented = rpc.CodeNoSuchRequest
params.IsNotImplemented = errorcode == params.CodeNotImplemented

make the rpc package return error code CodeNoSuchRequest on method-not-defined
error (it'll need to do the prefix test too for compatibility)
change the various callers of rpc.IsNoSuchRequest to call
params.IsNotImplemented.

Obviously 1) is least effort, but has a slight ickiness factor to
it because we're not actually making an rpc request.

However I suggest we go with that for the time being and file a bug to change
things later - api clients should probably not be relying on
rpc-defined functions.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b