From 4a703d6cbcf562106126fc4936e68575871ce55a Mon Sep 17 00:00:00 2001 From: Kermit Alexander II Date: Mon, 22 Aug 2022 16:59:14 +0000 Subject: [PATCH 1/3] Run pin-dependency.sh and update-vendor.sh. --- go.mod | 4 +- go.sum | 4 +- .../src/k8s.io/apiextensions-apiserver/go.mod | 2 +- .../src/k8s.io/apiextensions-apiserver/go.sum | 4 +- .../google/cel-go/checker/checker.go | 65 +++++++++---------- .../github.com/google/cel-go/checker/cost.go | 42 +++++++++--- .../google/cel-go/checker/printer.go | 8 +-- .../github.com/google/cel-go/checker/types.go | 36 +++++----- .../cel-go/common/containers/container.go | 56 ++++++++-------- .../google/cel-go/common/debug/debug.go | 42 ++++++------ .../cel-go/interpreter/interpretable.go | 4 +- .../google/cel-go/interpreter/planner.go | 57 ++++++++-------- .../google/cel-go/interpreter/prune.go | 18 +++-- .../github.com/google/cel-go/parser/helper.go | 2 +- .../github.com/google/cel-go/parser/parser.go | 6 +- .../google/cel-go/parser/unparser.go | 4 +- vendor/modules.txt | 4 +- 17 files changed, 192 insertions(+), 166 deletions(-) diff --git a/go.mod b/go.mod index 2406b3da679..8ed4bd5ee6c 100644 --- a/go.mod +++ b/go.mod @@ -176,7 +176,7 @@ require ( github.com/gofrs/uuid v4.0.0+incompatible // indirect github.com/golang-jwt/jwt/v4 v4.2.0 // indirect github.com/google/btree v1.0.1 // indirect - github.com/google/cel-go v0.12.4 // indirect + github.com/google/cel-go v0.12.5 // indirect github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect github.com/googleapis/gax-go/v2 v2.1.1 // indirect @@ -388,7 +388,7 @@ replace ( github.com/golangplus/testing => github.com/golangplus/testing v1.0.0 github.com/google/btree => github.com/google/btree v1.0.1 github.com/google/cadvisor => github.com/google/cadvisor v0.45.0 - github.com/google/cel-go => github.com/google/cel-go v0.12.4 + github.com/google/cel-go => github.com/google/cel-go v0.12.5 github.com/google/gnostic => github.com/google/gnostic v0.5.7-v3refs github.com/google/go-cmp => github.com/google/go-cmp v0.5.6 github.com/google/gofuzz => github.com/google/gofuzz v1.1.0 diff --git a/go.sum b/go.sum index f046333e69a..4efd4a6be58 100644 --- a/go.sum +++ b/go.sum @@ -215,8 +215,8 @@ github.com/google/btree v1.0.1 h1:gK4Kx5IaGY9CD5sPJ36FHiBJ6ZXl0kilRiiCj+jdYp4= github.com/google/btree v1.0.1/go.mod h1:xXMiIv4Fb/0kKde4SpL7qlzvu5cMJDRkFDxJfI9uaxA= github.com/google/cadvisor v0.45.0 h1:bXQze1sd8srZiQwiQ19Qaq/AoMIZS8YceBXrIaEvkX0= github.com/google/cadvisor v0.45.0/go.mod h1:vsMT3Uv2XjQ8M7WUtKARV74mU/HN64C4XtM1bJhUKcU= -github.com/google/cel-go v0.12.4 h1:YINKfuHZ8n72tPOqSPZBwGiDpew2CJS48mdM5W8LZQU= -github.com/google/cel-go v0.12.4/go.mod h1:Av7CU6r6X3YmcHR9GXqVDaEJYfEtSxl6wvIjUQTriCw= +github.com/google/cel-go v0.12.5 h1:DmzaiSgoaqGCjtpPQWl26/gND+yRpim56H1jCVev6d8= +github.com/google/cel-go v0.12.5/go.mod h1:Jk7ljRzLBhkmiAwBoUxB1sZSCVBAzkqPF25olK/iRDw= github.com/google/gnostic v0.5.7-v3refs h1:FhTMOKj2VhjpouxvWJAV1TL304uMlb9zcDqkl6cEI54= github.com/google/gnostic v0.5.7-v3refs/go.mod h1:73MKFl6jIHelAJNaBGFzt3SPtZULs9dYrGFt8OiIsHQ= github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= diff --git a/staging/src/k8s.io/apiextensions-apiserver/go.mod b/staging/src/k8s.io/apiextensions-apiserver/go.mod index 64765d140e3..7eeb4263d49 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/go.mod +++ b/staging/src/k8s.io/apiextensions-apiserver/go.mod @@ -7,7 +7,7 @@ go 1.19 require ( github.com/emicklei/go-restful/v3 v3.8.0 github.com/gogo/protobuf v1.3.2 - github.com/google/cel-go v0.12.4 + github.com/google/cel-go v0.12.5 github.com/google/gnostic v0.5.7-v3refs github.com/google/go-cmp v0.5.6 github.com/google/gofuzz v1.1.0 diff --git a/staging/src/k8s.io/apiextensions-apiserver/go.sum b/staging/src/k8s.io/apiextensions-apiserver/go.sum index 7af68c6924f..bc65b8b14e9 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/go.sum +++ b/staging/src/k8s.io/apiextensions-apiserver/go.sum @@ -198,8 +198,8 @@ github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Z github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.1 h1:gK4Kx5IaGY9CD5sPJ36FHiBJ6ZXl0kilRiiCj+jdYp4= github.com/google/btree v1.0.1/go.mod h1:xXMiIv4Fb/0kKde4SpL7qlzvu5cMJDRkFDxJfI9uaxA= -github.com/google/cel-go v0.12.4 h1:YINKfuHZ8n72tPOqSPZBwGiDpew2CJS48mdM5W8LZQU= -github.com/google/cel-go v0.12.4/go.mod h1:Av7CU6r6X3YmcHR9GXqVDaEJYfEtSxl6wvIjUQTriCw= +github.com/google/cel-go v0.12.5 h1:DmzaiSgoaqGCjtpPQWl26/gND+yRpim56H1jCVev6d8= +github.com/google/cel-go v0.12.5/go.mod h1:Jk7ljRzLBhkmiAwBoUxB1sZSCVBAzkqPF25olK/iRDw= github.com/google/gnostic v0.5.7-v3refs h1:FhTMOKj2VhjpouxvWJAV1TL304uMlb9zcDqkl6cEI54= github.com/google/gnostic v0.5.7-v3refs/go.mod h1:73MKFl6jIHelAJNaBGFzt3SPtZULs9dYrGFt8OiIsHQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= diff --git a/vendor/github.com/google/cel-go/checker/checker.go b/vendor/github.com/google/cel-go/checker/checker.go index 6e45789a298..fcddb1b2c28 100644 --- a/vendor/github.com/google/cel-go/checker/checker.go +++ b/vendor/github.com/google/cel-go/checker/checker.go @@ -80,10 +80,10 @@ func (c *checker) check(e *exprpb.Expr) { return } - switch e.ExprKind.(type) { + switch e.GetExprKind().(type) { case *exprpb.Expr_ConstExpr: literal := e.GetConstExpr() - switch literal.ConstantKind.(type) { + switch literal.GetConstantKind().(type) { case *exprpb.Constant_BoolValue: c.checkBoolLiteral(e) case *exprpb.Constant_BytesValue: @@ -149,8 +149,8 @@ func (c *checker) checkIdent(e *exprpb.Expr) { identExpr := e.GetIdentExpr() // Check to see if the identifier is declared. if ident := c.env.LookupIdent(identExpr.GetName()); ident != nil { - c.setType(e, ident.GetIdent().Type) - c.setReference(e, newIdentReference(ident.GetName(), ident.GetIdent().Value)) + c.setType(e, ident.GetIdent().GetType()) + c.setReference(e, newIdentReference(ident.GetName(), ident.GetIdent().GetValue())) // Overwrite the identifier with its fully qualified name. identExpr.Name = ident.GetName() return @@ -186,23 +186,20 @@ func (c *checker) checkSelect(e *exprpb.Expr) { } // Interpret as field selection, first traversing down the operand. - c.check(sel.Operand) - targetType := substitute(c.mappings, c.getType(sel.Operand), false) + c.check(sel.GetOperand()) + targetType := substitute(c.mappings, c.getType(sel.GetOperand()), false) // Assume error type by default as most types do not support field selection. resultType := decls.Error switch kindOf(targetType) { case kindMap: // Maps yield their value type as the selection result type. mapType := targetType.GetMapType() - resultType = mapType.ValueType + resultType = mapType.GetValueType() case kindObject: // Objects yield their field type declaration as the selection result type, but only if // the field is defined. messageType := targetType - if fieldType, found := c.lookupFieldType( - c.location(e), - messageType.GetMessageType(), - sel.Field); found { + if fieldType, found := c.lookupFieldType(c.location(e), messageType.GetMessageType(), sel.GetField()); found { resultType = fieldType.Type } case kindTypeParam: @@ -320,15 +317,15 @@ func (c *checker) resolveOverload( var resultType *exprpb.Type var checkedRef *exprpb.Reference - for _, overload := range fn.GetFunction().Overloads { + for _, overload := range fn.GetFunction().GetOverloads() { // Determine whether the overload is currently considered. if c.env.isOverloadDisabled(overload.GetOverloadId()) { continue } // Ensure the call style for the overload matches. - if (target == nil && overload.IsInstanceFunction) || - (target != nil && !overload.IsInstanceFunction) { + if (target == nil && overload.GetIsInstanceFunction()) || + (target != nil && !overload.GetIsInstanceFunction()) { // not a compatible call style. continue } @@ -348,13 +345,11 @@ func (c *checker) resolveOverload( if checkedRef == nil { checkedRef = newFunctionReference(overload.GetOverloadId()) } else { - checkedRef.OverloadId = append(checkedRef.OverloadId, overload.GetOverloadId()) + checkedRef.OverloadId = append(checkedRef.GetOverloadId(), overload.GetOverloadId()) } // First matching overload, determines result type. - fnResultType := substitute(c.mappings, - overloadType.GetFunction().GetResultType(), - false) + fnResultType := substitute(c.mappings, overloadType.GetFunction().GetResultType(), false) if resultType == nil { resultType = fnResultType } else if !isDyn(resultType) && !proto.Equal(fnResultType, resultType) { @@ -375,7 +370,7 @@ func (c *checker) resolveOverload( func (c *checker) checkCreateList(e *exprpb.Expr) { create := e.GetListExpr() var elemType *exprpb.Type - for _, e := range create.Elements { + for _, e := range create.GetElements() { c.check(e) elemType = c.joinTypes(c.location(e), elemType, c.getType(e)) } @@ -388,7 +383,7 @@ func (c *checker) checkCreateList(e *exprpb.Expr) { func (c *checker) checkCreateStruct(e *exprpb.Expr) { str := e.GetStructExpr() - if str.MessageName != "" { + if str.GetMessageName() != "" { c.checkCreateMessage(e) } else { c.checkCreateMap(e) @@ -419,22 +414,22 @@ func (c *checker) checkCreateMessage(e *exprpb.Expr) { msgVal := e.GetStructExpr() // Determine the type of the message. messageType := decls.Error - decl := c.env.LookupIdent(msgVal.MessageName) + decl := c.env.LookupIdent(msgVal.GetMessageName()) if decl == nil { c.errors.undeclaredReference( - c.location(e), c.env.container.Name(), msgVal.MessageName) + c.location(e), c.env.container.Name(), msgVal.GetMessageName()) return } // Ensure the type name is fully qualified in the AST. msgVal.MessageName = decl.GetName() c.setReference(e, newIdentReference(decl.GetName(), nil)) ident := decl.GetIdent() - identKind := kindOf(ident.Type) + identKind := kindOf(ident.GetType()) if identKind != kindError { if identKind != kindType { - c.errors.notAType(c.location(e), ident.Type) + c.errors.notAType(c.location(e), ident.GetType()) } else { - messageType = ident.Type.GetType() + messageType = ident.GetType().GetType() if kindOf(messageType) != kindObject { c.errors.notAMessageType(c.location(e), messageType) messageType = decls.Error @@ -450,12 +445,12 @@ func (c *checker) checkCreateMessage(e *exprpb.Expr) { // Check the field initializers. for _, ent := range msgVal.GetEntries() { field := ent.GetFieldKey() - value := ent.Value + value := ent.GetValue() c.check(value) fieldType := decls.Error if t, found := c.lookupFieldType( - c.locationByID(ent.Id), + c.locationByID(ent.GetId()), messageType.GetMessageType(), field); found { fieldType = t.Type @@ -576,25 +571,25 @@ func (c *checker) lookupFieldType(l common.Location, messageType string, fieldNa } func (c *checker) setType(e *exprpb.Expr, t *exprpb.Type) { - if old, found := c.types[e.Id]; found && !proto.Equal(old, t) { + if old, found := c.types[e.GetId()]; found && !proto.Equal(old, t) { c.errors.ReportError(c.location(e), "(Incompatible) Type already exists for expression: %v(%d) old:%v, new:%v", e, e.GetId(), old, t) return } - c.types[e.Id] = t + c.types[e.GetId()] = t } func (c *checker) getType(e *exprpb.Expr) *exprpb.Type { - return c.types[e.Id] + return c.types[e.GetId()] } func (c *checker) setReference(e *exprpb.Expr, r *exprpb.Reference) { - if old, found := c.references[e.Id]; found && !proto.Equal(old, r) { + if old, found := c.references[e.GetId()]; found && !proto.Equal(old, r) { c.errors.ReportError(c.location(e), - "Reference already exists for expression: %v(%d) old:%v, new:%v", e, e.Id, old, r) + "Reference already exists for expression: %v(%d) old:%v, new:%v", e, e.GetId(), old, r) return } - c.references[e.Id] = r + c.references[e.GetId()] = r } func (c *checker) assertType(e *exprpb.Expr, t *exprpb.Type) { @@ -616,7 +611,7 @@ func newResolution(checkedRef *exprpb.Reference, t *exprpb.Type) *overloadResolu } func (c *checker) location(e *exprpb.Expr) common.Location { - return c.locationByID(e.Id) + return c.locationByID(e.GetId()) } func (c *checker) locationByID(id int64) common.Location { @@ -624,7 +619,7 @@ func (c *checker) locationByID(id int64) common.Location { var line = 1 if offset, found := positions[id]; found { col := int(offset) - for _, lineOffset := range c.sourceInfo.LineOffsets { + for _, lineOffset := range c.sourceInfo.GetLineOffsets() { if lineOffset < offset { line++ col = int(offset - lineOffset) diff --git a/vendor/github.com/google/cel-go/checker/cost.go b/vendor/github.com/google/cel-go/checker/cost.go index 75142ebc19d..7312d1fe2f8 100644 --- a/vendor/github.com/google/cel-go/checker/cost.go +++ b/vendor/github.com/google/cel-go/checker/cost.go @@ -88,9 +88,9 @@ func (e astNode) ComputedSize() *SizeEstimate { return e.derivedSize } var v uint64 - switch ek := e.expr.ExprKind.(type) { + switch ek := e.expr.GetExprKind().(type) { case *exprpb.Expr_ConstExpr: - switch ck := ek.ConstExpr.ConstantKind.(type) { + switch ck := ek.ConstExpr.GetConstantKind().(type) { case *exprpb.Constant_StringValue: v = uint64(len(ck.StringValue)) case *exprpb.Constant_BytesValue: @@ -103,10 +103,10 @@ func (e astNode) ComputedSize() *SizeEstimate { return nil } case *exprpb.Expr_ListExpr: - v = uint64(len(ek.ListExpr.Elements)) + v = uint64(len(ek.ListExpr.GetElements())) case *exprpb.Expr_StructExpr: - if ek.StructExpr.MessageName == "" { - v = uint64(len(ek.StructExpr.Entries)) + if ek.StructExpr.GetMessageName() == "" { + v = uint64(len(ek.StructExpr.GetEntries())) } default: return nil @@ -297,7 +297,7 @@ func (c *coster) cost(e *exprpb.Expr) CostEstimate { return CostEstimate{} } var cost CostEstimate - switch e.ExprKind.(type) { + switch e.GetExprKind().(type) { case *exprpb.Expr_ConstExpr: cost = constCost case *exprpb.Expr_IdentExpr: @@ -323,7 +323,7 @@ func (c *coster) costIdent(e *exprpb.Expr) CostEstimate { // build and track the field path if iterRange, ok := c.iterRanges.peek(identExpr.GetName()); ok { - switch c.checkedExpr.TypeMap[iterRange].TypeKind.(type) { + switch c.checkedExpr.TypeMap[iterRange].GetTypeKind().(type) { case *exprpb.Type_ListType_: c.addPath(e, append(c.exprPath[iterRange], "@items")) case *exprpb.Type_MapType_: @@ -350,7 +350,7 @@ func (c *coster) costSelect(e *exprpb.Expr) CostEstimate { } // build and track the field path - c.addPath(e, append(c.getPath(sel.GetOperand()), sel.Field)) + c.addPath(e, append(c.getPath(sel.GetOperand()), sel.GetField())) return sum } @@ -476,6 +476,15 @@ func (c *coster) sizeEstimate(t AstNode) SizeEstimate { if l := c.estimator.EstimateSize(t); l != nil { return *l } + // return an estimate of 1 for return types of set + // lengths, since strings/bytes/more complex objects could be of + // variable length + if isScalar(t.Type()) { + // TODO: since the logic for size estimation is split between + // ComputedSize and isScalar, changing one will likely require changing + // the other, so they should be merged in the future if possible + return SizeEstimate{Min: 1, Max: 1} + } return SizeEstimate{Min: 0, Max: math.MaxUint64} } @@ -599,3 +608,20 @@ func (c *coster) newAstNode(e *exprpb.Expr) *astNode { } return &astNode{path: path, t: c.getType(e), expr: e, derivedSize: derivedSize} } + +// isScalar returns true if the given type is known to be of a constant size at +// compile time. isScalar will return false for strings (they are variable-width) +// in addition to protobuf.Any and protobuf.Value (their size is not knowable at compile time). +func isScalar(t *exprpb.Type) bool { + switch kindOf(t) { + case kindPrimitive: + if t.GetPrimitive() != exprpb.Type_STRING && t.GetPrimitive() != exprpb.Type_BYTES { + return true + } + case kindWellKnown: + if t.GetWellKnown() == exprpb.Type_DURATION || t.GetWellKnown() == exprpb.Type_TIMESTAMP { + return true + } + } + return false +} diff --git a/vendor/github.com/google/cel-go/checker/printer.go b/vendor/github.com/google/cel-go/checker/printer.go index 15c25ecc686..e2ed35be834 100644 --- a/vendor/github.com/google/cel-go/checker/printer.go +++ b/vendor/github.com/google/cel-go/checker/printer.go @@ -32,22 +32,22 @@ func (a *semanticAdorner) GetMetadata(elem interface{}) string { if !isExpr { return result } - t := a.checks.TypeMap[e.Id] + t := a.checks.TypeMap[e.GetId()] if t != nil { result += "~" result += FormatCheckedType(t) } - switch e.ExprKind.(type) { + switch e.GetExprKind().(type) { case *exprpb.Expr_IdentExpr, *exprpb.Expr_CallExpr, *exprpb.Expr_StructExpr, *exprpb.Expr_SelectExpr: - if ref, found := a.checks.ReferenceMap[e.Id]; found { + if ref, found := a.checks.ReferenceMap[e.GetId()]; found { if len(ref.GetOverloadId()) == 0 { result += "^" + ref.Name } else { - for i, overload := range ref.OverloadId { + for i, overload := range ref.GetOverloadId() { if i == 0 { result += "^" } else { diff --git a/vendor/github.com/google/cel-go/checker/types.go b/vendor/github.com/google/cel-go/checker/types.go index cd34167979f..8683797d5bb 100644 --- a/vendor/github.com/google/cel-go/checker/types.go +++ b/vendor/github.com/google/cel-go/checker/types.go @@ -52,13 +52,13 @@ func FormatCheckedType(t *exprpb.Type) string { t.GetFunction().GetArgTypes(), false) case kindList: - return fmt.Sprintf("list(%s)", FormatCheckedType(t.GetListType().ElemType)) + return fmt.Sprintf("list(%s)", FormatCheckedType(t.GetListType().GetElemType())) case kindObject: return t.GetMessageType() case kindMap: return fmt.Sprintf("map(%s, %s)", - FormatCheckedType(t.GetMapType().KeyType), - FormatCheckedType(t.GetMapType().ValueType)) + FormatCheckedType(t.GetMapType().GetKeyType()), + FormatCheckedType(t.GetMapType().GetValueType())) case kindNull: return "null" case kindPrimitive: @@ -152,12 +152,12 @@ func isEqualOrLessSpecific(t1 *exprpb.Type, t2 *exprpb.Type) bool { } return true case kindList: - return isEqualOrLessSpecific(t1.GetListType().ElemType, t2.GetListType().ElemType) + return isEqualOrLessSpecific(t1.GetListType().GetElemType(), t2.GetListType().GetElemType()) case kindMap: m1 := t1.GetMapType() m2 := t2.GetMapType() - return isEqualOrLessSpecific(m1.KeyType, m2.KeyType) && - isEqualOrLessSpecific(m1.ValueType, m2.ValueType) + return isEqualOrLessSpecific(m1.GetKeyType(), m2.GetKeyType()) && + isEqualOrLessSpecific(m1.GetValueType(), m2.GetValueType()) case kindType: return true default: @@ -165,7 +165,7 @@ func isEqualOrLessSpecific(t1 *exprpb.Type, t2 *exprpb.Type) bool { } } -/// internalIsAssignable returns true if t1 is assignable to t2. +// / internalIsAssignable returns true if t1 is assignable to t2. func internalIsAssignable(m *mapping, t1 *exprpb.Type, t2 *exprpb.Type) bool { // Process type parameters. kind1, kind2 := kindOf(t1), kindOf(t2) @@ -272,18 +272,14 @@ func isValidTypeSubstitution(m *mapping, t1, t2 *exprpb.Type) (valid, hasSub boo // internalIsAssignableAbstractType returns true if the abstract type names agree and all type // parameters are assignable. -func internalIsAssignableAbstractType(m *mapping, - a1 *exprpb.Type_AbstractType, - a2 *exprpb.Type_AbstractType) bool { +func internalIsAssignableAbstractType(m *mapping, a1 *exprpb.Type_AbstractType, a2 *exprpb.Type_AbstractType) bool { return a1.GetName() == a2.GetName() && internalIsAssignableList(m, a1.GetParameterTypes(), a2.GetParameterTypes()) } // internalIsAssignableFunction returns true if the function return type and arg types are // assignable. -func internalIsAssignableFunction(m *mapping, - f1 *exprpb.Type_FunctionType, - f2 *exprpb.Type_FunctionType) bool { +func internalIsAssignableFunction(m *mapping, f1 *exprpb.Type_FunctionType, f2 *exprpb.Type_FunctionType) bool { f1ArgTypes := flattenFunctionTypes(f1) f2ArgTypes := flattenFunctionTypes(f2) if internalIsAssignableList(m, f1ArgTypes, f2ArgTypes) { @@ -363,7 +359,7 @@ func kindOf(t *exprpb.Type) int { if t == nil || t.TypeKind == nil { return kindUnknown } - switch t.TypeKind.(type) { + switch t.GetTypeKind().(type) { case *exprpb.Type_Error: return kindError case *exprpb.Type_Function: @@ -425,10 +421,10 @@ func notReferencedIn(m *mapping, t *exprpb.Type, withinType *exprpb.Type) bool { } return true case kindList: - return notReferencedIn(m, t, withinType.GetListType().ElemType) + return notReferencedIn(m, t, withinType.GetListType().GetElemType()) case kindMap: mt := withinType.GetMapType() - return notReferencedIn(m, t, mt.KeyType) && notReferencedIn(m, t, mt.ValueType) + return notReferencedIn(m, t, mt.GetKeyType()) && notReferencedIn(m, t, mt.GetValueType()) case kindWrapper: return notReferencedIn(m, t, decls.NewPrimitiveType(withinType.GetWrapper())) default: @@ -457,17 +453,17 @@ func substitute(m *mapping, t *exprpb.Type, typeParamToDyn bool) *exprpb.Type { case kindFunction: fn := t.GetFunction() rt := substitute(m, fn.ResultType, typeParamToDyn) - args := make([]*exprpb.Type, len(fn.ArgTypes)) + args := make([]*exprpb.Type, len(fn.GetArgTypes())) for i, a := range fn.ArgTypes { args[i] = substitute(m, a, typeParamToDyn) } return decls.NewFunctionType(rt, args...) case kindList: - return decls.NewListType(substitute(m, t.GetListType().ElemType, typeParamToDyn)) + return decls.NewListType(substitute(m, t.GetListType().GetElemType(), typeParamToDyn)) case kindMap: mt := t.GetMapType() - return decls.NewMapType(substitute(m, mt.KeyType, typeParamToDyn), - substitute(m, mt.ValueType, typeParamToDyn)) + return decls.NewMapType(substitute(m, mt.GetKeyType(), typeParamToDyn), + substitute(m, mt.GetValueType(), typeParamToDyn)) case kindType: if t.GetType() != nil { return decls.NewTypeType(substitute(m, t.GetType(), typeParamToDyn)) diff --git a/vendor/github.com/google/cel-go/common/containers/container.go b/vendor/github.com/google/cel-go/common/containers/container.go index 07ae72c81be..d46698d3cdf 100644 --- a/vendor/github.com/google/cel-go/common/containers/container.go +++ b/vendor/github.com/google/cel-go/common/containers/container.go @@ -98,12 +98,12 @@ func (c *Container) Name() string { // // Given a container name a.b.c.M.N and a type name R.s, this will deliver in order: // -// a.b.c.M.N.R.s -// a.b.c.M.R.s -// a.b.c.R.s -// a.b.R.s -// a.R.s -// R.s +// a.b.c.M.N.R.s +// a.b.c.M.R.s +// a.b.c.R.s +// a.b.R.s +// a.R.s +// R.s // // If aliases or abbreviations are configured for the container, then alias names will take // precedence over containerized names. @@ -145,9 +145,9 @@ func (c *Container) aliasSet() map[string]string { // If the name is qualified, the first component of the qualified name is checked against known // aliases. Any alias that is found in a qualified name is expanded in the result: // -// alias: R -> my.alias.R -// name: R.S.T -// output: my.alias.R.S.T +// alias: R -> my.alias.R +// name: R.S.T +// output: my.alias.R.S.T // // Note, the name must not have a leading dot. func (c *Container) findAlias(name string) (string, bool) { @@ -177,19 +177,19 @@ type ContainerOption func(*Container) (*Container, error) // Abbreviations can be useful when working with variables, functions, and especially types from // multiple namespaces: // -// // CEL object construction -// qual.pkg.version.ObjTypeName{ -// field: alt.container.ver.FieldTypeName{value: ...} -// } +// // CEL object construction +// qual.pkg.version.ObjTypeName{ +// field: alt.container.ver.FieldTypeName{value: ...} +// } // // Only one the qualified names above may be used as the CEL container, so at least one of these // references must be a long qualified name within an otherwise short CEL program. Using the // following abbreviations, the program becomes much simpler: // -// // CEL Go option -// Abbrevs("qual.pkg.version.ObjTypeName", "alt.container.ver.FieldTypeName") -// // Simplified Object construction -// ObjTypeName{field: FieldTypeName{value: ...}} +// // CEL Go option +// Abbrevs("qual.pkg.version.ObjTypeName", "alt.container.ver.FieldTypeName") +// // Simplified Object construction +// ObjTypeName{field: FieldTypeName{value: ...}} // // There are a few rules for the qualified names and the simple abbreviations generated from them: // - Qualified names must be dot-delimited, e.g. `package.subpkg.name`. @@ -198,13 +198,13 @@ type ContainerOption func(*Container) (*Container, error) // - The abbreviation must not collide with unqualified names in use. // // Abbreviations are distinct from container-based references in the following important ways: -// - Abbreviations must expand to a fully-qualified name. -// - Expanded abbreviations do not participate in namespace resolution. -// - Abbreviation expansion is done instead of the container search for a matching identifier. -// - Containers follow C++ namespace resolution rules with searches from the most qualified name -// to the least qualified name. -// - Container references within the CEL program may be relative, and are resolved to fully -// qualified names at either type-check time or program plan time, whichever comes first. +// - Abbreviations must expand to a fully-qualified name. +// - Expanded abbreviations do not participate in namespace resolution. +// - Abbreviation expansion is done instead of the container search for a matching identifier. +// - Containers follow C++ namespace resolution rules with searches from the most qualified name +// to the least qualified name. +// - Container references within the CEL program may be relative, and are resolved to fully +// qualified names at either type-check time or program plan time, whichever comes first. // // If there is ever a case where an identifier could be in both the container and as an // abbreviation, the abbreviation wins as this will ensure that the meaning of a program is @@ -298,18 +298,18 @@ func Name(name string) ContainerOption { // ToQualifiedName converts an expression AST into a qualified name if possible, with a boolean // 'found' value that indicates if the conversion is successful. func ToQualifiedName(e *exprpb.Expr) (string, bool) { - switch e.ExprKind.(type) { + switch e.GetExprKind().(type) { case *exprpb.Expr_IdentExpr: id := e.GetIdentExpr() - return id.Name, true + return id.GetName(), true case *exprpb.Expr_SelectExpr: sel := e.GetSelectExpr() // Test only expressions are not valid as qualified names. if sel.GetTestOnly() { return "", false } - if qual, found := ToQualifiedName(sel.Operand); found { - return qual + "." + sel.Field, true + if qual, found := ToQualifiedName(sel.GetOperand()); found { + return qual + "." + sel.GetField(), true } } return "", false diff --git a/vendor/github.com/google/cel-go/common/debug/debug.go b/vendor/github.com/google/cel-go/common/debug/debug.go index 5a4894733d4..bec885424b1 100644 --- a/vendor/github.com/google/cel-go/common/debug/debug.go +++ b/vendor/github.com/google/cel-go/common/debug/debug.go @@ -102,9 +102,9 @@ func (w *debugWriter) Buffer(e *exprpb.Expr) { } func (w *debugWriter) appendSelect(sel *exprpb.Expr_Select) { - w.Buffer(sel.Operand) + w.Buffer(sel.GetOperand()) w.append(".") - w.append(sel.Field) + w.append(sel.GetField()) if sel.TestOnly { w.append("~test-only~") } @@ -112,15 +112,15 @@ func (w *debugWriter) appendSelect(sel *exprpb.Expr_Select) { func (w *debugWriter) appendCall(call *exprpb.Expr_Call) { if call.Target != nil { - w.Buffer(call.Target) + w.Buffer(call.GetTarget()) w.append(".") } - w.append(call.Function) + w.append(call.GetFunction()) w.append("(") if len(call.GetArgs()) > 0 { w.addIndent() w.appendLine() - for i, arg := range call.Args { + for i, arg := range call.GetArgs() { if i > 0 { w.append(",") w.appendLine() @@ -138,7 +138,7 @@ func (w *debugWriter) appendList(list *exprpb.Expr_CreateList) { if len(list.GetElements()) > 0 { w.appendLine() w.addIndent() - for i, elem := range list.Elements { + for i, elem := range list.GetElements() { if i > 0 { w.append(",") w.appendLine() @@ -160,19 +160,19 @@ func (w *debugWriter) appendStruct(obj *exprpb.Expr_CreateStruct) { } func (w *debugWriter) appendObject(obj *exprpb.Expr_CreateStruct) { - w.append(obj.MessageName) + w.append(obj.GetMessageName()) w.append("{") - if len(obj.Entries) > 0 { + if len(obj.GetEntries()) > 0 { w.appendLine() w.addIndent() - for i, entry := range obj.Entries { + for i, entry := range obj.GetEntries() { if i > 0 { w.append(",") w.appendLine() } w.append(entry.GetFieldKey()) w.append(":") - w.Buffer(entry.Value) + w.Buffer(entry.GetValue()) w.adorn(entry) } w.removeIndent() @@ -183,17 +183,17 @@ func (w *debugWriter) appendObject(obj *exprpb.Expr_CreateStruct) { func (w *debugWriter) appendMap(obj *exprpb.Expr_CreateStruct) { w.append("{") - if len(obj.Entries) > 0 { + if len(obj.GetEntries()) > 0 { w.appendLine() w.addIndent() - for i, entry := range obj.Entries { + for i, entry := range obj.GetEntries() { if i > 0 { w.append(",") w.appendLine() } w.Buffer(entry.GetMapKey()) w.append(":") - w.Buffer(entry.Value) + w.Buffer(entry.GetValue()) w.adorn(entry) } w.removeIndent() @@ -208,43 +208,43 @@ func (w *debugWriter) appendComprehension(comprehension *exprpb.Expr_Comprehensi w.appendLine() w.append("// Variable") w.appendLine() - w.append(comprehension.IterVar) + w.append(comprehension.GetIterVar()) w.append(",") w.appendLine() w.append("// Target") w.appendLine() - w.Buffer(comprehension.IterRange) + w.Buffer(comprehension.GetIterRange()) w.append(",") w.appendLine() w.append("// Accumulator") w.appendLine() - w.append(comprehension.AccuVar) + w.append(comprehension.GetAccuVar()) w.append(",") w.appendLine() w.append("// Init") w.appendLine() - w.Buffer(comprehension.AccuInit) + w.Buffer(comprehension.GetAccuInit()) w.append(",") w.appendLine() w.append("// LoopCondition") w.appendLine() - w.Buffer(comprehension.LoopCondition) + w.Buffer(comprehension.GetLoopCondition()) w.append(",") w.appendLine() w.append("// LoopStep") w.appendLine() - w.Buffer(comprehension.LoopStep) + w.Buffer(comprehension.GetLoopStep()) w.append(",") w.appendLine() w.append("// Result") w.appendLine() - w.Buffer(comprehension.Result) + w.Buffer(comprehension.GetResult()) w.append(")") w.removeIndent() } func formatLiteral(c *exprpb.Constant) string { - switch c.ConstantKind.(type) { + switch c.GetConstantKind().(type) { case *exprpb.Constant_BoolValue: return fmt.Sprintf("%t", c.GetBoolValue()) case *exprpb.Constant_BytesValue: diff --git a/vendor/github.com/google/cel-go/interpreter/interpretable.go b/vendor/github.com/google/cel-go/interpreter/interpretable.go index 324edccaccd..4fdd12028bd 100644 --- a/vendor/github.com/google/cel-go/interpreter/interpretable.go +++ b/vendor/github.com/google/cel-go/interpreter/interpretable.go @@ -835,7 +835,9 @@ func (fold *evalFold) Eval(ctx Activation) ref.Val { varActivationPool.Put(accuCtx) // Convert a mutable list to an immutable one, if the comprehension has generated a list as a result. if !types.IsUnknownOrError(res) && buildingList { - res = res.(traits.MutableLister).ToImmutableList() + if _, ok := res.(traits.MutableLister); ok { + res = res.(traits.MutableLister).ToImmutableList() + } } return res } diff --git a/vendor/github.com/google/cel-go/interpreter/planner.go b/vendor/github.com/google/cel-go/interpreter/planner.go index 938cf4d762e..882e0419a5f 100644 --- a/vendor/github.com/google/cel-go/interpreter/planner.go +++ b/vendor/github.com/google/cel-go/interpreter/planner.go @@ -95,7 +95,7 @@ type planner struct { // such as state-tracking, expression re-write, and possibly efficient thread-safe memoization of // repeated expressions. func (p *planner) Plan(expr *exprpb.Expr) (Interpretable, error) { - switch expr.ExprKind.(type) { + switch expr.GetExprKind().(type) { case *exprpb.Expr_CallExpr: return p.decorate(p.planCall(expr)) case *exprpb.Expr_IdentExpr: @@ -146,10 +146,10 @@ func (p *planner) planIdent(expr *exprpb.Expr) (Interpretable, error) { func (p *planner) planCheckedIdent(id int64, identRef *exprpb.Reference) (Interpretable, error) { // Plan a constant reference if this is the case for this simple identifier. - if identRef.Value != nil { + if identRef.GetValue() != nil { return p.Plan(&exprpb.Expr{Id: id, ExprKind: &exprpb.Expr_ConstExpr{ - ConstExpr: identRef.Value, + ConstExpr: identRef.GetValue(), }}) } @@ -157,9 +157,9 @@ func (p *planner) planCheckedIdent(id int64, identRef *exprpb.Reference) (Interp // registered with the provider. cType := p.typeMap[id] if cType.GetType() != nil { - cVal, found := p.provider.FindIdent(identRef.Name) + cVal, found := p.provider.FindIdent(identRef.GetName()) if !found { - return nil, fmt.Errorf("reference to undefined type: %s", identRef.Name) + return nil, fmt.Errorf("reference to undefined type: %s", identRef.GetName()) } return NewConstValue(id, cVal), nil } @@ -167,14 +167,15 @@ func (p *planner) planCheckedIdent(id int64, identRef *exprpb.Reference) (Interp // Otherwise, return the attribute for the resolved identifier name. return &evalAttr{ adapter: p.adapter, - attr: p.attrFactory.AbsoluteAttribute(id, identRef.Name), + attr: p.attrFactory.AbsoluteAttribute(id, identRef.GetName()), }, nil } // planSelect creates an Interpretable with either: -// a) selects a field from a map or proto. -// b) creates a field presence test for a select within a has() macro. -// c) resolves the select expression to a namespaced identifier. +// +// a) selects a field from a map or proto. +// b) creates a field presence test for a select within a has() macro. +// c) resolves the select expression to a namespaced identifier. func (p *planner) planSelect(expr *exprpb.Expr) (Interpretable, error) { // If the Select id appears in the reference map from the CheckedExpr proto then it is either // a namespaced identifier or enum value. @@ -193,7 +194,7 @@ func (p *planner) planSelect(expr *exprpb.Expr) (Interpretable, error) { var fieldType *ref.FieldType opType := p.typeMap[sel.GetOperand().GetId()] if opType.GetMessageType() != "" { - ft, found := p.provider.FindFieldType(opType.GetMessageType(), sel.Field) + ft, found := p.provider.FindFieldType(opType.GetMessageType(), sel.GetField()) if found && ft.IsSet != nil && ft.GetFrom != nil { fieldType = ft } @@ -213,15 +214,15 @@ func (p *planner) planSelect(expr *exprpb.Expr) (Interpretable, error) { if sel.TestOnly { // Return the test only eval expression. return &evalTestOnly{ - id: expr.Id, - field: types.String(sel.Field), + id: expr.GetId(), + field: types.String(sel.GetField()), fieldType: fieldType, op: op, }, nil } // Build a qualifier. qual, err := p.attrFactory.NewQualifier( - opType, expr.Id, sel.Field) + opType, expr.GetId(), sel.GetField()) if err != nil { return nil, err } @@ -329,7 +330,7 @@ func (p *planner) planCallZero(expr *exprpb.Expr, return nil, fmt.Errorf("no such overload: %s()", function) } return &evalZeroArity{ - id: expr.Id, + id: expr.GetId(), function: function, overload: overload, impl: impl.Function, @@ -354,7 +355,7 @@ func (p *planner) planCallUnary(expr *exprpb.Expr, nonStrict = impl.NonStrict } return &evalUnary{ - id: expr.Id, + id: expr.GetId(), function: function, overload: overload, arg: args[0], @@ -382,7 +383,7 @@ func (p *planner) planCallBinary(expr *exprpb.Expr, nonStrict = impl.NonStrict } return &evalBinary{ - id: expr.Id, + id: expr.GetId(), function: function, overload: overload, lhs: args[0], @@ -411,7 +412,7 @@ func (p *planner) planCallVarArgs(expr *exprpb.Expr, nonStrict = impl.NonStrict } return &evalVarArgs{ - id: expr.Id, + id: expr.GetId(), function: function, overload: overload, args: args, @@ -425,7 +426,7 @@ func (p *planner) planCallVarArgs(expr *exprpb.Expr, func (p *planner) planCallEqual(expr *exprpb.Expr, args []Interpretable) (Interpretable, error) { return &evalEq{ - id: expr.Id, + id: expr.GetId(), lhs: args[0], rhs: args[1], }, nil @@ -435,7 +436,7 @@ func (p *planner) planCallEqual(expr *exprpb.Expr, func (p *planner) planCallNotEqual(expr *exprpb.Expr, args []Interpretable) (Interpretable, error) { return &evalNe{ - id: expr.Id, + id: expr.GetId(), lhs: args[0], rhs: args[1], }, nil @@ -445,7 +446,7 @@ func (p *planner) planCallNotEqual(expr *exprpb.Expr, func (p *planner) planCallLogicalAnd(expr *exprpb.Expr, args []Interpretable) (Interpretable, error) { return &evalAnd{ - id: expr.Id, + id: expr.GetId(), lhs: args[0], rhs: args[1], }, nil @@ -455,7 +456,7 @@ func (p *planner) planCallLogicalAnd(expr *exprpb.Expr, func (p *planner) planCallLogicalOr(expr *exprpb.Expr, args []Interpretable) (Interpretable, error) { return &evalOr{ - id: expr.Id, + id: expr.GetId(), lhs: args[0], rhs: args[1], }, nil @@ -486,7 +487,7 @@ func (p *planner) planCallConditional(expr *exprpb.Expr, return &evalAttr{ adapter: p.adapter, - attr: p.attrFactory.ConditionalAttribute(expr.Id, cond, tAttr, fAttr), + attr: p.attrFactory.ConditionalAttribute(expr.GetId(), cond, tAttr, fAttr), }, nil } @@ -541,7 +542,7 @@ func (p *planner) planCreateList(expr *exprpb.Expr) (Interpretable, error) { elems[i] = elemVal } return &evalList{ - id: expr.Id, + id: expr.GetId(), elems: elems, adapter: p.adapter, }, nil @@ -570,7 +571,7 @@ func (p *planner) planCreateStruct(expr *exprpb.Expr) (Interpretable, error) { vals[i] = valVal } return &evalMap{ - id: expr.Id, + id: expr.GetId(), keys: keys, vals: vals, adapter: p.adapter, @@ -596,7 +597,7 @@ func (p *planner) planCreateObj(expr *exprpb.Expr) (Interpretable, error) { vals[i] = val } return &evalObj{ - id: expr.Id, + id: expr.GetId(), typeName: typeName, fields: fields, vals: vals, @@ -628,7 +629,7 @@ func (p *planner) planComprehension(expr *exprpb.Expr) (Interpretable, error) { return nil, err } return &evalFold{ - id: expr.Id, + id: expr.GetId(), accuVar: fold.AccuVar, accu: accu, iterVar: fold.IterVar, @@ -646,12 +647,12 @@ func (p *planner) planConst(expr *exprpb.Expr) (Interpretable, error) { if err != nil { return nil, err } - return NewConstValue(expr.Id, val), nil + return NewConstValue(expr.GetId(), val), nil } // constValue converts a proto Constant value to a ref.Val. func (p *planner) constValue(c *exprpb.Constant) (ref.Val, error) { - switch c.ConstantKind.(type) { + switch c.GetConstantKind().(type) { case *exprpb.Constant_BoolValue: return p.adapter.NativeToValue(c.GetBoolValue()), nil case *exprpb.Constant_BytesValue: diff --git a/vendor/github.com/google/cel-go/interpreter/prune.go b/vendor/github.com/google/cel-go/interpreter/prune.go index 0c01eb4f3ac..eab46e0c06e 100644 --- a/vendor/github.com/google/cel-go/interpreter/prune.go +++ b/vendor/github.com/google/cel-go/interpreter/prune.go @@ -41,17 +41,23 @@ type astPruner struct { // A) // 1) Evaluate expr with some unknowns, // 2) If result is unknown: -// a) PruneAst -// b) Goto 1 +// +// a) PruneAst +// b) Goto 1 +// // Functional call results which are known would be effectively cached across // iterations. // // B) // 1) Compile the expression (maybe via a service and maybe after checking a -// compiled expression does not exists in local cache) +// +// compiled expression does not exists in local cache) +// // 2) Prepare the environment and the interpreter. Activation might be empty. // 3) Eval the expression. This might return unknown or error or a concrete -// value. +// +// value. +// // 4) PruneAst // 4) Maybe cache the expression // This is effectively constant folding the expression. How the environment is @@ -232,9 +238,9 @@ func (p *astPruner) prune(node *exprpb.Expr) (*exprpb.Expr, bool) { // transform, or expression was not evaluated. If possible, drill down // more. - switch node.ExprKind.(type) { + switch node.GetExprKind().(type) { case *exprpb.Expr_SelectExpr: - if operand, pruned := p.prune(node.GetSelectExpr().Operand); pruned { + if operand, pruned := p.prune(node.GetSelectExpr().GetOperand()); pruned { return &exprpb.Expr{ Id: node.GetId(), ExprKind: &exprpb.Expr_SelectExpr{ diff --git a/vendor/github.com/google/cel-go/parser/helper.go b/vendor/github.com/google/cel-go/parser/helper.go index a6d9578ed8c..be41339e3f2 100644 --- a/vendor/github.com/google/cel-go/parser/helper.go +++ b/vendor/github.com/google/cel-go/parser/helper.go @@ -217,7 +217,7 @@ func (p *parserHelper) buildMacroCallArg(expr *exprpb.Expr) *exprpb.Expr { return &exprpb.Expr{Id: expr.GetId()} } - switch expr.ExprKind.(type) { + switch expr.GetExprKind().(type) { case *exprpb.Expr_CallExpr: // Iterate the AST from `expr` recursively looking for macros. Because we are at most // starting from the top level macro, this recursion is bounded by the size of the AST. This diff --git a/vendor/github.com/google/cel-go/parser/parser.go b/vendor/github.com/google/cel-go/parser/parser.go index 477eede924a..072f6245745 100644 --- a/vendor/github.com/google/cel-go/parser/parser.go +++ b/vendor/github.com/google/cel-go/parser/parser.go @@ -807,13 +807,13 @@ func (p *parser) extractQualifiedName(e *exprpb.Expr) (string, bool) { if e == nil { return "", false } - switch e.ExprKind.(type) { + switch e.GetExprKind().(type) { case *exprpb.Expr_IdentExpr: return e.GetIdentExpr().GetName(), true case *exprpb.Expr_SelectExpr: s := e.GetSelectExpr() - if prefix, found := p.extractQualifiedName(s.Operand); found { - return prefix + "." + s.Field, true + if prefix, found := p.extractQualifiedName(s.GetOperand()); found { + return prefix + "." + s.GetField(), true } } // TODO: Add a method to Source to get location from character offset. diff --git a/vendor/github.com/google/cel-go/parser/unparser.go b/vendor/github.com/google/cel-go/parser/unparser.go index 64440a94511..a459bb4a98d 100644 --- a/vendor/github.com/google/cel-go/parser/unparser.go +++ b/vendor/github.com/google/cel-go/parser/unparser.go @@ -81,7 +81,7 @@ func (un *unparser) visit(expr *exprpb.Expr) error { if visited || err != nil { return err } - switch expr.ExprKind.(type) { + switch expr.GetExprKind().(type) { case *exprpb.Expr_CallExpr: return un.visitCall(expr) case *exprpb.Expr_ConstExpr: @@ -249,7 +249,7 @@ func (un *unparser) visitCallUnary(expr *exprpb.Expr) error { func (un *unparser) visitConst(expr *exprpb.Expr) error { c := expr.GetConstExpr() - switch c.ConstantKind.(type) { + switch c.GetConstantKind().(type) { case *exprpb.Constant_BoolValue: un.str.WriteString(strconv.FormatBool(c.GetBoolValue())) case *exprpb.Constant_BytesValue: diff --git a/vendor/modules.txt b/vendor/modules.txt index 1b99b6847ed..fea02f82459 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -411,7 +411,7 @@ github.com/google/cadvisor/utils/sysfs github.com/google/cadvisor/utils/sysinfo github.com/google/cadvisor/version github.com/google/cadvisor/watcher -# github.com/google/cel-go v0.12.4 => github.com/google/cel-go v0.12.4 +# github.com/google/cel-go v0.12.5 => github.com/google/cel-go v0.12.5 ## explicit; go 1.17 github.com/google/cel-go/cel github.com/google/cel-go/checker @@ -2686,7 +2686,7 @@ sigs.k8s.io/yaml # github.com/golangplus/testing => github.com/golangplus/testing v1.0.0 # github.com/google/btree => github.com/google/btree v1.0.1 # github.com/google/cadvisor => github.com/google/cadvisor v0.45.0 -# github.com/google/cel-go => github.com/google/cel-go v0.12.4 +# github.com/google/cel-go => github.com/google/cel-go v0.12.5 # github.com/google/gnostic => github.com/google/gnostic v0.5.7-v3refs # github.com/google/go-cmp => github.com/google/go-cmp v0.5.6 # github.com/google/gofuzz => github.com/google/gofuzz v1.1.0 From 6042d781f536e73dbc378259eebe5891f6c3633a Mon Sep 17 00:00:00 2001 From: Kermit Alexander II Date: Mon, 22 Aug 2022 17:01:57 +0000 Subject: [PATCH 2/3] Add unit tests. --- .../apiserver/schema/cel/compilation_test.go | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/cel/compilation_test.go b/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/cel/compilation_test.go index 847fec2e698..3eec572ff1e 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/cel/compilation_test.go +++ b/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/cel/compilation_test.go @@ -1593,6 +1593,27 @@ func TestCostEstimation(t *testing.T) { setMaxElements: 10, expectedSetCost: 6, }, + { + name: "check cost of size call", + schemaGenerator: genMapWithRule("integer", "oldSelf.size() == self.size()"), + expectedCalcCost: 5, + setMaxElements: 10, + expectedSetCost: 5, + }, + { + name: "check cost of timestamp comparison", + schemaGenerator: genMapWithRule("date-time", `self["a"] == self["b"]`), + expectedCalcCost: 8, + setMaxElements: 7, + expectedSetCost: 8, + }, + { + name: "check cost of duration comparison", + schemaGenerator: genMapWithRule("duration", `self["c"] == self["d"]`), + expectedCalcCost: 8, + setMaxElements: 42, + expectedSetCost: 8, + }, } for _, testCase := range cases { t.Run(testCase.name, func(t *testing.T) { From 9509cb293f136aa8c4b0e8bcf89e19f8a1abbb85 Mon Sep 17 00:00:00 2001 From: Kermit Alexander II Date: Mon, 22 Aug 2022 18:10:40 +0000 Subject: [PATCH 3/3] Run lint-dependencies.sh/pin-dependency.sh/update-vendor.sh. --- go.mod | 2 +- go.sum | 2 +- vendor/modules.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 8ed4bd5ee6c..0628c495a23 100644 --- a/go.mod +++ b/go.mod @@ -378,7 +378,7 @@ replace ( github.com/gogo/protobuf => github.com/gogo/protobuf v1.3.2 github.com/golang-jwt/jwt/v4 => github.com/golang-jwt/jwt/v4 v4.2.0 github.com/golang/freetype => github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 - github.com/golang/glog => github.com/golang/glog v1.0.0 + github.com/golang/glog => github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b github.com/golang/groupcache => github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da github.com/golang/mock => github.com/golang/mock v1.6.0 github.com/golang/protobuf => github.com/golang/protobuf v1.5.2 diff --git a/go.sum b/go.sum index 4efd4a6be58..15ca8a71ac7 100644 --- a/go.sum +++ b/go.sum @@ -199,7 +199,7 @@ github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69 github.com/golang-jwt/jwt/v4 v4.2.0 h1:besgBTC8w8HjP6NzQdxwKH9Z5oQMZ24ThTrHp3cZ8eU= github.com/golang-jwt/jwt/v4 v4.2.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= -github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= diff --git a/vendor/modules.txt b/vendor/modules.txt index fea02f82459..009e63d269a 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -2676,7 +2676,7 @@ sigs.k8s.io/yaml # github.com/gogo/protobuf => github.com/gogo/protobuf v1.3.2 # github.com/golang-jwt/jwt/v4 => github.com/golang-jwt/jwt/v4 v4.2.0 # github.com/golang/freetype => github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 -# github.com/golang/glog => github.com/golang/glog v1.0.0 +# github.com/golang/glog => github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b # github.com/golang/groupcache => github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da # github.com/golang/mock => github.com/golang/mock v1.6.0 # github.com/golang/protobuf => github.com/golang/protobuf v1.5.2