From 9023bd754f7fcf11f251d64e95516f9907f35f83 Mon Sep 17 00:00:00 2001 From: Oliver Sun <73540835+oliversun9@users.noreply.github.com> Date: Mon, 2 Oct 2023 17:24:36 -0400 Subject: [PATCH] Move package `celext` out of internal (#56) Move `celext` out of internal so that `buf lint` can import this package and load `DefaultEnv` before checking if a CEL expression compiles. --- .golangci.yml | 2 +- {internal/celext => celext}/lib.go | 3 +-- {internal/celext => celext}/lib_test.go | 0 internal/constraints/cache_test.go | 2 +- internal/evaluator/builder_test.go | 2 +- internal/expression/ast_test.go | 2 +- validator.go | 2 +- 7 files changed, 6 insertions(+), 7 deletions(-) rename {internal/celext => celext}/lib.go (98%) rename {internal/celext => celext}/lib_test.go (100%) diff --git a/.golangci.yml b/.golangci.yml index 4e38e07..b6f1c43 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -67,7 +67,7 @@ issues: - varnamelen - unparam - gosec - - path: internal/celext/lib.go + - path: celext/lib.go linters: # setting up custom functions/overloads appears duplicative (false positive) - dupl diff --git a/internal/celext/lib.go b/celext/lib.go similarity index 98% rename from internal/celext/lib.go rename to celext/lib.go index 1a70b61..fa472dd 100644 --- a/internal/celext/lib.go +++ b/celext/lib.go @@ -33,8 +33,7 @@ import ( // DefaultEnv produces a cel.Env with the necessary cel.EnvOption and // cel.ProgramOption values preconfigured for usage throughout the // module. If useUTC is true, timestamp operations use the UTC timezone instead -// of the local timezone. If locale is non-empty, the provided locale string is -// used for string formatting, defaulting to 'en_US' if unset. +// of the local timezone. func DefaultEnv(useUTC bool) (*cel.Env, error) { return cel.NewEnv( cel.Lib(lib{ diff --git a/internal/celext/lib_test.go b/celext/lib_test.go similarity index 100% rename from internal/celext/lib_test.go rename to celext/lib_test.go diff --git a/internal/constraints/cache_test.go b/internal/constraints/cache_test.go index e7fa495..e36839a 100644 --- a/internal/constraints/cache_test.go +++ b/internal/constraints/cache_test.go @@ -18,7 +18,7 @@ import ( "testing" "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate" - "github.com/bufbuild/protovalidate-go/internal/celext" + "github.com/bufbuild/protovalidate-go/celext" "github.com/bufbuild/protovalidate-go/internal/gen/buf/validate/conformance/cases" "github.com/google/cel-go/cel" "github.com/stretchr/testify/assert" diff --git a/internal/evaluator/builder_test.go b/internal/evaluator/builder_test.go index 0ac6fa5..3e5e486 100644 --- a/internal/evaluator/builder_test.go +++ b/internal/evaluator/builder_test.go @@ -18,7 +18,7 @@ import ( "sync" "testing" - "github.com/bufbuild/protovalidate-go/internal/celext" + "github.com/bufbuild/protovalidate-go/celext" pb "github.com/bufbuild/protovalidate-go/internal/gen/tests/example/v1" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/internal/expression/ast_test.go b/internal/expression/ast_test.go index 36f1a76..b15606b 100644 --- a/internal/expression/ast_test.go +++ b/internal/expression/ast_test.go @@ -18,7 +18,7 @@ import ( "testing" "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate" - "github.com/bufbuild/protovalidate-go/internal/celext" + "github.com/bufbuild/protovalidate-go/celext" "github.com/google/cel-go/cel" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/validator.go b/validator.go index 0c0dda9..e5ab70d 100644 --- a/validator.go +++ b/validator.go @@ -18,7 +18,7 @@ import ( "fmt" "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate" - "github.com/bufbuild/protovalidate-go/internal/celext" + "github.com/bufbuild/protovalidate-go/celext" "github.com/bufbuild/protovalidate-go/internal/errors" "github.com/bufbuild/protovalidate-go/internal/evaluator" "google.golang.org/protobuf/proto"