Skip to content

Commit

Permalink
Minor edits to simplify imports (#1012)
Browse files Browse the repository at this point in the history
  • Loading branch information
TristonianJones authored Aug 30, 2024
1 parent 6ba2c03 commit b4397c4
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion common/containers/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func Abbrevs(qualifiedNames ...string) ContainerOption {
return func(c *Container) (*Container, error) {
for _, qn := range qualifiedNames {
qn = strings.TrimSpace(qn)
for _, r := range []rune(qn) {
for _, r := range qn {
if !isIdentifierChar(r) {
return nil, fmt.Errorf(
"invalid qualified name: %s, wanted name of the form 'qualified.name'", qn)
Expand Down
2 changes: 1 addition & 1 deletion common/types/null.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (n Null) ConvertToNative(typeDesc reflect.Type) (any, error) {
uint64WrapperType, durationValueType, timestampValueType, protoIfaceType:
return nil, nil
case jsonListValueType, jsonStructType:
break
// skip handling
default:
if typeDesc.Implements(protoIfaceType) {
return nil, nil
Expand Down
2 changes: 1 addition & 1 deletion common/types/null_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import (
"reflect"
"testing"

"github.com/google/cel-go/test/proto3pb"
"google.golang.org/protobuf/proto"

proto3pb "github.com/google/cel-go/test/proto3pb"
dynamicpb "google.golang.org/protobuf/types/dynamicpb"
anypb "google.golang.org/protobuf/types/known/anypb"
structpb "google.golang.org/protobuf/types/known/structpb"
Expand Down
3 changes: 3 additions & 0 deletions conformance/conformance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,20 @@ import (
"cel.dev/expr/proto/test/v1/testpb"

"github.com/bazelbuild/rules_go/go/runfiles"

"github.com/google/cel-go/cel"
"github.com/google/cel-go/common"
"github.com/google/cel-go/common/types"
"github.com/google/cel-go/common/types/ref"
"github.com/google/cel-go/ext"
"github.com/google/go-cmp/cmp"

"google.golang.org/protobuf/encoding/prototext"
"google.golang.org/protobuf/testing/protocmp"

test2pb "cel.dev/expr/proto/test/v1/proto2/test_all_types"
test3pb "cel.dev/expr/proto/test/v1/proto3/test_all_types"

exprpb "google.golang.org/genproto/googleapis/api/expr/v1alpha1"
)

Expand Down
4 changes: 2 additions & 2 deletions interpreter/interpreter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ import (
"time"

"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/structpb"
"google.golang.org/protobuf/types/known/wrapperspb"

"github.com/google/cel-go/checker"
"github.com/google/cel-go/common"
Expand All @@ -42,7 +40,9 @@ import (
"github.com/google/cel-go/parser"

exprpb "google.golang.org/genproto/googleapis/api/expr/v1alpha1"
structpb "google.golang.org/protobuf/types/known/structpb"
tpb "google.golang.org/protobuf/types/known/timestamppb"
wrapperspb "google.golang.org/protobuf/types/known/wrapperspb"

proto2pb "github.com/google/cel-go/test/proto2pb"
proto3pb "github.com/google/cel-go/test/proto3pb"
Expand Down
6 changes: 6 additions & 0 deletions policy/compiler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ func (r *runner) run(t *testing.T) {
t.Fatalf("context variable is not a valid proto: %v", err)
}
activation, err = cel.ContextProtoVars(ctx.(proto.Message))
if err != nil {
t.Fatalf("cel.ContextProtoVars() failed: %v", err)
}
break
}
input[k] = v.Value
Expand Down Expand Up @@ -276,6 +279,9 @@ func (r *runner) bench(b *testing.B) {
b.Fatalf("context variable is not a valid proto: %v", err)
}
activation, err = cel.ContextProtoVars(ctx.(proto.Message))
if err != nil {
b.Fatalf("cel.ContextProtoVars() failed: %v", err)
}
break
}
input[k] = v.Value
Expand Down
2 changes: 1 addition & 1 deletion policy/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ variables:
{
config: `
variables:
- type:
- type:
type_name: "no variable name"`,
err: "invalid variable, must set 'name' or 'context_proto' field",
},
Expand Down
3 changes: 2 additions & 1 deletion policy/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ import (
"github.com/google/cel-go/cel"
"github.com/google/cel-go/common/types"
"github.com/google/cel-go/common/types/ref"
"github.com/google/cel-go/test/proto3pb"

"gopkg.in/yaml.v3"

proto3pb "github.com/google/cel-go/test/proto3pb"
)

var (
Expand Down
4 changes: 2 additions & 2 deletions repl/evaluator.go
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ func newExtensionOption(extType string) (*extensionOption, error) {
return &extensionOption{extensionType: extType, option: extOption}, nil
} else {
keys := make([]string, 0)
for k, _ := range extensionMap {
for k := range extensionMap {
keys = append(keys, k)
}
sort.Strings(keys)
Expand Down Expand Up @@ -821,7 +821,7 @@ func (e *Evaluator) loadExtensionOption(idx int, args []string) error {
argExtType := args[idx]
if argExtType == "all" {
// Load all extension types as a convenience
for val, _ := range extensionMap {
for val := range extensionMap {
err := e.loadExtensionOptionType(val)
if err != nil {
return err
Expand Down

0 comments on commit b4397c4

Please sign in to comment.