From 7a819412c272060f5342a135c2c7dca2aea3a6c9 Mon Sep 17 00:00:00 2001 From: jkoberg Date: Wed, 19 Jun 2024 12:01:02 +0200 Subject: [PATCH] feat(ocis): move ast and kql pkg to ocis-pkg Signed-off-by: jkoberg --- {services/search/pkg/query => ocis-pkg}/ast/ast.go | 0 {services/search/pkg/query => ocis-pkg}/ast/test/test.go | 3 +-- {services/search/pkg/query => ocis-pkg}/kql/cast.go | 3 +-- {services/search/pkg/query => ocis-pkg}/kql/connect.go | 2 +- .../search/pkg/query => ocis-pkg}/kql/dictionary.peg | 0 .../search/pkg/query => ocis-pkg}/kql/dictionary_gen.go | 0 .../search/pkg/query => ocis-pkg}/kql/dictionary_test.go | 7 +++---- {services/search/pkg/query => ocis-pkg}/kql/doc.go | 0 .../pkg/query => ocis-pkg}/kql/engine_suite_test.go | 0 {services/search/pkg/query => ocis-pkg}/kql/factory.go | 2 +- {services/search/pkg/query => ocis-pkg}/kql/gen.go | 0 {services/search/pkg/query => ocis-pkg}/kql/kql.go | 2 +- {services/search/pkg/query => ocis-pkg}/kql/kql_test.go | 5 ++--- {services/search/pkg/query => ocis-pkg}/kql/validate.go | 2 +- services/activitylog/Makefile | 2 +- services/activitylog/pkg/config/log.go | 8 ++++---- services/activitylog/pkg/service/http.go | 4 ++-- services/search/Makefile | 2 +- services/search/pkg/query/bleve/bleve.go | 2 +- services/search/pkg/query/bleve/compiler.go | 4 ++-- services/search/pkg/query/bleve/compiler_test.go | 3 +-- services/search/pkg/query/error.go | 2 +- services/search/pkg/query/query.go | 4 +--- 23 files changed, 25 insertions(+), 32 deletions(-) rename {services/search/pkg/query => ocis-pkg}/ast/ast.go (100%) rename {services/search/pkg/query => ocis-pkg}/ast/test/test.go (92%) rename {services/search/pkg/query => ocis-pkg}/kql/cast.go (97%) rename {services/search/pkg/query => ocis-pkg}/kql/connect.go (98%) rename {services/search/pkg/query => ocis-pkg}/kql/dictionary.peg (100%) rename {services/search/pkg/query => ocis-pkg}/kql/dictionary_gen.go (100%) rename {services/search/pkg/query => ocis-pkg}/kql/dictionary_test.go (99%) rename {services/search/pkg/query => ocis-pkg}/kql/doc.go (100%) rename {services/search/pkg/query => ocis-pkg}/kql/engine_suite_test.go (100%) rename {services/search/pkg/query => ocis-pkg}/kql/factory.go (98%) rename {services/search/pkg/query => ocis-pkg}/kql/gen.go (100%) rename {services/search/pkg/query => ocis-pkg}/kql/kql.go (94%) rename {services/search/pkg/query => ocis-pkg}/kql/kql_test.go (88%) rename {services/search/pkg/query => ocis-pkg}/kql/validate.go (91%) diff --git a/services/search/pkg/query/ast/ast.go b/ocis-pkg/ast/ast.go similarity index 100% rename from services/search/pkg/query/ast/ast.go rename to ocis-pkg/ast/ast.go diff --git a/services/search/pkg/query/ast/test/test.go b/ocis-pkg/ast/test/test.go similarity index 92% rename from services/search/pkg/query/ast/test/test.go rename to ocis-pkg/ast/test/test.go index 01a260de0e..946856f8b3 100644 --- a/services/search/pkg/query/ast/test/test.go +++ b/ocis-pkg/ast/test/test.go @@ -4,8 +4,7 @@ package test import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" - - "github.com/owncloud/ocis/v2/services/search/pkg/query/ast" + "github.com/owncloud/ocis/v2/ocis-pkg/ast" ) // DiffAst returns a human-readable report of the differences between two values diff --git a/services/search/pkg/query/kql/cast.go b/ocis-pkg/kql/cast.go similarity index 97% rename from services/search/pkg/query/kql/cast.go rename to ocis-pkg/kql/cast.go index c6ca30541a..55033eb1ff 100644 --- a/services/search/pkg/query/kql/cast.go +++ b/ocis-pkg/kql/cast.go @@ -5,9 +5,8 @@ import ( "time" "github.com/jinzhu/now" + "github.com/owncloud/ocis/v2/ocis-pkg/ast" "github.com/owncloud/ocis/v2/services/search/pkg/query" - - "github.com/owncloud/ocis/v2/services/search/pkg/query/ast" ) func toNode[T ast.Node](in interface{}) (T, error) { diff --git a/services/search/pkg/query/kql/connect.go b/ocis-pkg/kql/connect.go similarity index 98% rename from services/search/pkg/query/kql/connect.go rename to ocis-pkg/kql/connect.go index 3c926d688c..674a915618 100644 --- a/services/search/pkg/query/kql/connect.go +++ b/ocis-pkg/kql/connect.go @@ -3,7 +3,7 @@ package kql import ( "strings" - "github.com/owncloud/ocis/v2/services/search/pkg/query/ast" + "github.com/owncloud/ocis/v2/ocis-pkg/ast" ) // connectNodes connects given nodes diff --git a/services/search/pkg/query/kql/dictionary.peg b/ocis-pkg/kql/dictionary.peg similarity index 100% rename from services/search/pkg/query/kql/dictionary.peg rename to ocis-pkg/kql/dictionary.peg diff --git a/services/search/pkg/query/kql/dictionary_gen.go b/ocis-pkg/kql/dictionary_gen.go similarity index 100% rename from services/search/pkg/query/kql/dictionary_gen.go rename to ocis-pkg/kql/dictionary_gen.go diff --git a/services/search/pkg/query/kql/dictionary_test.go b/ocis-pkg/kql/dictionary_test.go similarity index 99% rename from services/search/pkg/query/kql/dictionary_test.go rename to ocis-pkg/kql/dictionary_test.go index adf4bd2d45..812f831df7 100644 --- a/services/search/pkg/query/kql/dictionary_test.go +++ b/ocis-pkg/kql/dictionary_test.go @@ -6,12 +6,11 @@ import ( "time" "github.com/jinzhu/now" + "github.com/owncloud/ocis/v2/ocis-pkg/ast" + "github.com/owncloud/ocis/v2/ocis-pkg/ast/test" + "github.com/owncloud/ocis/v2/ocis-pkg/kql" "github.com/owncloud/ocis/v2/services/search/pkg/query" tAssert "github.com/stretchr/testify/assert" - - "github.com/owncloud/ocis/v2/services/search/pkg/query/ast" - "github.com/owncloud/ocis/v2/services/search/pkg/query/ast/test" - "github.com/owncloud/ocis/v2/services/search/pkg/query/kql" ) func TestParse_Spec(t *testing.T) { diff --git a/services/search/pkg/query/kql/doc.go b/ocis-pkg/kql/doc.go similarity index 100% rename from services/search/pkg/query/kql/doc.go rename to ocis-pkg/kql/doc.go diff --git a/services/search/pkg/query/kql/engine_suite_test.go b/ocis-pkg/kql/engine_suite_test.go similarity index 100% rename from services/search/pkg/query/kql/engine_suite_test.go rename to ocis-pkg/kql/engine_suite_test.go diff --git a/services/search/pkg/query/kql/factory.go b/ocis-pkg/kql/factory.go similarity index 98% rename from services/search/pkg/query/kql/factory.go rename to ocis-pkg/kql/factory.go index 0eb858dd97..99deef825d 100644 --- a/services/search/pkg/query/kql/factory.go +++ b/ocis-pkg/kql/factory.go @@ -3,7 +3,7 @@ package kql import ( "strings" - "github.com/owncloud/ocis/v2/services/search/pkg/query/ast" + "github.com/owncloud/ocis/v2/ocis-pkg/ast" ) func base(text []byte, pos position) (*ast.Base, error) { diff --git a/services/search/pkg/query/kql/gen.go b/ocis-pkg/kql/gen.go similarity index 100% rename from services/search/pkg/query/kql/gen.go rename to ocis-pkg/kql/gen.go diff --git a/services/search/pkg/query/kql/kql.go b/ocis-pkg/kql/kql.go similarity index 94% rename from services/search/pkg/query/kql/kql.go rename to ocis-pkg/kql/kql.go index 2cf03a7f06..6e14cc7b6f 100644 --- a/services/search/pkg/query/kql/kql.go +++ b/ocis-pkg/kql/kql.go @@ -5,7 +5,7 @@ import ( "errors" "time" - "github.com/owncloud/ocis/v2/services/search/pkg/query/ast" + "github.com/owncloud/ocis/v2/ocis-pkg/ast" ) // The operator node value definition diff --git a/services/search/pkg/query/kql/kql_test.go b/ocis-pkg/kql/kql_test.go similarity index 88% rename from services/search/pkg/query/kql/kql_test.go rename to ocis-pkg/kql/kql_test.go index c130f75582..09f1249c5b 100644 --- a/services/search/pkg/query/kql/kql_test.go +++ b/ocis-pkg/kql/kql_test.go @@ -3,11 +3,10 @@ package kql_test import ( "testing" + "github.com/owncloud/ocis/v2/ocis-pkg/ast" + "github.com/owncloud/ocis/v2/ocis-pkg/kql" "github.com/owncloud/ocis/v2/services/search/pkg/query" tAssert "github.com/stretchr/testify/assert" - - "github.com/owncloud/ocis/v2/services/search/pkg/query/ast" - "github.com/owncloud/ocis/v2/services/search/pkg/query/kql" ) func TestNewAST(t *testing.T) { diff --git a/services/search/pkg/query/kql/validate.go b/ocis-pkg/kql/validate.go similarity index 91% rename from services/search/pkg/query/kql/validate.go rename to ocis-pkg/kql/validate.go index 96c6761ab1..0712a1a7ec 100644 --- a/services/search/pkg/query/kql/validate.go +++ b/ocis-pkg/kql/validate.go @@ -1,8 +1,8 @@ package kql import ( + "github.com/owncloud/ocis/v2/ocis-pkg/ast" "github.com/owncloud/ocis/v2/services/search/pkg/query" - "github.com/owncloud/ocis/v2/services/search/pkg/query/ast" ) func validateAst(a *ast.Ast) error { diff --git a/services/activitylog/Makefile b/services/activitylog/Makefile index 8d4cc0e158..f57e85e66f 100644 --- a/services/activitylog/Makefile +++ b/services/activitylog/Makefile @@ -44,7 +44,7 @@ l10n-push: .PHONY: l10n-read l10n-read: $(GO_XGETTEXT) - go-xgettext -o $(OUTPUT_DIR)/userlog.pot --keyword=l10n.Template -s pkg/service/response.go + go-xgettext -o $(OUTPUT_DIR)/activitylog.pot --keyword=l10n.Template -s pkg/service/response.go .PHONY: l10n-write l10n-write: diff --git a/services/activitylog/pkg/config/log.go b/services/activitylog/pkg/config/log.go index fef52d1078..6b19a62041 100644 --- a/services/activitylog/pkg/config/log.go +++ b/services/activitylog/pkg/config/log.go @@ -2,8 +2,8 @@ package config // Log defines the available log configuration. type Log struct { - Level string `mapstructure:"level" env:"OCIS_LOG_LEVEL;ACTIVITYLOG_USERLOG_LOG_LEVEL" desc:"The log level. Valid values are: 'panic', 'fatal', 'error', 'warn', 'info', 'debug', 'trace'." introductionVersion:"5.0"` - Pretty bool `mapstructure:"pretty" env:"OCIS_LOG_PRETTY;ACTIVITYLOG_USERLOG_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"5.0"` - Color bool `mapstructure:"color" env:"OCIS_LOG_COLOR;ACTIVITYLOG_USERLOG_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"5.0"` - File string `mapstructure:"file" env:"OCIS_LOG_FILE;ACTIVITYLOG_USERLOG_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set." introductionVersion:"5.0"` + Level string `mapstructure:"level" env:"OCIS_LOG_LEVEL;ACTIVITYLOG_LOG_LEVEL" desc:"The log level. Valid values are: 'panic', 'fatal', 'error', 'warn', 'info', 'debug', 'trace'." introductionVersion:"5.0"` + Pretty bool `mapstructure:"pretty" env:"OCIS_LOG_PRETTY;ACTIVITYLOG_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"5.0"` + Color bool `mapstructure:"color" env:"OCIS_LOG_COLOR;ACTIVITYLOG_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"5.0"` + File string `mapstructure:"file" env:"OCIS_LOG_FILE;ACTIVITYLOG_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set." introductionVersion:"5.0"` } diff --git a/services/activitylog/pkg/service/http.go b/services/activitylog/pkg/service/http.go index 39dbbb2683..73aeda0ebf 100644 --- a/services/activitylog/pkg/service/http.go +++ b/services/activitylog/pkg/service/http.go @@ -15,11 +15,11 @@ import ( "github.com/cs3org/reva/v2/pkg/utils" libregraph "github.com/owncloud/libre-graph-api-go" + "github.com/owncloud/ocis/v2/ocis-pkg/ast" + "github.com/owncloud/ocis/v2/ocis-pkg/kql" "github.com/owncloud/ocis/v2/ocis-pkg/l10n" ehmsg "github.com/owncloud/ocis/v2/protogen/gen/ocis/messages/eventhistory/v0" ehsvc "github.com/owncloud/ocis/v2/protogen/gen/ocis/services/eventhistory/v0" - "github.com/owncloud/ocis/v2/services/search/pkg/query/ast" - "github.com/owncloud/ocis/v2/services/search/pkg/query/kql" ) var ( diff --git a/services/search/Makefile b/services/search/Makefile index bc58a2eb79..a55dd6fed7 100644 --- a/services/search/Makefile +++ b/services/search/Makefile @@ -26,7 +26,7 @@ include ../../.make/generate.mk .PHONY: ci-go-generate ci-go-generate: $(PIGEON) $(MOCKERY) # CI runs ci-node-generate automatically before this target $(MOCKERY) - $(PIGEON) -optimize-grammar -optimize-parser -o pkg/query/kql/dictionary_gen.go pkg/query/kql/dictionary.peg + $(PIGEON) -optimize-grammar -optimize-parser -o ../../ocis-pkg/kql/dictionary_gen.go ../../ocis-pkg/kql/dictionary.peg .PHONY: ci-node-generate ci-node-generate: diff --git a/services/search/pkg/query/bleve/bleve.go b/services/search/pkg/query/bleve/bleve.go index e720b35f70..b6e825e6ee 100644 --- a/services/search/pkg/query/bleve/bleve.go +++ b/services/search/pkg/query/bleve/bleve.go @@ -4,8 +4,8 @@ package bleve import ( bQuery "github.com/blevesearch/bleve/v2/search/query" + "github.com/owncloud/ocis/v2/ocis-pkg/kql" "github.com/owncloud/ocis/v2/services/search/pkg/query" - "github.com/owncloud/ocis/v2/services/search/pkg/query/kql" ) // Creator is combines a Builder and a Compiler which is used to Create the query. diff --git a/services/search/pkg/query/bleve/compiler.go b/services/search/pkg/query/bleve/compiler.go index 2d0eace100..7046bee9de 100644 --- a/services/search/pkg/query/bleve/compiler.go +++ b/services/search/pkg/query/bleve/compiler.go @@ -6,8 +6,8 @@ import ( "github.com/blevesearch/bleve/v2" bleveQuery "github.com/blevesearch/bleve/v2/search/query" - "github.com/owncloud/ocis/v2/services/search/pkg/query/ast" - "github.com/owncloud/ocis/v2/services/search/pkg/query/kql" + "github.com/owncloud/ocis/v2/ocis-pkg/ast" + "github.com/owncloud/ocis/v2/ocis-pkg/kql" ) var _fields = map[string]string{ diff --git a/services/search/pkg/query/bleve/compiler_test.go b/services/search/pkg/query/bleve/compiler_test.go index 597ce4c29e..c1286cab95 100644 --- a/services/search/pkg/query/bleve/compiler_test.go +++ b/services/search/pkg/query/bleve/compiler_test.go @@ -5,9 +5,8 @@ import ( "time" "github.com/blevesearch/bleve/v2/search/query" + "github.com/owncloud/ocis/v2/ocis-pkg/ast" tAssert "github.com/stretchr/testify/assert" - - "github.com/owncloud/ocis/v2/services/search/pkg/query/ast" ) var timeMustParse = func(t *testing.T, ts string) time.Time { diff --git a/services/search/pkg/query/error.go b/services/search/pkg/query/error.go index 89f504c8a4..7a3780a38d 100644 --- a/services/search/pkg/query/error.go +++ b/services/search/pkg/query/error.go @@ -3,7 +3,7 @@ package query import ( "fmt" - "github.com/owncloud/ocis/v2/services/search/pkg/query/ast" + "github.com/owncloud/ocis/v2/ocis-pkg/ast" ) // StartsWithBinaryOperatorError records an error and the operation that caused it. diff --git a/services/search/pkg/query/query.go b/services/search/pkg/query/query.go index e49dbecd91..2b776595b5 100644 --- a/services/search/pkg/query/query.go +++ b/services/search/pkg/query/query.go @@ -1,9 +1,7 @@ // Package query provides functions to work with the different search query flavours. package query -import ( - "github.com/owncloud/ocis/v2/services/search/pkg/query/ast" -) +import "github.com/owncloud/ocis/v2/ocis-pkg/ast" // Builder is the interface that wraps the basic Build method. type Builder interface {