From 63f74b1930cb76b6dd9b0094dbf16c66ae6fb7d9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 18 Nov 2021 16:54:25 +0000 Subject: [PATCH 1/2] Bump github.com/CiscoM31/godata from 1.0.4 to 1.0.5 Bumps [github.com/CiscoM31/godata](https://github.com/CiscoM31/godata) from 1.0.4 to 1.0.5. - [Release notes](https://github.com/CiscoM31/godata/releases) - [Commits](https://github.com/CiscoM31/godata/compare/v1.0.4...v1.0.5) --- updated-dependencies: - dependency-name: github.com/CiscoM31/godata dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 8111708aea..807ad5d1fc 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/owncloud/ocis go 1.17 require ( - github.com/CiscoM31/godata v1.0.4 + github.com/CiscoM31/godata v1.0.5 github.com/GeertJohan/yubigo v0.0.0-20190917122436-175bc097e60e github.com/asim/go-micro/plugins/client/grpc/v4 v4.0.0-20211028090348-ed690ed838cc github.com/asim/go-micro/plugins/logger/zerolog/v4 v4.0.0-20211028090348-ed690ed838cc diff --git a/go.sum b/go.sum index 265e54fc3e..8c2b51ccad 100644 --- a/go.sum +++ b/go.sum @@ -72,8 +72,8 @@ github.com/Azure/go-ntlmssp v0.0.0-20200615164410-66371956d46c/go.mod h1:chxPXzS github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v0.4.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/CiscoM31/godata v1.0.4 h1:PFGyWG3lunFVnYodKaTPxgTfenDxeCci4Td1F13fOQc= -github.com/CiscoM31/godata v1.0.4/go.mod h1:Mgl+jHnqFqMT3pPD0pcahMMqI392Z8qInjrwvsbJAb4= +github.com/CiscoM31/godata v1.0.5 h1:AITXpa/5ybXEq59A0nqUGiS7ZXVJnQtFw5o09tyN/UA= +github.com/CiscoM31/godata v1.0.5/go.mod h1:wcmFm66GMdOE316TgwFO1wo5ainCvTK26omd93oZf2M= github.com/GeertJohan/yubigo v0.0.0-20190917122436-175bc097e60e h1:Bqtt5C+uVk+vH/t5dmB47uDCTwxw16EYHqvJnmY2aQc= github.com/GeertJohan/yubigo v0.0.0-20190917122436-175bc097e60e/go.mod h1:njRCDrl+1RQ/A/+KVU8Ho2EWAxUSkohOWczdW3dzDG0= github.com/HdrHistogram/hdrhistogram-go v1.1.2/go.mod h1:yDgFjdqOqDEKOvasDdhWNXYg9BVp4O+o5f6V/ehm6Oo= From 32ffbe3ac6e3d18209acc819c7a2642cc59e21df Mon Sep 17 00:00:00 2001 From: Willy Kloucek Date: Fri, 19 Nov 2021 13:17:38 +0100 Subject: [PATCH 2/2] adapt changed function signatures --- accounts/pkg/service/v0/accounts.go | 2 +- accounts/pkg/service/v0/groups.go | 2 +- graph/pkg/service/v0/drives.go | 2 +- ocis-pkg/indexer/indexer.go | 9 +++++---- ocis-pkg/indexer/indexer_test.go | 12 +++++++----- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/accounts/pkg/service/v0/accounts.go b/accounts/pkg/service/v0/accounts.go index 37979cddf3..805f06c376 100644 --- a/accounts/pkg/service/v0/accounts.go +++ b/accounts/pkg/service/v0/accounts.go @@ -276,7 +276,7 @@ func (s Service) ListAccounts(ctx context.Context, in *proto.ListAccountsRequest } func (s Service) findAccountsByQuery(ctx context.Context, query string) ([]string, error) { - return s.index.Query(&proto.Account{}, query) + return s.index.Query(ctx, &proto.Account{}, query) } // GetAccount implements the AccountsServiceHandler interface diff --git a/accounts/pkg/service/v0/groups.go b/accounts/pkg/service/v0/groups.go index e69e82dc4c..e719efefba 100644 --- a/accounts/pkg/service/v0/groups.go +++ b/accounts/pkg/service/v0/groups.go @@ -88,7 +88,7 @@ func (s Service) ListGroups(ctx context.Context, in *proto.ListGroupsRequest, ou return } func (s Service) findGroupsByQuery(ctx context.Context, query string) ([]string, error) { - return s.index.Query(&proto.Group{}, query) + return s.index.Query(ctx, &proto.Group{}, query) } // GetGroup implements the GroupsServiceHandler interface diff --git a/graph/pkg/service/v0/drives.go b/graph/pkg/service/v0/drives.go index c7f7745339..aa370cbdfd 100644 --- a/graph/pkg/service/v0/drives.go +++ b/graph/pkg/service/v0/drives.go @@ -257,7 +257,7 @@ func (g Graph) UpdateDrive(w http.ResponseWriter, r *http.Request) { //https://github.com/CiscoM31/godata/blob/d70e191d2908191623be84401fecc40d6af4afde/url_parser_test.go#L10 sanitized := strings.TrimPrefix(r.URL.Path, "/graph/v1.0/") - req, err := godata.ParseRequest(sanitized, r.URL.Query(), true) + req, err := godata.ParseRequest(r.Context(), sanitized, r.URL.Query()) if err != nil { errorcode.GeneralException.Render(w, r, http.StatusBadRequest, err.Error()) return diff --git a/ocis-pkg/indexer/indexer.go b/ocis-pkg/indexer/indexer.go index 1517734429..2a42a56f7d 100644 --- a/ocis-pkg/indexer/indexer.go +++ b/ocis-pkg/indexer/indexer.go @@ -2,6 +2,7 @@ package indexer import ( + "context" "fmt" "path" "strings" @@ -255,8 +256,8 @@ func (i *Indexer) Update(from, to interface{}) error { } // Query parses an OData query into something our indexer.Index understands and resolves it. -func (i *Indexer) Query(t interface{}, q string) ([]string, error) { - query, err := godata.ParseFilterString(q) +func (i *Indexer) Query(ctx context.Context, t interface{}, q string) ([]string, error) { + query, err := godata.ParseFilterString(ctx, q) if err != nil { return nil, err } @@ -353,7 +354,7 @@ func sanitizeInput(operands []string) (*indexerTuple, error) { // is to transform godata operators and functions into supported operations on our index. At the time of this writing // we only support `FindBy` and `FindByPartial` queries as these are the only implemented filters on indexer.Index(es). func buildTreeFromOdataQuery(root *godata.ParseNode, tree *queryTree) error { - if root.Token.Type == godata.FilterTokenFunc { // i.e "startswith", "contains" + if root.Token.Type == godata.ExpressionTokenFunc { // i.e "startswith", "contains" switch root.Token.Value { case "startswith": token := token{ @@ -372,7 +373,7 @@ func buildTreeFromOdataQuery(root *godata.ParseNode, tree *queryTree) error { } } - if root.Token.Type == godata.FilterTokenLogical { + if root.Token.Type == godata.ExpressionTokenLogical { switch root.Token.Value { case "or": tree.insert(&token{operator: root.Token.Value}) diff --git a/ocis-pkg/indexer/indexer_test.go b/ocis-pkg/indexer/indexer_test.go index baf27a5117..9cf9e74ad3 100644 --- a/ocis-pkg/indexer/indexer_test.go +++ b/ocis-pkg/indexer/indexer_test.go @@ -1,6 +1,7 @@ package indexer import ( + "context" "os" "path" "testing" @@ -255,6 +256,7 @@ func TestQueryDiskImpl(t *testing.T) { dataDir, err := WriteIndexTestData(Data, "ID", "") assert.NoError(t, err) indexer := createDiskIndexer(dataDir) + ctx := context.Background() err = indexer.AddIndex(&Account{}, "OnPremisesSamAccountName", "ID", "accounts", "non_unique", nil, false) assert.NoError(t, err) @@ -274,23 +276,23 @@ func TestQueryDiskImpl(t *testing.T) { _, err = indexer.Add(acc) assert.NoError(t, err) - r, err := indexer.Query(&Account{}, "on_premises_sam_account_name eq 'MrDootDoot'") // this query will match both pets. + r, err := indexer.Query(ctx, &Account{}, "on_premises_sam_account_name eq 'MrDootDoot'") // this query will match both pets. assert.NoError(t, err) assert.Equal(t, []string{"ba5b6e54-e29d-4b2b-8cc4-0a0b958140d2"}, r) - r, err = indexer.Query(&Account{}, "mail eq 'spooky@skeletons.org'") // this query will match both pets. + r, err = indexer.Query(ctx, &Account{}, "mail eq 'spooky@skeletons.org'") // this query will match both pets. assert.NoError(t, err) assert.Equal(t, []string{"ba5b6e54-e29d-4b2b-8cc4-0a0b958140d2"}, r) - r, err = indexer.Query(&Account{}, "on_premises_sam_account_name eq 'MrDootDoot' or mail eq 'spooky@skeletons.org'") // this query will match both pets. + r, err = indexer.Query(ctx, &Account{}, "on_premises_sam_account_name eq 'MrDootDoot' or mail eq 'spooky@skeletons.org'") // this query will match both pets. assert.NoError(t, err) assert.Equal(t, []string{"ba5b6e54-e29d-4b2b-8cc4-0a0b958140d2"}, r) - r, err = indexer.Query(&Account{}, "startswith(on_premises_sam_account_name,'MrDoo')") // this query will match both pets. + r, err = indexer.Query(ctx, &Account{}, "startswith(on_premises_sam_account_name,'MrDoo')") // this query will match both pets. assert.NoError(t, err) assert.Equal(t, []string{"ba5b6e54-e29d-4b2b-8cc4-0a0b958140d2"}, r) - r, err = indexer.Query(&Account{}, "id eq 'ba5b6e54-e29d-4b2b-8cc4-0a0b958140d2' or on_premises_sam_account_name eq 'MrDootDoot'") // this query will match both pets. + r, err = indexer.Query(ctx, &Account{}, "id eq 'ba5b6e54-e29d-4b2b-8cc4-0a0b958140d2' or on_premises_sam_account_name eq 'MrDootDoot'") // this query will match both pets. assert.NoError(t, err) assert.Equal(t, []string{"ba5b6e54-e29d-4b2b-8cc4-0a0b958140d2"}, r)