Add permisisons to crossmodel facade apis #7130

Merged
merged 1 commit into from Mar 21, 2017

Conversation

Projects
None yet
3 participants
Owner

wallyworld commented Mar 21, 2017

Please provide the following details to expedite Pull Request review:


Description of change

The crossmodel facade has permission checks added so that:
offer -> admin access
list -> admin access
show -> read access
find -> read access

Also fix a bug in state where an error adding an offer would create part of the offer and fail the next time.
And improve the offer command by printing info after it runs.

QA steps

create CMR offers, list, show, find etc

axw approved these changes Mar 21, 2017

apiserver/crossmodel/crossmodel.go
@@ -239,7 +261,7 @@ func makeOfferParamsFromOffer(offer jujucrossmodel.ApplicationOffer) params.Appl
// FindApplicationOffers gets details about remote applications that match given filter.
func (api *API) FindApplicationOffers(filters params.OfferFilters) (params.FindApplicationOffersResults, error) {
var result params.FindApplicationOffersResults
- offers, err := api.getApplicationOffersDetails(filters)
+ offers, err := api.getApplicationOffersDetails(filters, permission.ReadAccess)
@axw

axw Mar 21, 2017

Member

seems weird that Find and List have different perms. can you please leave a comment why. I assume it's because the details of offers, only returned by List, are sensitive.

(it also seems weird that List returns details, and Find doesn't...)

@wallyworld

wallyworld Mar 21, 2017

Owner

Add comments. Also, next PR will move Find and Show to a separate controller facade.

cmd/juju/crossmodel/offer.go
@@ -102,7 +106,17 @@ func (c *offerCommand) Run(_ *cmd.Context) error {
if err != nil {
return err
}
- return params.ErrorResults{results}.Combine()
+ err = params.ErrorResults{results}.Combine()
+ if err == nil {
@axw

axw Mar 21, 2017

Member

this feels too clever, can you please just do

if err := params.ErrorResults{results}.Combine(); err != nil {
    return err
}

that way you're keepin the return err close to where it was checked, and it doesn't risk getting messed up

cmd/juju/crossmodel/offer.go
+ }
+ url := jujucrossmodel.MakeURL(owner.Name(), unqualifiedModelName, c.OfferName, "")
+ ep := strings.Join(c.Endpoints, ", ")
+ ctx.Infof("Application %q endpoints [%s] availble at %q", c.Application, ep, url)
@axw

axw Mar 21, 2017

Member

typo

Owner

wallyworld commented Mar 21, 2017

$$merge$$

Contributor

jujubot commented Mar 21, 2017

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju

Contributor

jujubot commented Mar 21, 2017

Build failed: Tests failed
build url: http://juju-ci.vapour.ws:8080/job/github-merge-juju/10507

Owner

wallyworld commented Mar 21, 2017

$$merge$$

Contributor

jujubot commented Mar 21, 2017

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju

@jujubot jujubot merged commit 961a482 into juju:develop Mar 21, 2017

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