Skip to content

Commit

Permalink
mozzle: Fix space query construction
Browse files Browse the repository at this point in the history
Fixes #12.
  • Loading branch information
Bo0mer committed Jan 31, 2017
1 parent 00c793d commit 2ba1154
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,25 +315,30 @@ func (m *AppMonitor) appEventsSince(ctx context.Context, app application, t time

// getSpace returns the Space entity described by the org, space pair.
func getSpace(ctx context.Context, cc *ccv2.Client, org, space string) (ccv2.Space, error) {
orgNameQuery := ccv2.Query{
Filter: ccv2.FilterName,
Op: ccv2.OperatorEqual,
Value: org,
}
orgs, err := cc.Organizations(ctx, orgNameQuery)
orgs, err := cc.Organizations(ctx,
ccv2.Query{
Filter: ccv2.FilterName,
Op: ccv2.OperatorEqual,
Value: org,
})
if err != nil {
return ccv2.Space{}, err
}
if len(orgs) != 1 {
return ccv2.Space{}, fmt.Errorf("%q does not describe a single organization", org)
}

spaceQuery := ccv2.Query{
Filter: ccv2.FilterOrganizationGUID,
Op: ccv2.OperatorEqual,
Value: orgs[0].GUID,
}
spaces, err := cc.Spaces(ctx, spaceQuery)
spaces, err := cc.Spaces(ctx,
ccv2.Query{
Filter: ccv2.FilterOrganizationGUID,
Op: ccv2.OperatorEqual,
Value: orgs[0].GUID,
},
ccv2.Query{
Filter: ccv2.FilterName,
Op: ccv2.OperatorEqual,
Value: space,
})
if err != nil {
return ccv2.Space{}, err
}
Expand Down

0 comments on commit 2ba1154

Please sign in to comment.