From 2ba11541238d235b1f742cb70f81335916cfda3c Mon Sep 17 00:00:00 2001 From: Ivan Borshukov Date: Wed, 1 Feb 2017 00:39:51 +0200 Subject: [PATCH] mozzle: Fix space query construction Fixes https://github.com/Bo0mer/mozzle/issues/12. --- monitor.go | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/monitor.go b/monitor.go index 78eda7a..746b0bf 100644 --- a/monitor.go +++ b/monitor.go @@ -315,12 +315,12 @@ 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 } @@ -328,12 +328,17 @@ func getSpace(ctx context.Context, cc *ccv2.Client, org, space string) (ccv2.Spa 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 }