From 47dc1ad1ae3b9e8ea343245a5a137102769b5af1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Mar 2024 00:37:39 +0000 Subject: [PATCH] chore(deps): bump go.einride.tech/sage from 0.264.0 to 0.272.0 in /.sage Bumps [go.einride.tech/sage](https://github.com/einride/sage) from 0.264.0 to 0.272.0. - [Release notes](https://github.com/einride/sage/releases) - [Commits](https://github.com/einride/sage/compare/v0.264.0...v0.272.0) --- updated-dependencies: - dependency-name: go.einride.tech/sage dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .sage/go.mod | 2 +- .sage/go.sum | 4 +- .../internal/genaip/resourcename.go | 26 ++++----- fieldbehavior/fieldbehavior.go | 2 +- fieldbehavior/fieldbehavior_test.go | 6 +- fieldbehavior/immutable.go | 2 +- fieldbehavior/required.go | 2 +- filtering/checker.go | 58 +++++++++---------- filtering/checker_test.go | 2 +- filtering/declarations.go | 6 +- filtering/exprs/match.go | 6 +- filtering/macro.go | 18 +++--- filtering/macro_test.go | 12 ++-- filtering/parser.go | 6 +- filtering/parser_test.go | 14 ++--- filtering/request.go | 2 +- filtering/walk.go | 24 ++++---- reflect/aipreflect/resources.go | 2 +- .../aipreflect/validateresourcereferences.go | 4 +- validation/error.go | 8 +-- validation/error_test.go | 2 +- validation/messagevalidator.go | 2 +- 22 files changed, 105 insertions(+), 105 deletions(-) diff --git a/.sage/go.mod b/.sage/go.mod index e5e9d1723e..757526c8f0 100644 --- a/.sage/go.mod +++ b/.sage/go.mod @@ -2,4 +2,4 @@ module sage go 1.19 -require go.einride.tech/sage v0.264.0 +require go.einride.tech/sage v0.272.0 diff --git a/.sage/go.sum b/.sage/go.sum index 280851aaba..767564babb 100644 --- a/.sage/go.sum +++ b/.sage/go.sum @@ -1,2 +1,2 @@ -go.einride.tech/sage v0.264.0 h1:NuEefbHh89txKXhVLcn70y1M2dY+eJw9cjLeousZefs= -go.einride.tech/sage v0.264.0/go.mod h1:EzV5uciFX7/2ho8EKB5K9JghOfXIxlzs694b+Tkl5GQ= +go.einride.tech/sage v0.272.0 h1:NxK2zVtsYJn9Wwp//Tz5gmQsiVwT0uXLkau5WJnnXR8= +go.einride.tech/sage v0.272.0/go.mod h1:EzV5uciFX7/2ho8EKB5K9JghOfXIxlzs694b+Tkl5GQ= diff --git a/cmd/protoc-gen-go-aip/internal/genaip/resourcename.go b/cmd/protoc-gen-go-aip/internal/genaip/resourcename.go index 02eca653c3..147cd81054 100644 --- a/cmd/protoc-gen-go-aip/internal/genaip/resourcename.go +++ b/cmd/protoc-gen-go-aip/internal/genaip/resourcename.go @@ -19,11 +19,11 @@ type resourceNameCodeGenerator struct { } func (r resourceNameCodeGenerator) GenerateCode(g *protogen.GeneratedFile) error { - if len(r.resource.Pattern) == 0 { + if len(r.resource.GetPattern()) == 0 { return nil } - hasMultiPattern := len(r.resource.Pattern) > 1 - hasFutureMultiPattern := r.resource.History == annotations.ResourceDescriptor_FUTURE_MULTI_PATTERN + hasMultiPattern := len(r.resource.GetPattern()) > 1 + hasFutureMultiPattern := r.resource.GetHistory() == annotations.ResourceDescriptor_FUTURE_MULTI_PATTERN // Generate multi-pattern interface and parse methods if we have multiple patterns now or in the future. if hasMultiPattern || hasFutureMultiPattern { if err := r.generateMultiPatternInterface(g); err != nil { @@ -35,7 +35,7 @@ func (r resourceNameCodeGenerator) GenerateCode(g *protogen.GeneratedFile) error } // Generate the single-pattern struct unless we explicitly only want multi-patterns from the start. - firstPattern := r.resource.Pattern[0] + firstPattern := r.resource.GetPattern()[0] shouldGenerateSinglePatternStruct := !hasFutureMultiPattern firstSinglePatternStructName := r.SinglePatternStructName() if shouldGenerateSinglePatternStruct { @@ -59,7 +59,7 @@ func (r resourceNameCodeGenerator) GenerateCode(g *protogen.GeneratedFile) error } } // Generate multi-pattern structs for all but the first pattern. - for _, pattern := range r.resource.Pattern[1:] { + for _, pattern := range r.resource.GetPattern()[1:] { if err := r.generatePatternStruct(g, pattern, r.MultiPatternStructName(pattern)); err != nil { return err } @@ -136,7 +136,7 @@ func (r *resourceNameCodeGenerator) generateParentConstructorMethod( parent *annotations.ResourceDescriptor, ) error { var parentPattern string - for _, parentCandidate := range parent.Pattern { + for _, parentCandidate := range parent.GetPattern() { if resourcename.HasParent(pattern, parentCandidate) { parentPattern = parentCandidate break @@ -193,7 +193,7 @@ func (r *resourceNameCodeGenerator) generateParentMethod( parent *annotations.ResourceDescriptor, ) error { var parentPattern string - for _, parentCandidate := range parent.Pattern { + for _, parentCandidate := range parent.GetPattern() { if resourcename.HasParent(pattern, parentCandidate) { parentPattern = parentCandidate break @@ -370,7 +370,7 @@ func (r *resourceNameCodeGenerator) generateMultiPatternParseMethod(g *protogen. g.P() g.P("func Parse", r.MultiPatternInterfaceName(), "(name string) (", r.MultiPatternInterfaceName(), ", error) {") g.P("switch {") - for _, pattern := range r.resource.Pattern { + for _, pattern := range r.resource.GetPattern() { g.P("case ", resourcenameMatch, "(", strconv.Quote(pattern), ", name):") g.P("var result ", r.MultiPatternStructName(pattern)) g.P("return &result, result.UnmarshalString(name)") @@ -383,14 +383,14 @@ func (r *resourceNameCodeGenerator) generateMultiPatternParseMethod(g *protogen. } func (r *resourceNameCodeGenerator) SinglePatternStructName() string { - return aipreflect.ResourceType(r.resource.Type).Type() + "ResourceName" + return aipreflect.ResourceType(r.resource.GetType()).Type() + "ResourceName" } func (r *resourceNameCodeGenerator) StructName(pattern string) string { - if r.resource.History == annotations.ResourceDescriptor_FUTURE_MULTI_PATTERN || len(r.resource.Pattern) > 1 { + if r.resource.GetHistory() == annotations.ResourceDescriptor_FUTURE_MULTI_PATTERN || len(r.resource.GetPattern()) > 1 { return r.MultiPatternStructName(pattern) } - if r.resource.Pattern[0] == pattern { + if r.resource.GetPattern()[0] == pattern { return r.SinglePatternStructName() } return r.MultiPatternStructName(pattern) @@ -401,7 +401,7 @@ func (r *resourceNameCodeGenerator) MultiPatternStructName(pattern string) strin var sc resourcename.Scanner sc.Init(pattern) for sc.Scan() { - if !sc.Segment().IsVariable() && string(sc.Segment().Literal()) != r.resource.Plural { + if !sc.Segment().IsVariable() && string(sc.Segment().Literal()) != r.resource.GetPlural() { _, _ = result.WriteString(strcase.UpperCamelCase(string(sc.Segment().Literal()))) } } @@ -410,5 +410,5 @@ func (r *resourceNameCodeGenerator) MultiPatternStructName(pattern string) strin } func (r *resourceNameCodeGenerator) MultiPatternInterfaceName() string { - return aipreflect.ResourceType(r.resource.Type).Type() + "MultiPatternResourceName" + return aipreflect.ResourceType(r.resource.GetType()).Type() + "MultiPatternResourceName" } diff --git a/fieldbehavior/fieldbehavior.go b/fieldbehavior/fieldbehavior.go index 0f984518cd..2024d60c21 100644 --- a/fieldbehavior/fieldbehavior.go +++ b/fieldbehavior/fieldbehavior.go @@ -112,7 +112,7 @@ func clearFieldsWithBehaviors(m proto.Message, behaviorsToClear ...annotations.F rangeFieldsWithBehaviors(m, func( m protoreflect.Message, f protoreflect.FieldDescriptor, - v protoreflect.Value, + _ protoreflect.Value, behaviors []annotations.FieldBehavior, ) bool { if hasAnyBehavior(behaviors, behaviorsToClear) { diff --git a/fieldbehavior/fieldbehavior_test.go b/fieldbehavior/fieldbehavior_test.go index 19f4bc91e5..2b48b700dc 100644 --- a/fieldbehavior/fieldbehavior_test.go +++ b/fieldbehavior/fieldbehavior_test.go @@ -22,9 +22,9 @@ func TestClearFields(t *testing.T) { DisplayName: "site one", // has REQUIRED field_behavior; should not be cleared. } ClearFields(site, annotations.FieldBehavior_OUTPUT_ONLY) - assert.Equal(t, site.CreateTime, (*timestamppb.Timestamp)(nil)) - assert.Equal(t, site.DisplayName, "site one") - assert.Equal(t, site.Name, "site1") + assert.Equal(t, site.GetCreateTime(), (*timestamppb.Timestamp)(nil)) + assert.Equal(t, site.GetDisplayName(), "site one") + assert.Equal(t, site.GetName(), "site1") }) } diff --git a/fieldbehavior/immutable.go b/fieldbehavior/immutable.go index 33f64f45a5..9bf6771a1d 100644 --- a/fieldbehavior/immutable.go +++ b/fieldbehavior/immutable.go @@ -47,7 +47,7 @@ func validateImmutableFields(m protoreflect.Message, mask *fieldmaskpb.FieldMask continue } var mapErr error - value.Map().Range(func(key protoreflect.MapKey, value protoreflect.Value) bool { + value.Map().Range(func(_ protoreflect.MapKey, value protoreflect.Value) bool { if err := validateImmutableFields(value.Message(), mask, currPath); err != nil { mapErr = err return false diff --git a/fieldbehavior/required.go b/fieldbehavior/required.go index 417791014d..ef81a2efe5 100644 --- a/fieldbehavior/required.go +++ b/fieldbehavior/required.go @@ -55,7 +55,7 @@ func validateRequiredFields(reflectMessage protoreflect.Message, mask *fieldmask continue } var mapErr error - value.Map().Range(func(key protoreflect.MapKey, value protoreflect.Value) bool { + value.Map().Range(func(_ protoreflect.MapKey, value protoreflect.Value) bool { if err := validateRequiredFields(value.Message(), mask, currPath); err != nil { mapErr = err return false diff --git a/filtering/checker.go b/filtering/checker.go index 3a03ae317d..5168eb12ee 100644 --- a/filtering/checker.go +++ b/filtering/checker.go @@ -20,7 +20,7 @@ func (c *Checker) Init(exp *expr.Expr, sourceInfo *expr.SourceInfo, declarations expr: exp, declarations: declarations, sourceInfo: sourceInfo, - typeMap: make(map[int64]*expr.Type, len(sourceInfo.Positions)), + typeMap: make(map[int64]*expr.Type, len(sourceInfo.GetPositions())), } } @@ -46,9 +46,9 @@ func (c *Checker) checkExpr(e *expr.Expr) error { if e == nil { return nil } - switch e.ExprKind.(type) { + switch e.GetExprKind().(type) { case *expr.Expr_ConstExpr: - switch e.GetConstExpr().ConstantKind.(type) { + switch e.GetConstExpr().GetConstantKind().(type) { case *expr.Constant_BoolValue: return c.checkBoolLiteral(e) case *expr.Constant_DoubleValue: @@ -95,17 +95,17 @@ func (c *Checker) checkSelectExpr(e *expr.Expr) (err error) { } } selectExpr := e.GetSelectExpr() - if selectExpr.Operand == nil { + if selectExpr.GetOperand() == nil { return c.errorf(e, "missing operand") } - if err := c.checkExpr(selectExpr.Operand); err != nil { + if err := c.checkExpr(selectExpr.GetOperand()); err != nil { return err } - operandType, ok := c.getType(selectExpr.Operand) + operandType, ok := c.getType(selectExpr.GetOperand()) if !ok { return c.errorf(e, "failed to get operand type") } - switch operandType.TypeKind.(type) { + switch operandType.GetTypeKind().(type) { case *expr.Type_MapType_: return c.setType(e, operandType.GetMapType().GetValueType()) default: @@ -125,9 +125,9 @@ func (c *Checker) checkCallExpr(e *expr.Expr) (err error) { return err } } - functionDeclaration, ok := c.declarations.LookupFunction(callExpr.Function) + functionDeclaration, ok := c.declarations.LookupFunction(callExpr.GetFunction()) if !ok { - return c.errorf(e, "undeclared function '%s'", callExpr.Function) + return c.errorf(e, "undeclared function '%s'", callExpr.GetFunction()) } functionOverload, err := c.resolveCallExprFunctionOverload(e, functionDeclaration) if err != nil { @@ -136,7 +136,7 @@ func (c *Checker) checkCallExpr(e *expr.Expr) (err error) { if err := c.checkCallExprBuiltinFunctionOverloads(e, functionOverload); err != nil { return err } - return c.setType(e, functionOverload.ResultType) + return c.setType(e, functionOverload.GetResultType()) } func (c *Checker) resolveCallExprFunctionOverload( @@ -145,15 +145,15 @@ func (c *Checker) resolveCallExprFunctionOverload( ) (*expr.Decl_FunctionDecl_Overload, error) { callExpr := e.GetCallExpr() for _, overload := range functionDeclaration.GetFunction().GetOverloads() { - if len(callExpr.GetArgs()) != len(overload.Params) { + if len(callExpr.GetArgs()) != len(overload.GetParams()) { continue } - if len(overload.TypeParams) == 0 { + if len(overload.GetTypeParams()) == 0 { allTypesMatch := true - for i, param := range overload.Params { - argType, ok := c.getType(callExpr.Args[i]) + for i, param := range overload.GetParams() { + argType, ok := c.getType(callExpr.GetArgs()[i]) if !ok { - return nil, c.errorf(callExpr.Args[i], "unknown type") + return nil, c.errorf(callExpr.GetArgs()[i], "unknown type") } if !proto.Equal(argType, param) { allTypesMatch = false @@ -183,17 +183,17 @@ func (c *Checker) checkCallExprBuiltinFunctionOverloads( functionOverload *expr.Decl_FunctionDecl_Overload, ) error { callExpr := e.GetCallExpr() - switch functionOverload.OverloadId { + switch functionOverload.GetOverloadId() { case FunctionOverloadTimestampString: - if constExpr := callExpr.Args[0].GetConstExpr(); constExpr != nil { + if constExpr := callExpr.GetArgs()[0].GetConstExpr(); constExpr != nil { if _, err := time.Parse(time.RFC3339, constExpr.GetStringValue()); err != nil { - return c.errorf(callExpr.Args[0], "invalid timestamp. Should be in RFC3339 format") + return c.errorf(callExpr.GetArgs()[0], "invalid timestamp. Should be in RFC3339 format") } } case FunctionOverloadDurationString: - if constExpr := callExpr.Args[0].GetConstExpr(); constExpr != nil { + if constExpr := callExpr.GetArgs()[0].GetConstExpr(); constExpr != nil { if _, err := time.ParseDuration(constExpr.GetStringValue()); err != nil { - return c.errorf(callExpr.Args[0], "invalid duration") + return c.errorf(callExpr.GetArgs()[0], "invalid duration") } } case FunctionOverloadLessThanTimestampString, @@ -202,9 +202,9 @@ func (c *Checker) checkCallExprBuiltinFunctionOverloads( FunctionOverloadGreaterEqualsTimestampString, FunctionOverloadEqualsTimestampString, FunctionOverloadNotEqualsTimestampString: - if constExpr := callExpr.Args[1].GetConstExpr(); constExpr != nil { + if constExpr := callExpr.GetArgs()[1].GetConstExpr(); constExpr != nil { if _, err := time.Parse(time.RFC3339, constExpr.GetStringValue()); err != nil { - return c.errorf(callExpr.Args[0], "invalid timestamp. Should be in RFC3339 format") + return c.errorf(callExpr.GetArgs()[0], "invalid timestamp. Should be in RFC3339 format") } } } @@ -243,15 +243,15 @@ func (c *Checker) wrapf(err error, _ *expr.Expr, format string, args ...interfac } func (c *Checker) setType(e *expr.Expr, t *expr.Type) error { - if existingT, ok := c.typeMap[e.Id]; ok && !proto.Equal(t, existingT) { + if existingT, ok := c.typeMap[e.GetId()]; ok && !proto.Equal(t, existingT) { return c.errorf(e, "type conflict between %s and %s", t, existingT) } - c.typeMap[e.Id] = t + c.typeMap[e.GetId()] = t return nil } func (c *Checker) getType(e *expr.Expr) (*expr.Type, bool) { - t, ok := c.typeMap[e.Id] + t, ok := c.typeMap[e.GetId()] if !ok { return nil, false } @@ -259,18 +259,18 @@ func (c *Checker) getType(e *expr.Expr) (*expr.Type, bool) { } func toQualifiedName(e *expr.Expr) (string, bool) { - switch kind := e.ExprKind.(type) { + switch kind := e.GetExprKind().(type) { case *expr.Expr_IdentExpr: return kind.IdentExpr.GetName(), true case *expr.Expr_SelectExpr: - if kind.SelectExpr.TestOnly { + if kind.SelectExpr.GetTestOnly() { return "", false } - parent, ok := toQualifiedName(kind.SelectExpr.Operand) + parent, ok := toQualifiedName(kind.SelectExpr.GetOperand()) if !ok { return "", false } - return parent + "." + kind.SelectExpr.Field, true + return parent + "." + kind.SelectExpr.GetField(), true default: return "", false } diff --git a/filtering/checker_test.go b/filtering/checker_test.go index 756640578d..bff0d650a9 100644 --- a/filtering/checker_test.go +++ b/filtering/checker_test.go @@ -450,7 +450,7 @@ func TestChecker(t *testing.T) { } assert.NilError(t, err) var checker Checker - checker.Init(parsedExpr.Expr, parsedExpr.SourceInfo, declarations) + checker.Init(parsedExpr.GetExpr(), parsedExpr.GetSourceInfo(), declarations) checkedExpr, err := checker.Check() if tt.errorContains != "" { assert.ErrorContains(t, err, tt.errorContains) diff --git a/filtering/declarations.go b/filtering/declarations.go index 51a2083968..192553ea44 100644 --- a/filtering/declarations.go +++ b/filtering/declarations.go @@ -195,9 +195,9 @@ func (d *Declarations) declareFunction(name string, overloads ...*expr.Decl_Func NewOverloadLoop: for _, newOverload := range overloads { for _, existingOverload := range function.GetOverloads() { - if newOverload.OverloadId == existingOverload.OverloadId { + if newOverload.GetOverloadId() == existingOverload.GetOverloadId() { if !proto.Equal(newOverload, existingOverload) { - return fmt.Errorf("redeclaration of overload %s", existingOverload.OverloadId) + return fmt.Errorf("redeclaration of overload %s", existingOverload.GetOverloadId()) } continue NewOverloadLoop } @@ -208,7 +208,7 @@ NewOverloadLoop: } func (d *Declarations) declare(decl *expr.Decl) error { - switch decl.DeclKind.(type) { + switch decl.GetDeclKind().(type) { case *expr.Decl_Function: return d.declareFunction(decl.GetName(), decl.GetFunction().GetOverloads()...) case *expr.Decl_Ident: diff --git a/filtering/exprs/match.go b/filtering/exprs/match.go index af370dba76..1e2a294df8 100644 --- a/filtering/exprs/match.go +++ b/filtering/exprs/match.go @@ -25,7 +25,7 @@ func MatchAnyString(value *string) Matcher { if cons == nil { return false } - if _, ok := cons.ConstantKind.(*expr.Constant_StringValue); !ok { + if _, ok := cons.GetConstantKind().(*expr.Constant_StringValue); !ok { return false } *value = cons.GetStringValue() @@ -50,7 +50,7 @@ func MatchAnyFloat(value *float64) Matcher { if cons == nil { return false } - if _, ok := cons.ConstantKind.(*expr.Constant_DoubleValue); !ok { + if _, ok := cons.GetConstantKind().(*expr.Constant_DoubleValue); !ok { return false } *value = cons.GetDoubleValue() @@ -75,7 +75,7 @@ func MatchAnyInt(value *int64) Matcher { if cons == nil { return false } - if _, ok := cons.ConstantKind.(*expr.Constant_Int64Value); !ok { + if _, ok := cons.GetConstantKind().(*expr.Constant_Int64Value); !ok { return false } *value = cons.GetInt64Value() diff --git a/filtering/macro.go b/filtering/macro.go index d703612c08..bd68d20615 100644 --- a/filtering/macro.go +++ b/filtering/macro.go @@ -7,9 +7,9 @@ type Macro func(*Cursor) // ApplyMacros applies the provided macros to the filter and type-checks the result against the provided declarations. func ApplyMacros(filter Filter, declarations *Declarations, macros ...Macro) (Filter, error) { - applyMacros(filter.CheckedExpr.Expr, filter.CheckedExpr.SourceInfo, macros...) + applyMacros(filter.CheckedExpr.GetExpr(), filter.CheckedExpr.GetSourceInfo(), macros...) var checker Checker - checker.Init(filter.CheckedExpr.Expr, filter.CheckedExpr.SourceInfo, declarations) + checker.Init(filter.CheckedExpr.GetExpr(), filter.CheckedExpr.GetSourceInfo(), declarations) checkedExpr, err := checker.Check() if err != nil { return Filter{}, err @@ -62,7 +62,7 @@ func (c *Cursor) Expr() *expr.Expr { // Replace the current expression with a new expression. func (c *Cursor) Replace(newExpr *expr.Expr) { - Walk(func(childExpr, parentExpr *expr.Expr) bool { + Walk(func(childExpr, _ *expr.Expr) bool { childExpr.Id = c.nextID c.nextID++ return true @@ -70,17 +70,17 @@ func (c *Cursor) Replace(newExpr *expr.Expr) { if c.sourceInfo.MacroCalls == nil { c.sourceInfo.MacroCalls = map[int64]*expr.Expr{} } - c.sourceInfo.MacroCalls[newExpr.Id] = &expr.Expr{Id: c.currExpr.Id, ExprKind: c.currExpr.ExprKind} - c.currExpr.Id = newExpr.Id - c.currExpr.ExprKind = newExpr.ExprKind + c.sourceInfo.MacroCalls[newExpr.GetId()] = &expr.Expr{Id: c.currExpr.GetId(), ExprKind: c.currExpr.GetExprKind()} + c.currExpr.Id = newExpr.GetId() + c.currExpr.ExprKind = newExpr.GetExprKind() c.replaced = true } func maxID(exp *expr.Expr) int64 { var max int64 - Walk(func(currExpr, parentExpr *expr.Expr) bool { - if exp.Id > max { - max = exp.Id + Walk(func(_, _ *expr.Expr) bool { + if exp.GetId() > max { + max = exp.GetId() } return true }, exp) diff --git a/filtering/macro_test.go b/filtering/macro_test.go index e79eaad02a..469848e444 100644 --- a/filtering/macro_test.go +++ b/filtering/macro_test.go @@ -31,21 +31,21 @@ func TestApplyMacros(t *testing.T) { if callExpr == nil { return } - if callExpr.Function != FunctionEquals { + if callExpr.GetFunction() != FunctionEquals { return } - if len(callExpr.Args) != 2 { + if len(callExpr.GetArgs()) != 2 { return } - arg0Select := callExpr.Args[0].GetSelectExpr() + arg0Select := callExpr.GetArgs()[0].GetSelectExpr() if arg0Select == nil || arg0Select.GetOperand().GetIdentExpr().GetName() != "annotations" { return } - arg1String := callExpr.Args[1].GetConstExpr().GetStringValue() + arg1String := callExpr.GetArgs()[1].GetConstExpr().GetStringValue() if arg1String == "" { return } - cursor.Replace(Has(arg0Select.Operand, String(arg0Select.Field+"="+arg1String))) + cursor.Replace(Has(arg0Select.GetOperand(), String(arg0Select.GetField()+"="+arg1String))) }, }, macroDeclarations: []DeclarationOption{ @@ -77,7 +77,7 @@ func TestApplyMacros(t *testing.T) { assert.DeepEqual( t, tt.expected, - actual.CheckedExpr.Expr, + actual.CheckedExpr.GetExpr(), protocmp.Transform(), protocmp.IgnoreFields(&expr.Expr{}, "id"), ) diff --git a/filtering/parser.go b/filtering/parser.go index d4c4cc9ffc..c1ca93b4d7 100644 --- a/filtering/parser.go +++ b/filtering/parser.go @@ -194,8 +194,8 @@ func (p *Parser) ParseTerm() (_ *expr.Expr, err error) { case not, minus: if minus { // Simplify MINUS number to negation of the constant value. - if constExpr, ok := simple.ExprKind.(*expr.Expr_ConstExpr); ok { - switch constantKind := constExpr.ConstExpr.ConstantKind.(type) { + if constExpr, ok := simple.GetExprKind().(*expr.Expr_ConstExpr); ok { + switch constantKind := constExpr.ConstExpr.GetConstantKind().(type) { case *expr.Constant_Int64Value: constantKind.Int64Value *= -1 return simple, nil @@ -266,7 +266,7 @@ func (p *Parser) ParseRestriction() (_ *expr.Expr, err error) { // Special case for `:` if comparatorToken.Type == TokenTypeHas && arg.GetIdentExpr() != nil { // m:foo - true if m contains the key "foo". - arg = parsedString(arg.Id, arg.GetIdentExpr().GetName()) + arg = parsedString(arg.GetId(), arg.GetIdentExpr().GetName()) } return parsedFunction(p.nextID(start), comparatorToken.Type.Function(), comp, arg), nil } diff --git a/filtering/parser_test.go b/filtering/parser_test.go index 3715078516..c571bed3d4 100644 --- a/filtering/parser_test.go +++ b/filtering/parser_test.go @@ -247,7 +247,7 @@ func TestParser(t *testing.T) { actual, err := parser.Parse() if tt.errorContains != "" { if actual != nil { - t.Log(actual.Expr.String()) + t.Log(actual.GetExpr().String()) } assert.ErrorContains(t, err, tt.errorContains) } else { @@ -255,11 +255,11 @@ func TestParser(t *testing.T) { assert.DeepEqual( t, tt.expected, - actual.Expr, + actual.GetExpr(), protocmp.Transform(), protocmp.IgnoreFields(&expr.Expr{}, "id"), ) - assertUniqueExprIDs(t, actual.Expr) + assertUniqueExprIDs(t, actual.GetExpr()) } }) } @@ -268,11 +268,11 @@ func TestParser(t *testing.T) { func assertUniqueExprIDs(t *testing.T, exp *expr.Expr) { t.Helper() seenIDs := make(map[int64]struct{}) - Walk(func(currExpr, parentExpr *expr.Expr) bool { - if _, ok := seenIDs[currExpr.Id]; ok { - t.Fatalf("duplicate expression ID '%d' for expr %v", currExpr.Id, currExpr) + Walk(func(currExpr, _ *expr.Expr) bool { + if _, ok := seenIDs[currExpr.GetId()]; ok { + t.Fatalf("duplicate expression ID '%d' for expr %v", currExpr.GetId(), currExpr) } - seenIDs[currExpr.Id] = struct{}{} + seenIDs[currExpr.GetId()] = struct{}{} return true }, exp) } diff --git a/filtering/request.go b/filtering/request.go index f7b02189a5..05f2558bcd 100644 --- a/filtering/request.go +++ b/filtering/request.go @@ -17,7 +17,7 @@ func ParseFilter(request Request, declarations *Declarations) (Filter, error) { return Filter{}, err } var checker Checker - checker.Init(parsedExpr.Expr, parsedExpr.SourceInfo, declarations) + checker.Init(parsedExpr.GetExpr(), parsedExpr.GetSourceInfo(), declarations) checkedExpr, err := checker.Check() if err != nil { return Filter{}, err diff --git a/filtering/walk.go b/filtering/walk.go index 59b8dca1d2..2f25ec1365 100644 --- a/filtering/walk.go +++ b/filtering/walk.go @@ -18,29 +18,29 @@ func walk(fn WalkFunc, currExpr, parentExpr *expr.Expr) { if ok := fn(currExpr, parentExpr); !ok { return } - switch v := currExpr.ExprKind.(type) { + switch v := currExpr.GetExprKind().(type) { case *expr.Expr_ConstExpr, *expr.Expr_IdentExpr: // Nothing to do here. case *expr.Expr_SelectExpr: - walk(fn, v.SelectExpr.Operand, currExpr) + walk(fn, v.SelectExpr.GetOperand(), currExpr) case *expr.Expr_CallExpr: - walk(fn, v.CallExpr.Target, currExpr) - for _, arg := range v.CallExpr.Args { + walk(fn, v.CallExpr.GetTarget(), currExpr) + for _, arg := range v.CallExpr.GetArgs() { walk(fn, arg, currExpr) } case *expr.Expr_ListExpr: - for _, el := range v.ListExpr.Elements { + for _, el := range v.ListExpr.GetElements() { walk(fn, el, currExpr) } case *expr.Expr_StructExpr: - for _, entry := range v.StructExpr.Entries { - walk(fn, entry.Value, currExpr) + for _, entry := range v.StructExpr.GetEntries() { + walk(fn, entry.GetValue(), currExpr) } case *expr.Expr_ComprehensionExpr: - walk(fn, v.ComprehensionExpr.IterRange, currExpr) - walk(fn, v.ComprehensionExpr.AccuInit, currExpr) - walk(fn, v.ComprehensionExpr.LoopCondition, currExpr) - walk(fn, v.ComprehensionExpr.LoopStep, currExpr) - walk(fn, v.ComprehensionExpr.Result, currExpr) + walk(fn, v.ComprehensionExpr.GetIterRange(), currExpr) + walk(fn, v.ComprehensionExpr.GetAccuInit(), currExpr) + walk(fn, v.ComprehensionExpr.GetLoopCondition(), currExpr) + walk(fn, v.ComprehensionExpr.GetLoopStep(), currExpr) + walk(fn, v.ComprehensionExpr.GetResult(), currExpr) } } diff --git a/reflect/aipreflect/resources.go b/reflect/aipreflect/resources.go index 26a86df254..82de85285d 100644 --- a/reflect/aipreflect/resources.go +++ b/reflect/aipreflect/resources.go @@ -80,7 +80,7 @@ func RangeParentResourcesInPackage( } var stop bool RangeResourceDescriptorsInPackage(registry, packageName, func(resource *annotations.ResourceDescriptor) bool { - for _, candidatePattern := range resource.Pattern { + for _, candidatePattern := range resource.GetPattern() { if candidatePattern == parent { if !fn(resource) { stop = true diff --git a/reflect/aipreflect/validateresourcereferences.go b/reflect/aipreflect/validateresourcereferences.go index c287dc5458..dc071732cf 100644 --- a/reflect/aipreflect/validateresourcereferences.go +++ b/reflect/aipreflect/validateresourcereferences.go @@ -50,10 +50,10 @@ func ValidateResourceReferences(message proto.Message) error { protoregistry.GlobalFiles, field.ParentFile().Package(), func(resource *annotations.ResourceDescriptor) bool { - if resource.Type != resourceReferenceAnnotation.GetType() { + if resource.GetType() != resourceReferenceAnnotation.GetType() { return true } - for _, pattern := range resource.Pattern { + for _, pattern := range resource.GetPattern() { if resourcename.Match(pattern, fieldValue) { return false } diff --git a/validation/error.go b/validation/error.go index 01ecf2e901..39c0e686a2 100644 --- a/validation/error.go +++ b/validation/error.go @@ -31,7 +31,7 @@ func (e *Error) GRPCStatus() *status.Status { if e.grpcStatus == nil { var fields strings.Builder for i, fieldViolation := range e.fieldViolations { - _, _ = fields.WriteString(fieldViolation.Field) + _, _ = fields.WriteString(fieldViolation.GetField()) if i < len(e.fieldViolations)-1 { _, _ = fields.WriteString(", ") } @@ -54,14 +54,14 @@ func (e *Error) Error() string { if len(e.fieldViolations) == 1 { e.str = fmt.Sprintf( "field violation on %s: %s", - e.fieldViolations[0].Field, - e.fieldViolations[0].Description, + e.fieldViolations[0].GetField(), + e.fieldViolations[0].GetDescription(), ) } else { var result strings.Builder _, _ = result.WriteString("field violation on multiple fields:\n") for i, fieldViolation := range e.fieldViolations { - _, _ = result.WriteString(fmt.Sprintf(" | %s: %s", fieldViolation.Field, fieldViolation.Description)) + _, _ = result.WriteString(fmt.Sprintf(" | %s: %s", fieldViolation.GetField(), fieldViolation.GetDescription())) if i < len(e.fieldViolations)-1 { _ = result.WriteByte('\n') } diff --git a/validation/error_test.go b/validation/error_test.go index f165ea360a..2e44e88c06 100644 --- a/validation/error_test.go +++ b/validation/error_test.go @@ -40,7 +40,7 @@ func TestError_GRPCStatus(t *testing.T) { {Field: "baz", Description: "test2"}, }, } - s := status.Convert(NewError(expected.FieldViolations)) + s := status.Convert(NewError(expected.GetFieldViolations())) assert.Equal(t, codes.InvalidArgument, s.Code()) assert.Equal(t, "invalid fields: foo.bar, baz", s.Message()) details := s.Details() diff --git a/validation/messagevalidator.go b/validation/messagevalidator.go index 1433a39f26..e3add2c6fc 100644 --- a/validation/messagevalidator.go +++ b/validation/messagevalidator.go @@ -42,7 +42,7 @@ func (m *MessageValidator) AddFieldError(field string, err error) { originalParentField := m.parentField m.parentField = makeFieldWithParent(m.parentField, field) for _, fieldViolation := range errValidation.fieldViolations { - m.AddFieldViolation(fieldViolation.Field, fieldViolation.Description) + m.AddFieldViolation(fieldViolation.GetField(), fieldViolation.GetDescription()) } m.parentField = originalParentField } else {