Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Move the GetBundleChanges call in a new Bundle facade. #6354
Conversation
| // Licensed under the AGPLv3, see LICENCE file for details. | ||
| -package client_test | ||
| +package bundle_test |
natefinch
Sep 29, 2016
Contributor
frankban
Sep 30, 2016
Member
Ok, I ended up exposing NewFacade, which feels right for other reasons as well.
| -func (s *serverSuite) TestGetBundleChangesBundleContentError(c *gc.C) { | ||
| - args := params.GetBundleChangesParams{ | ||
| +type bundleSuite struct { | ||
| + jujutesting.JujuConnSuite |
natefinch
Sep 29, 2016
•
Contributor
howbazaar
Sep 29, 2016
Owner
The StateSuite from state/testing is sufficient if you need a *state.State. See apiserver/pinger_test.go for an example.
| -// GetBundleChanges returns the list of changes required to deploy the given | ||
| -// bundle data. The changes are sorted by requirements, so that they can be | ||
| -// applied in order. | ||
| -func (c *Client) GetBundleChanges(args params.GetBundleChangesParams) (params.GetBundleChangesResults, error) { |
howbazaar
Sep 29, 2016
Owner
You can't just delete this from the client facade now. We have committed to backwards compatibility with RC1.
This means that this method needs to stay, but can forward to the new facade for implementation.
| - return params.GetBundleChangesResults{}, err | ||
| +// init registers the Bundle facade. | ||
| +func init() { | ||
| + common.RegisterStandardFacade("Bundle", 0, newFacade) |
| // Licensed under the AGPLv3, see LICENCE file for details. | ||
| -package client_test |
howbazaar
Sep 29, 2016
Owner
You will need to keep a test in the client to show that client calls still work.
| -func (s *serverSuite) TestGetBundleChangesBundleContentError(c *gc.C) { | ||
| - args := params.GetBundleChangesParams{ | ||
| +type bundleSuite struct { | ||
| + jujutesting.JujuConnSuite |
natefinch
Sep 29, 2016
•
Contributor
howbazaar
Sep 29, 2016
Owner
The StateSuite from state/testing is sufficient if you need a *state.State. See apiserver/pinger_test.go for an example.
| -// GetBundleChangesParams holds parameters for making GetBundleChanges calls. | ||
| -type GetBundleChangesParams struct { | ||
| +// BundleGetChangesParams holds parameters for making Bundle.GetChanges calls. | ||
| +type BundleGetChangesParams struct { |
howbazaar
Sep 29, 2016
Owner
Why keep the "Get" in the name? If you are changing the name anyway, probably better to remove the "Get" altogether.
BundelChangesParam, and BundleChangesResults.
While you are at it, BundleChangesChange -> BundleChange ?
| @@ -32,5 +37,5 @@ func controllerFacadesOnly(facadeName, _ string) error { | ||
| func isControllerFacade(facadeName string) bool { | ||
| // Note: the Pinger facade can be used in both model and controller |
| +} | ||
| + | ||
| +// NewFacade creates and returns a new Bundle API facade. | ||
| +func NewFacade(_ *state.State, _ facade.Resources, auth facade.Authorizer) (Bundle, error) { |
axw
Oct 3, 2016
Member
(Sorry for the somewhat conflicting advice. This is a newish thing.)
Please have the RegisterStandardFacade call an unexported function which has this signature, and have that call NewFacade. NewFacade should not mention state.State. In other facades we are creating a "Backend" interface which contains the subset of State that that facade needs. In this case you don't even need State, so you can just not include it in the NewFacade signature.
i.e. something like:
common.RegisterStandardFacade("Bundle", 1, newFacade)
...
func newFacade(_ *state.State, _ facade.Resources, auth facade.Authorizer) (Bundle, error) {
return NewFacade(auth)
}
...
func NewFacade(auth facade.Authorizer) (Bundle, error) {
...
| +) | ||
| + | ||
| +type bundleSuite struct { | ||
| + statetesting.StateSuite |
| + model, err := s.State.ControllerModel() | ||
| + c.Assert(err, jc.ErrorIsNil) | ||
| + auth := apiservertesting.FakeAuthorizer{ | ||
| + Tag: model.Owner(), |
axw
Oct 3, 2016
Member
Just set it to some fake user tag. We don't care about the relationship to the model (clearly, since you're not using State), just that it's a client making the request.
|
Thank you for the reviews! |
|
Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju |
frankban commentedSep 29, 2016
Also make the new facade available on both controller and model connections.
This is done so that GUI users can render the bundle uncommitted state even without a model connection.
Note that, even if this is a backward incompatible API change, I think we can be quite sure that the GUI is the only client of this API.