mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 19:31:44 +00:00
Run pin-dependency.sh and update-vendor.sh.
This commit is contained in:
parent
d581cc90ad
commit
4a703d6cbc
4
go.mod
4
go.mod
@ -176,7 +176,7 @@ require (
|
|||||||
github.com/gofrs/uuid v4.0.0+incompatible // indirect
|
github.com/gofrs/uuid v4.0.0+incompatible // indirect
|
||||||
github.com/golang-jwt/jwt/v4 v4.2.0 // indirect
|
github.com/golang-jwt/jwt/v4 v4.2.0 // indirect
|
||||||
github.com/google/btree v1.0.1 // 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/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect
|
||||||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
|
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
|
||||||
github.com/googleapis/gax-go/v2 v2.1.1 // 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/golangplus/testing => github.com/golangplus/testing v1.0.0
|
||||||
github.com/google/btree => github.com/google/btree v1.0.1
|
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/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/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/go-cmp => github.com/google/go-cmp v0.5.6
|
||||||
github.com/google/gofuzz => github.com/google/gofuzz v1.1.0
|
github.com/google/gofuzz => github.com/google/gofuzz v1.1.0
|
||||||
|
4
go.sum
4
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/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 h1:bXQze1sd8srZiQwiQ19Qaq/AoMIZS8YceBXrIaEvkX0=
|
||||||
github.com/google/cadvisor v0.45.0/go.mod h1:vsMT3Uv2XjQ8M7WUtKARV74mU/HN64C4XtM1bJhUKcU=
|
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.5 h1:DmzaiSgoaqGCjtpPQWl26/gND+yRpim56H1jCVev6d8=
|
||||||
github.com/google/cel-go v0.12.4/go.mod h1:Av7CU6r6X3YmcHR9GXqVDaEJYfEtSxl6wvIjUQTriCw=
|
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 h1:FhTMOKj2VhjpouxvWJAV1TL304uMlb9zcDqkl6cEI54=
|
||||||
github.com/google/gnostic v0.5.7-v3refs/go.mod h1:73MKFl6jIHelAJNaBGFzt3SPtZULs9dYrGFt8OiIsHQ=
|
github.com/google/gnostic v0.5.7-v3refs/go.mod h1:73MKFl6jIHelAJNaBGFzt3SPtZULs9dYrGFt8OiIsHQ=
|
||||||
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
|
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
|
||||||
|
@ -7,7 +7,7 @@ go 1.19
|
|||||||
require (
|
require (
|
||||||
github.com/emicklei/go-restful/v3 v3.8.0
|
github.com/emicklei/go-restful/v3 v3.8.0
|
||||||
github.com/gogo/protobuf v1.3.2
|
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/gnostic v0.5.7-v3refs
|
||||||
github.com/google/go-cmp v0.5.6
|
github.com/google/go-cmp v0.5.6
|
||||||
github.com/google/gofuzz v1.1.0
|
github.com/google/gofuzz v1.1.0
|
||||||
|
@ -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.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||||
github.com/google/btree v1.0.1 h1:gK4Kx5IaGY9CD5sPJ36FHiBJ6ZXl0kilRiiCj+jdYp4=
|
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/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.5 h1:DmzaiSgoaqGCjtpPQWl26/gND+yRpim56H1jCVev6d8=
|
||||||
github.com/google/cel-go v0.12.4/go.mod h1:Av7CU6r6X3YmcHR9GXqVDaEJYfEtSxl6wvIjUQTriCw=
|
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 h1:FhTMOKj2VhjpouxvWJAV1TL304uMlb9zcDqkl6cEI54=
|
||||||
github.com/google/gnostic v0.5.7-v3refs/go.mod h1:73MKFl6jIHelAJNaBGFzt3SPtZULs9dYrGFt8OiIsHQ=
|
github.com/google/gnostic v0.5.7-v3refs/go.mod h1:73MKFl6jIHelAJNaBGFzt3SPtZULs9dYrGFt8OiIsHQ=
|
||||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||||
|
65
vendor/github.com/google/cel-go/checker/checker.go
generated
vendored
65
vendor/github.com/google/cel-go/checker/checker.go
generated
vendored
@ -80,10 +80,10 @@ func (c *checker) check(e *exprpb.Expr) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
switch e.ExprKind.(type) {
|
switch e.GetExprKind().(type) {
|
||||||
case *exprpb.Expr_ConstExpr:
|
case *exprpb.Expr_ConstExpr:
|
||||||
literal := e.GetConstExpr()
|
literal := e.GetConstExpr()
|
||||||
switch literal.ConstantKind.(type) {
|
switch literal.GetConstantKind().(type) {
|
||||||
case *exprpb.Constant_BoolValue:
|
case *exprpb.Constant_BoolValue:
|
||||||
c.checkBoolLiteral(e)
|
c.checkBoolLiteral(e)
|
||||||
case *exprpb.Constant_BytesValue:
|
case *exprpb.Constant_BytesValue:
|
||||||
@ -149,8 +149,8 @@ func (c *checker) checkIdent(e *exprpb.Expr) {
|
|||||||
identExpr := e.GetIdentExpr()
|
identExpr := e.GetIdentExpr()
|
||||||
// Check to see if the identifier is declared.
|
// Check to see if the identifier is declared.
|
||||||
if ident := c.env.LookupIdent(identExpr.GetName()); ident != nil {
|
if ident := c.env.LookupIdent(identExpr.GetName()); ident != nil {
|
||||||
c.setType(e, ident.GetIdent().Type)
|
c.setType(e, ident.GetIdent().GetType())
|
||||||
c.setReference(e, newIdentReference(ident.GetName(), ident.GetIdent().Value))
|
c.setReference(e, newIdentReference(ident.GetName(), ident.GetIdent().GetValue()))
|
||||||
// Overwrite the identifier with its fully qualified name.
|
// Overwrite the identifier with its fully qualified name.
|
||||||
identExpr.Name = ident.GetName()
|
identExpr.Name = ident.GetName()
|
||||||
return
|
return
|
||||||
@ -186,23 +186,20 @@ func (c *checker) checkSelect(e *exprpb.Expr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Interpret as field selection, first traversing down the operand.
|
// Interpret as field selection, first traversing down the operand.
|
||||||
c.check(sel.Operand)
|
c.check(sel.GetOperand())
|
||||||
targetType := substitute(c.mappings, c.getType(sel.Operand), false)
|
targetType := substitute(c.mappings, c.getType(sel.GetOperand()), false)
|
||||||
// Assume error type by default as most types do not support field selection.
|
// Assume error type by default as most types do not support field selection.
|
||||||
resultType := decls.Error
|
resultType := decls.Error
|
||||||
switch kindOf(targetType) {
|
switch kindOf(targetType) {
|
||||||
case kindMap:
|
case kindMap:
|
||||||
// Maps yield their value type as the selection result type.
|
// Maps yield their value type as the selection result type.
|
||||||
mapType := targetType.GetMapType()
|
mapType := targetType.GetMapType()
|
||||||
resultType = mapType.ValueType
|
resultType = mapType.GetValueType()
|
||||||
case kindObject:
|
case kindObject:
|
||||||
// Objects yield their field type declaration as the selection result type, but only if
|
// Objects yield their field type declaration as the selection result type, but only if
|
||||||
// the field is defined.
|
// the field is defined.
|
||||||
messageType := targetType
|
messageType := targetType
|
||||||
if fieldType, found := c.lookupFieldType(
|
if fieldType, found := c.lookupFieldType(c.location(e), messageType.GetMessageType(), sel.GetField()); found {
|
||||||
c.location(e),
|
|
||||||
messageType.GetMessageType(),
|
|
||||||
sel.Field); found {
|
|
||||||
resultType = fieldType.Type
|
resultType = fieldType.Type
|
||||||
}
|
}
|
||||||
case kindTypeParam:
|
case kindTypeParam:
|
||||||
@ -320,15 +317,15 @@ func (c *checker) resolveOverload(
|
|||||||
|
|
||||||
var resultType *exprpb.Type
|
var resultType *exprpb.Type
|
||||||
var checkedRef *exprpb.Reference
|
var checkedRef *exprpb.Reference
|
||||||
for _, overload := range fn.GetFunction().Overloads {
|
for _, overload := range fn.GetFunction().GetOverloads() {
|
||||||
// Determine whether the overload is currently considered.
|
// Determine whether the overload is currently considered.
|
||||||
if c.env.isOverloadDisabled(overload.GetOverloadId()) {
|
if c.env.isOverloadDisabled(overload.GetOverloadId()) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure the call style for the overload matches.
|
// Ensure the call style for the overload matches.
|
||||||
if (target == nil && overload.IsInstanceFunction) ||
|
if (target == nil && overload.GetIsInstanceFunction()) ||
|
||||||
(target != nil && !overload.IsInstanceFunction) {
|
(target != nil && !overload.GetIsInstanceFunction()) {
|
||||||
// not a compatible call style.
|
// not a compatible call style.
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -348,13 +345,11 @@ func (c *checker) resolveOverload(
|
|||||||
if checkedRef == nil {
|
if checkedRef == nil {
|
||||||
checkedRef = newFunctionReference(overload.GetOverloadId())
|
checkedRef = newFunctionReference(overload.GetOverloadId())
|
||||||
} else {
|
} else {
|
||||||
checkedRef.OverloadId = append(checkedRef.OverloadId, overload.GetOverloadId())
|
checkedRef.OverloadId = append(checkedRef.GetOverloadId(), overload.GetOverloadId())
|
||||||
}
|
}
|
||||||
|
|
||||||
// First matching overload, determines result type.
|
// First matching overload, determines result type.
|
||||||
fnResultType := substitute(c.mappings,
|
fnResultType := substitute(c.mappings, overloadType.GetFunction().GetResultType(), false)
|
||||||
overloadType.GetFunction().GetResultType(),
|
|
||||||
false)
|
|
||||||
if resultType == nil {
|
if resultType == nil {
|
||||||
resultType = fnResultType
|
resultType = fnResultType
|
||||||
} else if !isDyn(resultType) && !proto.Equal(fnResultType, resultType) {
|
} else if !isDyn(resultType) && !proto.Equal(fnResultType, resultType) {
|
||||||
@ -375,7 +370,7 @@ func (c *checker) resolveOverload(
|
|||||||
func (c *checker) checkCreateList(e *exprpb.Expr) {
|
func (c *checker) checkCreateList(e *exprpb.Expr) {
|
||||||
create := e.GetListExpr()
|
create := e.GetListExpr()
|
||||||
var elemType *exprpb.Type
|
var elemType *exprpb.Type
|
||||||
for _, e := range create.Elements {
|
for _, e := range create.GetElements() {
|
||||||
c.check(e)
|
c.check(e)
|
||||||
elemType = c.joinTypes(c.location(e), elemType, c.getType(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) {
|
func (c *checker) checkCreateStruct(e *exprpb.Expr) {
|
||||||
str := e.GetStructExpr()
|
str := e.GetStructExpr()
|
||||||
if str.MessageName != "" {
|
if str.GetMessageName() != "" {
|
||||||
c.checkCreateMessage(e)
|
c.checkCreateMessage(e)
|
||||||
} else {
|
} else {
|
||||||
c.checkCreateMap(e)
|
c.checkCreateMap(e)
|
||||||
@ -419,22 +414,22 @@ func (c *checker) checkCreateMessage(e *exprpb.Expr) {
|
|||||||
msgVal := e.GetStructExpr()
|
msgVal := e.GetStructExpr()
|
||||||
// Determine the type of the message.
|
// Determine the type of the message.
|
||||||
messageType := decls.Error
|
messageType := decls.Error
|
||||||
decl := c.env.LookupIdent(msgVal.MessageName)
|
decl := c.env.LookupIdent(msgVal.GetMessageName())
|
||||||
if decl == nil {
|
if decl == nil {
|
||||||
c.errors.undeclaredReference(
|
c.errors.undeclaredReference(
|
||||||
c.location(e), c.env.container.Name(), msgVal.MessageName)
|
c.location(e), c.env.container.Name(), msgVal.GetMessageName())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Ensure the type name is fully qualified in the AST.
|
// Ensure the type name is fully qualified in the AST.
|
||||||
msgVal.MessageName = decl.GetName()
|
msgVal.MessageName = decl.GetName()
|
||||||
c.setReference(e, newIdentReference(decl.GetName(), nil))
|
c.setReference(e, newIdentReference(decl.GetName(), nil))
|
||||||
ident := decl.GetIdent()
|
ident := decl.GetIdent()
|
||||||
identKind := kindOf(ident.Type)
|
identKind := kindOf(ident.GetType())
|
||||||
if identKind != kindError {
|
if identKind != kindError {
|
||||||
if identKind != kindType {
|
if identKind != kindType {
|
||||||
c.errors.notAType(c.location(e), ident.Type)
|
c.errors.notAType(c.location(e), ident.GetType())
|
||||||
} else {
|
} else {
|
||||||
messageType = ident.Type.GetType()
|
messageType = ident.GetType().GetType()
|
||||||
if kindOf(messageType) != kindObject {
|
if kindOf(messageType) != kindObject {
|
||||||
c.errors.notAMessageType(c.location(e), messageType)
|
c.errors.notAMessageType(c.location(e), messageType)
|
||||||
messageType = decls.Error
|
messageType = decls.Error
|
||||||
@ -450,12 +445,12 @@ func (c *checker) checkCreateMessage(e *exprpb.Expr) {
|
|||||||
// Check the field initializers.
|
// Check the field initializers.
|
||||||
for _, ent := range msgVal.GetEntries() {
|
for _, ent := range msgVal.GetEntries() {
|
||||||
field := ent.GetFieldKey()
|
field := ent.GetFieldKey()
|
||||||
value := ent.Value
|
value := ent.GetValue()
|
||||||
c.check(value)
|
c.check(value)
|
||||||
|
|
||||||
fieldType := decls.Error
|
fieldType := decls.Error
|
||||||
if t, found := c.lookupFieldType(
|
if t, found := c.lookupFieldType(
|
||||||
c.locationByID(ent.Id),
|
c.locationByID(ent.GetId()),
|
||||||
messageType.GetMessageType(),
|
messageType.GetMessageType(),
|
||||||
field); found {
|
field); found {
|
||||||
fieldType = t.Type
|
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) {
|
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),
|
c.errors.ReportError(c.location(e),
|
||||||
"(Incompatible) Type already exists for expression: %v(%d) old:%v, new:%v", e, e.GetId(), old, t)
|
"(Incompatible) Type already exists for expression: %v(%d) old:%v, new:%v", e, e.GetId(), old, t)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.types[e.Id] = t
|
c.types[e.GetId()] = t
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *checker) getType(e *exprpb.Expr) *exprpb.Type {
|
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) {
|
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),
|
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
|
return
|
||||||
}
|
}
|
||||||
c.references[e.Id] = r
|
c.references[e.GetId()] = r
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *checker) assertType(e *exprpb.Expr, t *exprpb.Type) {
|
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 {
|
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 {
|
func (c *checker) locationByID(id int64) common.Location {
|
||||||
@ -624,7 +619,7 @@ func (c *checker) locationByID(id int64) common.Location {
|
|||||||
var line = 1
|
var line = 1
|
||||||
if offset, found := positions[id]; found {
|
if offset, found := positions[id]; found {
|
||||||
col := int(offset)
|
col := int(offset)
|
||||||
for _, lineOffset := range c.sourceInfo.LineOffsets {
|
for _, lineOffset := range c.sourceInfo.GetLineOffsets() {
|
||||||
if lineOffset < offset {
|
if lineOffset < offset {
|
||||||
line++
|
line++
|
||||||
col = int(offset - lineOffset)
|
col = int(offset - lineOffset)
|
||||||
|
42
vendor/github.com/google/cel-go/checker/cost.go
generated
vendored
42
vendor/github.com/google/cel-go/checker/cost.go
generated
vendored
@ -88,9 +88,9 @@ func (e astNode) ComputedSize() *SizeEstimate {
|
|||||||
return e.derivedSize
|
return e.derivedSize
|
||||||
}
|
}
|
||||||
var v uint64
|
var v uint64
|
||||||
switch ek := e.expr.ExprKind.(type) {
|
switch ek := e.expr.GetExprKind().(type) {
|
||||||
case *exprpb.Expr_ConstExpr:
|
case *exprpb.Expr_ConstExpr:
|
||||||
switch ck := ek.ConstExpr.ConstantKind.(type) {
|
switch ck := ek.ConstExpr.GetConstantKind().(type) {
|
||||||
case *exprpb.Constant_StringValue:
|
case *exprpb.Constant_StringValue:
|
||||||
v = uint64(len(ck.StringValue))
|
v = uint64(len(ck.StringValue))
|
||||||
case *exprpb.Constant_BytesValue:
|
case *exprpb.Constant_BytesValue:
|
||||||
@ -103,10 +103,10 @@ func (e astNode) ComputedSize() *SizeEstimate {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
case *exprpb.Expr_ListExpr:
|
case *exprpb.Expr_ListExpr:
|
||||||
v = uint64(len(ek.ListExpr.Elements))
|
v = uint64(len(ek.ListExpr.GetElements()))
|
||||||
case *exprpb.Expr_StructExpr:
|
case *exprpb.Expr_StructExpr:
|
||||||
if ek.StructExpr.MessageName == "" {
|
if ek.StructExpr.GetMessageName() == "" {
|
||||||
v = uint64(len(ek.StructExpr.Entries))
|
v = uint64(len(ek.StructExpr.GetEntries()))
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return nil
|
return nil
|
||||||
@ -297,7 +297,7 @@ func (c *coster) cost(e *exprpb.Expr) CostEstimate {
|
|||||||
return CostEstimate{}
|
return CostEstimate{}
|
||||||
}
|
}
|
||||||
var cost CostEstimate
|
var cost CostEstimate
|
||||||
switch e.ExprKind.(type) {
|
switch e.GetExprKind().(type) {
|
||||||
case *exprpb.Expr_ConstExpr:
|
case *exprpb.Expr_ConstExpr:
|
||||||
cost = constCost
|
cost = constCost
|
||||||
case *exprpb.Expr_IdentExpr:
|
case *exprpb.Expr_IdentExpr:
|
||||||
@ -323,7 +323,7 @@ func (c *coster) costIdent(e *exprpb.Expr) CostEstimate {
|
|||||||
|
|
||||||
// build and track the field path
|
// build and track the field path
|
||||||
if iterRange, ok := c.iterRanges.peek(identExpr.GetName()); ok {
|
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_:
|
case *exprpb.Type_ListType_:
|
||||||
c.addPath(e, append(c.exprPath[iterRange], "@items"))
|
c.addPath(e, append(c.exprPath[iterRange], "@items"))
|
||||||
case *exprpb.Type_MapType_:
|
case *exprpb.Type_MapType_:
|
||||||
@ -350,7 +350,7 @@ func (c *coster) costSelect(e *exprpb.Expr) CostEstimate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// build and track the field path
|
// 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
|
return sum
|
||||||
}
|
}
|
||||||
@ -476,6 +476,15 @@ func (c *coster) sizeEstimate(t AstNode) SizeEstimate {
|
|||||||
if l := c.estimator.EstimateSize(t); l != nil {
|
if l := c.estimator.EstimateSize(t); l != nil {
|
||||||
return *l
|
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}
|
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}
|
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
|
||||||
|
}
|
||||||
|
8
vendor/github.com/google/cel-go/checker/printer.go
generated
vendored
8
vendor/github.com/google/cel-go/checker/printer.go
generated
vendored
@ -32,22 +32,22 @@ func (a *semanticAdorner) GetMetadata(elem interface{}) string {
|
|||||||
if !isExpr {
|
if !isExpr {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
t := a.checks.TypeMap[e.Id]
|
t := a.checks.TypeMap[e.GetId()]
|
||||||
if t != nil {
|
if t != nil {
|
||||||
result += "~"
|
result += "~"
|
||||||
result += FormatCheckedType(t)
|
result += FormatCheckedType(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
switch e.ExprKind.(type) {
|
switch e.GetExprKind().(type) {
|
||||||
case *exprpb.Expr_IdentExpr,
|
case *exprpb.Expr_IdentExpr,
|
||||||
*exprpb.Expr_CallExpr,
|
*exprpb.Expr_CallExpr,
|
||||||
*exprpb.Expr_StructExpr,
|
*exprpb.Expr_StructExpr,
|
||||||
*exprpb.Expr_SelectExpr:
|
*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 {
|
if len(ref.GetOverloadId()) == 0 {
|
||||||
result += "^" + ref.Name
|
result += "^" + ref.Name
|
||||||
} else {
|
} else {
|
||||||
for i, overload := range ref.OverloadId {
|
for i, overload := range ref.GetOverloadId() {
|
||||||
if i == 0 {
|
if i == 0 {
|
||||||
result += "^"
|
result += "^"
|
||||||
} else {
|
} else {
|
||||||
|
36
vendor/github.com/google/cel-go/checker/types.go
generated
vendored
36
vendor/github.com/google/cel-go/checker/types.go
generated
vendored
@ -52,13 +52,13 @@ func FormatCheckedType(t *exprpb.Type) string {
|
|||||||
t.GetFunction().GetArgTypes(),
|
t.GetFunction().GetArgTypes(),
|
||||||
false)
|
false)
|
||||||
case kindList:
|
case kindList:
|
||||||
return fmt.Sprintf("list(%s)", FormatCheckedType(t.GetListType().ElemType))
|
return fmt.Sprintf("list(%s)", FormatCheckedType(t.GetListType().GetElemType()))
|
||||||
case kindObject:
|
case kindObject:
|
||||||
return t.GetMessageType()
|
return t.GetMessageType()
|
||||||
case kindMap:
|
case kindMap:
|
||||||
return fmt.Sprintf("map(%s, %s)",
|
return fmt.Sprintf("map(%s, %s)",
|
||||||
FormatCheckedType(t.GetMapType().KeyType),
|
FormatCheckedType(t.GetMapType().GetKeyType()),
|
||||||
FormatCheckedType(t.GetMapType().ValueType))
|
FormatCheckedType(t.GetMapType().GetValueType()))
|
||||||
case kindNull:
|
case kindNull:
|
||||||
return "null"
|
return "null"
|
||||||
case kindPrimitive:
|
case kindPrimitive:
|
||||||
@ -152,12 +152,12 @@ func isEqualOrLessSpecific(t1 *exprpb.Type, t2 *exprpb.Type) bool {
|
|||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case kindList:
|
case kindList:
|
||||||
return isEqualOrLessSpecific(t1.GetListType().ElemType, t2.GetListType().ElemType)
|
return isEqualOrLessSpecific(t1.GetListType().GetElemType(), t2.GetListType().GetElemType())
|
||||||
case kindMap:
|
case kindMap:
|
||||||
m1 := t1.GetMapType()
|
m1 := t1.GetMapType()
|
||||||
m2 := t2.GetMapType()
|
m2 := t2.GetMapType()
|
||||||
return isEqualOrLessSpecific(m1.KeyType, m2.KeyType) &&
|
return isEqualOrLessSpecific(m1.GetKeyType(), m2.GetKeyType()) &&
|
||||||
isEqualOrLessSpecific(m1.ValueType, m2.ValueType)
|
isEqualOrLessSpecific(m1.GetValueType(), m2.GetValueType())
|
||||||
case kindType:
|
case kindType:
|
||||||
return true
|
return true
|
||||||
default:
|
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 {
|
func internalIsAssignable(m *mapping, t1 *exprpb.Type, t2 *exprpb.Type) bool {
|
||||||
// Process type parameters.
|
// Process type parameters.
|
||||||
kind1, kind2 := kindOf(t1), kindOf(t2)
|
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
|
// internalIsAssignableAbstractType returns true if the abstract type names agree and all type
|
||||||
// parameters are assignable.
|
// parameters are assignable.
|
||||||
func internalIsAssignableAbstractType(m *mapping,
|
func internalIsAssignableAbstractType(m *mapping, a1 *exprpb.Type_AbstractType, a2 *exprpb.Type_AbstractType) bool {
|
||||||
a1 *exprpb.Type_AbstractType,
|
|
||||||
a2 *exprpb.Type_AbstractType) bool {
|
|
||||||
return a1.GetName() == a2.GetName() &&
|
return a1.GetName() == a2.GetName() &&
|
||||||
internalIsAssignableList(m, a1.GetParameterTypes(), a2.GetParameterTypes())
|
internalIsAssignableList(m, a1.GetParameterTypes(), a2.GetParameterTypes())
|
||||||
}
|
}
|
||||||
|
|
||||||
// internalIsAssignableFunction returns true if the function return type and arg types are
|
// internalIsAssignableFunction returns true if the function return type and arg types are
|
||||||
// assignable.
|
// assignable.
|
||||||
func internalIsAssignableFunction(m *mapping,
|
func internalIsAssignableFunction(m *mapping, f1 *exprpb.Type_FunctionType, f2 *exprpb.Type_FunctionType) bool {
|
||||||
f1 *exprpb.Type_FunctionType,
|
|
||||||
f2 *exprpb.Type_FunctionType) bool {
|
|
||||||
f1ArgTypes := flattenFunctionTypes(f1)
|
f1ArgTypes := flattenFunctionTypes(f1)
|
||||||
f2ArgTypes := flattenFunctionTypes(f2)
|
f2ArgTypes := flattenFunctionTypes(f2)
|
||||||
if internalIsAssignableList(m, f1ArgTypes, f2ArgTypes) {
|
if internalIsAssignableList(m, f1ArgTypes, f2ArgTypes) {
|
||||||
@ -363,7 +359,7 @@ func kindOf(t *exprpb.Type) int {
|
|||||||
if t == nil || t.TypeKind == nil {
|
if t == nil || t.TypeKind == nil {
|
||||||
return kindUnknown
|
return kindUnknown
|
||||||
}
|
}
|
||||||
switch t.TypeKind.(type) {
|
switch t.GetTypeKind().(type) {
|
||||||
case *exprpb.Type_Error:
|
case *exprpb.Type_Error:
|
||||||
return kindError
|
return kindError
|
||||||
case *exprpb.Type_Function:
|
case *exprpb.Type_Function:
|
||||||
@ -425,10 +421,10 @@ func notReferencedIn(m *mapping, t *exprpb.Type, withinType *exprpb.Type) bool {
|
|||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case kindList:
|
case kindList:
|
||||||
return notReferencedIn(m, t, withinType.GetListType().ElemType)
|
return notReferencedIn(m, t, withinType.GetListType().GetElemType())
|
||||||
case kindMap:
|
case kindMap:
|
||||||
mt := withinType.GetMapType()
|
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:
|
case kindWrapper:
|
||||||
return notReferencedIn(m, t, decls.NewPrimitiveType(withinType.GetWrapper()))
|
return notReferencedIn(m, t, decls.NewPrimitiveType(withinType.GetWrapper()))
|
||||||
default:
|
default:
|
||||||
@ -457,17 +453,17 @@ func substitute(m *mapping, t *exprpb.Type, typeParamToDyn bool) *exprpb.Type {
|
|||||||
case kindFunction:
|
case kindFunction:
|
||||||
fn := t.GetFunction()
|
fn := t.GetFunction()
|
||||||
rt := substitute(m, fn.ResultType, typeParamToDyn)
|
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 {
|
for i, a := range fn.ArgTypes {
|
||||||
args[i] = substitute(m, a, typeParamToDyn)
|
args[i] = substitute(m, a, typeParamToDyn)
|
||||||
}
|
}
|
||||||
return decls.NewFunctionType(rt, args...)
|
return decls.NewFunctionType(rt, args...)
|
||||||
case kindList:
|
case kindList:
|
||||||
return decls.NewListType(substitute(m, t.GetListType().ElemType, typeParamToDyn))
|
return decls.NewListType(substitute(m, t.GetListType().GetElemType(), typeParamToDyn))
|
||||||
case kindMap:
|
case kindMap:
|
||||||
mt := t.GetMapType()
|
mt := t.GetMapType()
|
||||||
return decls.NewMapType(substitute(m, mt.KeyType, typeParamToDyn),
|
return decls.NewMapType(substitute(m, mt.GetKeyType(), typeParamToDyn),
|
||||||
substitute(m, mt.ValueType, typeParamToDyn))
|
substitute(m, mt.GetValueType(), typeParamToDyn))
|
||||||
case kindType:
|
case kindType:
|
||||||
if t.GetType() != nil {
|
if t.GetType() != nil {
|
||||||
return decls.NewTypeType(substitute(m, t.GetType(), typeParamToDyn))
|
return decls.NewTypeType(substitute(m, t.GetType(), typeParamToDyn))
|
||||||
|
56
vendor/github.com/google/cel-go/common/containers/container.go
generated
vendored
56
vendor/github.com/google/cel-go/common/containers/container.go
generated
vendored
@ -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:
|
// 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.N.R.s
|
||||||
// a.b.c.M.R.s
|
// a.b.c.M.R.s
|
||||||
// a.b.c.R.s
|
// a.b.c.R.s
|
||||||
// a.b.R.s
|
// a.b.R.s
|
||||||
// a.R.s
|
// a.R.s
|
||||||
// R.s
|
// R.s
|
||||||
//
|
//
|
||||||
// If aliases or abbreviations are configured for the container, then alias names will take
|
// If aliases or abbreviations are configured for the container, then alias names will take
|
||||||
// precedence over containerized names.
|
// 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
|
// 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:
|
// aliases. Any alias that is found in a qualified name is expanded in the result:
|
||||||
//
|
//
|
||||||
// alias: R -> my.alias.R
|
// alias: R -> my.alias.R
|
||||||
// name: R.S.T
|
// name: R.S.T
|
||||||
// output: my.alias.R.S.T
|
// output: my.alias.R.S.T
|
||||||
//
|
//
|
||||||
// Note, the name must not have a leading dot.
|
// Note, the name must not have a leading dot.
|
||||||
func (c *Container) findAlias(name string) (string, bool) {
|
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
|
// Abbreviations can be useful when working with variables, functions, and especially types from
|
||||||
// multiple namespaces:
|
// multiple namespaces:
|
||||||
//
|
//
|
||||||
// // CEL object construction
|
// // CEL object construction
|
||||||
// qual.pkg.version.ObjTypeName{
|
// qual.pkg.version.ObjTypeName{
|
||||||
// field: alt.container.ver.FieldTypeName{value: ...}
|
// 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
|
// 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
|
// references must be a long qualified name within an otherwise short CEL program. Using the
|
||||||
// following abbreviations, the program becomes much simpler:
|
// following abbreviations, the program becomes much simpler:
|
||||||
//
|
//
|
||||||
// // CEL Go option
|
// // CEL Go option
|
||||||
// Abbrevs("qual.pkg.version.ObjTypeName", "alt.container.ver.FieldTypeName")
|
// Abbrevs("qual.pkg.version.ObjTypeName", "alt.container.ver.FieldTypeName")
|
||||||
// // Simplified Object construction
|
// // Simplified Object construction
|
||||||
// ObjTypeName{field: FieldTypeName{value: ...}}
|
// ObjTypeName{field: FieldTypeName{value: ...}}
|
||||||
//
|
//
|
||||||
// There are a few rules for the qualified names and the simple abbreviations generated from them:
|
// 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`.
|
// - 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.
|
// - The abbreviation must not collide with unqualified names in use.
|
||||||
//
|
//
|
||||||
// Abbreviations are distinct from container-based references in the following important ways:
|
// Abbreviations are distinct from container-based references in the following important ways:
|
||||||
// - Abbreviations must expand to a fully-qualified name.
|
// - Abbreviations must expand to a fully-qualified name.
|
||||||
// - Expanded abbreviations do not participate in namespace resolution.
|
// - Expanded abbreviations do not participate in namespace resolution.
|
||||||
// - Abbreviation expansion is done instead of the container search for a matching identifier.
|
// - 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
|
// - Containers follow C++ namespace resolution rules with searches from the most qualified name
|
||||||
// to the least qualified name.
|
// to the least qualified name.
|
||||||
// - Container references within the CEL program may be relative, and are resolved to fully
|
// - 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.
|
// 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
|
// 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
|
// 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
|
// ToQualifiedName converts an expression AST into a qualified name if possible, with a boolean
|
||||||
// 'found' value that indicates if the conversion is successful.
|
// 'found' value that indicates if the conversion is successful.
|
||||||
func ToQualifiedName(e *exprpb.Expr) (string, bool) {
|
func ToQualifiedName(e *exprpb.Expr) (string, bool) {
|
||||||
switch e.ExprKind.(type) {
|
switch e.GetExprKind().(type) {
|
||||||
case *exprpb.Expr_IdentExpr:
|
case *exprpb.Expr_IdentExpr:
|
||||||
id := e.GetIdentExpr()
|
id := e.GetIdentExpr()
|
||||||
return id.Name, true
|
return id.GetName(), true
|
||||||
case *exprpb.Expr_SelectExpr:
|
case *exprpb.Expr_SelectExpr:
|
||||||
sel := e.GetSelectExpr()
|
sel := e.GetSelectExpr()
|
||||||
// Test only expressions are not valid as qualified names.
|
// Test only expressions are not valid as qualified names.
|
||||||
if sel.GetTestOnly() {
|
if sel.GetTestOnly() {
|
||||||
return "", false
|
return "", false
|
||||||
}
|
}
|
||||||
if qual, found := ToQualifiedName(sel.Operand); found {
|
if qual, found := ToQualifiedName(sel.GetOperand()); found {
|
||||||
return qual + "." + sel.Field, true
|
return qual + "." + sel.GetField(), true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "", false
|
return "", false
|
||||||
|
42
vendor/github.com/google/cel-go/common/debug/debug.go
generated
vendored
42
vendor/github.com/google/cel-go/common/debug/debug.go
generated
vendored
@ -102,9 +102,9 @@ func (w *debugWriter) Buffer(e *exprpb.Expr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *debugWriter) appendSelect(sel *exprpb.Expr_Select) {
|
func (w *debugWriter) appendSelect(sel *exprpb.Expr_Select) {
|
||||||
w.Buffer(sel.Operand)
|
w.Buffer(sel.GetOperand())
|
||||||
w.append(".")
|
w.append(".")
|
||||||
w.append(sel.Field)
|
w.append(sel.GetField())
|
||||||
if sel.TestOnly {
|
if sel.TestOnly {
|
||||||
w.append("~test-only~")
|
w.append("~test-only~")
|
||||||
}
|
}
|
||||||
@ -112,15 +112,15 @@ func (w *debugWriter) appendSelect(sel *exprpb.Expr_Select) {
|
|||||||
|
|
||||||
func (w *debugWriter) appendCall(call *exprpb.Expr_Call) {
|
func (w *debugWriter) appendCall(call *exprpb.Expr_Call) {
|
||||||
if call.Target != nil {
|
if call.Target != nil {
|
||||||
w.Buffer(call.Target)
|
w.Buffer(call.GetTarget())
|
||||||
w.append(".")
|
w.append(".")
|
||||||
}
|
}
|
||||||
w.append(call.Function)
|
w.append(call.GetFunction())
|
||||||
w.append("(")
|
w.append("(")
|
||||||
if len(call.GetArgs()) > 0 {
|
if len(call.GetArgs()) > 0 {
|
||||||
w.addIndent()
|
w.addIndent()
|
||||||
w.appendLine()
|
w.appendLine()
|
||||||
for i, arg := range call.Args {
|
for i, arg := range call.GetArgs() {
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
w.append(",")
|
w.append(",")
|
||||||
w.appendLine()
|
w.appendLine()
|
||||||
@ -138,7 +138,7 @@ func (w *debugWriter) appendList(list *exprpb.Expr_CreateList) {
|
|||||||
if len(list.GetElements()) > 0 {
|
if len(list.GetElements()) > 0 {
|
||||||
w.appendLine()
|
w.appendLine()
|
||||||
w.addIndent()
|
w.addIndent()
|
||||||
for i, elem := range list.Elements {
|
for i, elem := range list.GetElements() {
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
w.append(",")
|
w.append(",")
|
||||||
w.appendLine()
|
w.appendLine()
|
||||||
@ -160,19 +160,19 @@ func (w *debugWriter) appendStruct(obj *exprpb.Expr_CreateStruct) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *debugWriter) appendObject(obj *exprpb.Expr_CreateStruct) {
|
func (w *debugWriter) appendObject(obj *exprpb.Expr_CreateStruct) {
|
||||||
w.append(obj.MessageName)
|
w.append(obj.GetMessageName())
|
||||||
w.append("{")
|
w.append("{")
|
||||||
if len(obj.Entries) > 0 {
|
if len(obj.GetEntries()) > 0 {
|
||||||
w.appendLine()
|
w.appendLine()
|
||||||
w.addIndent()
|
w.addIndent()
|
||||||
for i, entry := range obj.Entries {
|
for i, entry := range obj.GetEntries() {
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
w.append(",")
|
w.append(",")
|
||||||
w.appendLine()
|
w.appendLine()
|
||||||
}
|
}
|
||||||
w.append(entry.GetFieldKey())
|
w.append(entry.GetFieldKey())
|
||||||
w.append(":")
|
w.append(":")
|
||||||
w.Buffer(entry.Value)
|
w.Buffer(entry.GetValue())
|
||||||
w.adorn(entry)
|
w.adorn(entry)
|
||||||
}
|
}
|
||||||
w.removeIndent()
|
w.removeIndent()
|
||||||
@ -183,17 +183,17 @@ func (w *debugWriter) appendObject(obj *exprpb.Expr_CreateStruct) {
|
|||||||
|
|
||||||
func (w *debugWriter) appendMap(obj *exprpb.Expr_CreateStruct) {
|
func (w *debugWriter) appendMap(obj *exprpb.Expr_CreateStruct) {
|
||||||
w.append("{")
|
w.append("{")
|
||||||
if len(obj.Entries) > 0 {
|
if len(obj.GetEntries()) > 0 {
|
||||||
w.appendLine()
|
w.appendLine()
|
||||||
w.addIndent()
|
w.addIndent()
|
||||||
for i, entry := range obj.Entries {
|
for i, entry := range obj.GetEntries() {
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
w.append(",")
|
w.append(",")
|
||||||
w.appendLine()
|
w.appendLine()
|
||||||
}
|
}
|
||||||
w.Buffer(entry.GetMapKey())
|
w.Buffer(entry.GetMapKey())
|
||||||
w.append(":")
|
w.append(":")
|
||||||
w.Buffer(entry.Value)
|
w.Buffer(entry.GetValue())
|
||||||
w.adorn(entry)
|
w.adorn(entry)
|
||||||
}
|
}
|
||||||
w.removeIndent()
|
w.removeIndent()
|
||||||
@ -208,43 +208,43 @@ func (w *debugWriter) appendComprehension(comprehension *exprpb.Expr_Comprehensi
|
|||||||
w.appendLine()
|
w.appendLine()
|
||||||
w.append("// Variable")
|
w.append("// Variable")
|
||||||
w.appendLine()
|
w.appendLine()
|
||||||
w.append(comprehension.IterVar)
|
w.append(comprehension.GetIterVar())
|
||||||
w.append(",")
|
w.append(",")
|
||||||
w.appendLine()
|
w.appendLine()
|
||||||
w.append("// Target")
|
w.append("// Target")
|
||||||
w.appendLine()
|
w.appendLine()
|
||||||
w.Buffer(comprehension.IterRange)
|
w.Buffer(comprehension.GetIterRange())
|
||||||
w.append(",")
|
w.append(",")
|
||||||
w.appendLine()
|
w.appendLine()
|
||||||
w.append("// Accumulator")
|
w.append("// Accumulator")
|
||||||
w.appendLine()
|
w.appendLine()
|
||||||
w.append(comprehension.AccuVar)
|
w.append(comprehension.GetAccuVar())
|
||||||
w.append(",")
|
w.append(",")
|
||||||
w.appendLine()
|
w.appendLine()
|
||||||
w.append("// Init")
|
w.append("// Init")
|
||||||
w.appendLine()
|
w.appendLine()
|
||||||
w.Buffer(comprehension.AccuInit)
|
w.Buffer(comprehension.GetAccuInit())
|
||||||
w.append(",")
|
w.append(",")
|
||||||
w.appendLine()
|
w.appendLine()
|
||||||
w.append("// LoopCondition")
|
w.append("// LoopCondition")
|
||||||
w.appendLine()
|
w.appendLine()
|
||||||
w.Buffer(comprehension.LoopCondition)
|
w.Buffer(comprehension.GetLoopCondition())
|
||||||
w.append(",")
|
w.append(",")
|
||||||
w.appendLine()
|
w.appendLine()
|
||||||
w.append("// LoopStep")
|
w.append("// LoopStep")
|
||||||
w.appendLine()
|
w.appendLine()
|
||||||
w.Buffer(comprehension.LoopStep)
|
w.Buffer(comprehension.GetLoopStep())
|
||||||
w.append(",")
|
w.append(",")
|
||||||
w.appendLine()
|
w.appendLine()
|
||||||
w.append("// Result")
|
w.append("// Result")
|
||||||
w.appendLine()
|
w.appendLine()
|
||||||
w.Buffer(comprehension.Result)
|
w.Buffer(comprehension.GetResult())
|
||||||
w.append(")")
|
w.append(")")
|
||||||
w.removeIndent()
|
w.removeIndent()
|
||||||
}
|
}
|
||||||
|
|
||||||
func formatLiteral(c *exprpb.Constant) string {
|
func formatLiteral(c *exprpb.Constant) string {
|
||||||
switch c.ConstantKind.(type) {
|
switch c.GetConstantKind().(type) {
|
||||||
case *exprpb.Constant_BoolValue:
|
case *exprpb.Constant_BoolValue:
|
||||||
return fmt.Sprintf("%t", c.GetBoolValue())
|
return fmt.Sprintf("%t", c.GetBoolValue())
|
||||||
case *exprpb.Constant_BytesValue:
|
case *exprpb.Constant_BytesValue:
|
||||||
|
4
vendor/github.com/google/cel-go/interpreter/interpretable.go
generated
vendored
4
vendor/github.com/google/cel-go/interpreter/interpretable.go
generated
vendored
@ -835,7 +835,9 @@ func (fold *evalFold) Eval(ctx Activation) ref.Val {
|
|||||||
varActivationPool.Put(accuCtx)
|
varActivationPool.Put(accuCtx)
|
||||||
// Convert a mutable list to an immutable one, if the comprehension has generated a list as a result.
|
// Convert a mutable list to an immutable one, if the comprehension has generated a list as a result.
|
||||||
if !types.IsUnknownOrError(res) && buildingList {
|
if !types.IsUnknownOrError(res) && buildingList {
|
||||||
res = res.(traits.MutableLister).ToImmutableList()
|
if _, ok := res.(traits.MutableLister); ok {
|
||||||
|
res = res.(traits.MutableLister).ToImmutableList()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
57
vendor/github.com/google/cel-go/interpreter/planner.go
generated
vendored
57
vendor/github.com/google/cel-go/interpreter/planner.go
generated
vendored
@ -95,7 +95,7 @@ type planner struct {
|
|||||||
// such as state-tracking, expression re-write, and possibly efficient thread-safe memoization of
|
// such as state-tracking, expression re-write, and possibly efficient thread-safe memoization of
|
||||||
// repeated expressions.
|
// repeated expressions.
|
||||||
func (p *planner) Plan(expr *exprpb.Expr) (Interpretable, error) {
|
func (p *planner) Plan(expr *exprpb.Expr) (Interpretable, error) {
|
||||||
switch expr.ExprKind.(type) {
|
switch expr.GetExprKind().(type) {
|
||||||
case *exprpb.Expr_CallExpr:
|
case *exprpb.Expr_CallExpr:
|
||||||
return p.decorate(p.planCall(expr))
|
return p.decorate(p.planCall(expr))
|
||||||
case *exprpb.Expr_IdentExpr:
|
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) {
|
func (p *planner) planCheckedIdent(id int64, identRef *exprpb.Reference) (Interpretable, error) {
|
||||||
// Plan a constant reference if this is the case for this simple identifier.
|
// 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,
|
return p.Plan(&exprpb.Expr{Id: id,
|
||||||
ExprKind: &exprpb.Expr_ConstExpr{
|
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.
|
// registered with the provider.
|
||||||
cType := p.typeMap[id]
|
cType := p.typeMap[id]
|
||||||
if cType.GetType() != nil {
|
if cType.GetType() != nil {
|
||||||
cVal, found := p.provider.FindIdent(identRef.Name)
|
cVal, found := p.provider.FindIdent(identRef.GetName())
|
||||||
if !found {
|
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
|
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.
|
// Otherwise, return the attribute for the resolved identifier name.
|
||||||
return &evalAttr{
|
return &evalAttr{
|
||||||
adapter: p.adapter,
|
adapter: p.adapter,
|
||||||
attr: p.attrFactory.AbsoluteAttribute(id, identRef.Name),
|
attr: p.attrFactory.AbsoluteAttribute(id, identRef.GetName()),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// planSelect creates an Interpretable with either:
|
// 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.
|
// a) selects a field from a map or proto.
|
||||||
// c) resolves the select expression to a namespaced identifier.
|
// 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) {
|
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
|
// If the Select id appears in the reference map from the CheckedExpr proto then it is either
|
||||||
// a namespaced identifier or enum value.
|
// a namespaced identifier or enum value.
|
||||||
@ -193,7 +194,7 @@ func (p *planner) planSelect(expr *exprpb.Expr) (Interpretable, error) {
|
|||||||
var fieldType *ref.FieldType
|
var fieldType *ref.FieldType
|
||||||
opType := p.typeMap[sel.GetOperand().GetId()]
|
opType := p.typeMap[sel.GetOperand().GetId()]
|
||||||
if opType.GetMessageType() != "" {
|
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 {
|
if found && ft.IsSet != nil && ft.GetFrom != nil {
|
||||||
fieldType = ft
|
fieldType = ft
|
||||||
}
|
}
|
||||||
@ -213,15 +214,15 @@ func (p *planner) planSelect(expr *exprpb.Expr) (Interpretable, error) {
|
|||||||
if sel.TestOnly {
|
if sel.TestOnly {
|
||||||
// Return the test only eval expression.
|
// Return the test only eval expression.
|
||||||
return &evalTestOnly{
|
return &evalTestOnly{
|
||||||
id: expr.Id,
|
id: expr.GetId(),
|
||||||
field: types.String(sel.Field),
|
field: types.String(sel.GetField()),
|
||||||
fieldType: fieldType,
|
fieldType: fieldType,
|
||||||
op: op,
|
op: op,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
// Build a qualifier.
|
// Build a qualifier.
|
||||||
qual, err := p.attrFactory.NewQualifier(
|
qual, err := p.attrFactory.NewQualifier(
|
||||||
opType, expr.Id, sel.Field)
|
opType, expr.GetId(), sel.GetField())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -329,7 +330,7 @@ func (p *planner) planCallZero(expr *exprpb.Expr,
|
|||||||
return nil, fmt.Errorf("no such overload: %s()", function)
|
return nil, fmt.Errorf("no such overload: %s()", function)
|
||||||
}
|
}
|
||||||
return &evalZeroArity{
|
return &evalZeroArity{
|
||||||
id: expr.Id,
|
id: expr.GetId(),
|
||||||
function: function,
|
function: function,
|
||||||
overload: overload,
|
overload: overload,
|
||||||
impl: impl.Function,
|
impl: impl.Function,
|
||||||
@ -354,7 +355,7 @@ func (p *planner) planCallUnary(expr *exprpb.Expr,
|
|||||||
nonStrict = impl.NonStrict
|
nonStrict = impl.NonStrict
|
||||||
}
|
}
|
||||||
return &evalUnary{
|
return &evalUnary{
|
||||||
id: expr.Id,
|
id: expr.GetId(),
|
||||||
function: function,
|
function: function,
|
||||||
overload: overload,
|
overload: overload,
|
||||||
arg: args[0],
|
arg: args[0],
|
||||||
@ -382,7 +383,7 @@ func (p *planner) planCallBinary(expr *exprpb.Expr,
|
|||||||
nonStrict = impl.NonStrict
|
nonStrict = impl.NonStrict
|
||||||
}
|
}
|
||||||
return &evalBinary{
|
return &evalBinary{
|
||||||
id: expr.Id,
|
id: expr.GetId(),
|
||||||
function: function,
|
function: function,
|
||||||
overload: overload,
|
overload: overload,
|
||||||
lhs: args[0],
|
lhs: args[0],
|
||||||
@ -411,7 +412,7 @@ func (p *planner) planCallVarArgs(expr *exprpb.Expr,
|
|||||||
nonStrict = impl.NonStrict
|
nonStrict = impl.NonStrict
|
||||||
}
|
}
|
||||||
return &evalVarArgs{
|
return &evalVarArgs{
|
||||||
id: expr.Id,
|
id: expr.GetId(),
|
||||||
function: function,
|
function: function,
|
||||||
overload: overload,
|
overload: overload,
|
||||||
args: args,
|
args: args,
|
||||||
@ -425,7 +426,7 @@ func (p *planner) planCallVarArgs(expr *exprpb.Expr,
|
|||||||
func (p *planner) planCallEqual(expr *exprpb.Expr,
|
func (p *planner) planCallEqual(expr *exprpb.Expr,
|
||||||
args []Interpretable) (Interpretable, error) {
|
args []Interpretable) (Interpretable, error) {
|
||||||
return &evalEq{
|
return &evalEq{
|
||||||
id: expr.Id,
|
id: expr.GetId(),
|
||||||
lhs: args[0],
|
lhs: args[0],
|
||||||
rhs: args[1],
|
rhs: args[1],
|
||||||
}, nil
|
}, nil
|
||||||
@ -435,7 +436,7 @@ func (p *planner) planCallEqual(expr *exprpb.Expr,
|
|||||||
func (p *planner) planCallNotEqual(expr *exprpb.Expr,
|
func (p *planner) planCallNotEqual(expr *exprpb.Expr,
|
||||||
args []Interpretable) (Interpretable, error) {
|
args []Interpretable) (Interpretable, error) {
|
||||||
return &evalNe{
|
return &evalNe{
|
||||||
id: expr.Id,
|
id: expr.GetId(),
|
||||||
lhs: args[0],
|
lhs: args[0],
|
||||||
rhs: args[1],
|
rhs: args[1],
|
||||||
}, nil
|
}, nil
|
||||||
@ -445,7 +446,7 @@ func (p *planner) planCallNotEqual(expr *exprpb.Expr,
|
|||||||
func (p *planner) planCallLogicalAnd(expr *exprpb.Expr,
|
func (p *planner) planCallLogicalAnd(expr *exprpb.Expr,
|
||||||
args []Interpretable) (Interpretable, error) {
|
args []Interpretable) (Interpretable, error) {
|
||||||
return &evalAnd{
|
return &evalAnd{
|
||||||
id: expr.Id,
|
id: expr.GetId(),
|
||||||
lhs: args[0],
|
lhs: args[0],
|
||||||
rhs: args[1],
|
rhs: args[1],
|
||||||
}, nil
|
}, nil
|
||||||
@ -455,7 +456,7 @@ func (p *planner) planCallLogicalAnd(expr *exprpb.Expr,
|
|||||||
func (p *planner) planCallLogicalOr(expr *exprpb.Expr,
|
func (p *planner) planCallLogicalOr(expr *exprpb.Expr,
|
||||||
args []Interpretable) (Interpretable, error) {
|
args []Interpretable) (Interpretable, error) {
|
||||||
return &evalOr{
|
return &evalOr{
|
||||||
id: expr.Id,
|
id: expr.GetId(),
|
||||||
lhs: args[0],
|
lhs: args[0],
|
||||||
rhs: args[1],
|
rhs: args[1],
|
||||||
}, nil
|
}, nil
|
||||||
@ -486,7 +487,7 @@ func (p *planner) planCallConditional(expr *exprpb.Expr,
|
|||||||
|
|
||||||
return &evalAttr{
|
return &evalAttr{
|
||||||
adapter: p.adapter,
|
adapter: p.adapter,
|
||||||
attr: p.attrFactory.ConditionalAttribute(expr.Id, cond, tAttr, fAttr),
|
attr: p.attrFactory.ConditionalAttribute(expr.GetId(), cond, tAttr, fAttr),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -541,7 +542,7 @@ func (p *planner) planCreateList(expr *exprpb.Expr) (Interpretable, error) {
|
|||||||
elems[i] = elemVal
|
elems[i] = elemVal
|
||||||
}
|
}
|
||||||
return &evalList{
|
return &evalList{
|
||||||
id: expr.Id,
|
id: expr.GetId(),
|
||||||
elems: elems,
|
elems: elems,
|
||||||
adapter: p.adapter,
|
adapter: p.adapter,
|
||||||
}, nil
|
}, nil
|
||||||
@ -570,7 +571,7 @@ func (p *planner) planCreateStruct(expr *exprpb.Expr) (Interpretable, error) {
|
|||||||
vals[i] = valVal
|
vals[i] = valVal
|
||||||
}
|
}
|
||||||
return &evalMap{
|
return &evalMap{
|
||||||
id: expr.Id,
|
id: expr.GetId(),
|
||||||
keys: keys,
|
keys: keys,
|
||||||
vals: vals,
|
vals: vals,
|
||||||
adapter: p.adapter,
|
adapter: p.adapter,
|
||||||
@ -596,7 +597,7 @@ func (p *planner) planCreateObj(expr *exprpb.Expr) (Interpretable, error) {
|
|||||||
vals[i] = val
|
vals[i] = val
|
||||||
}
|
}
|
||||||
return &evalObj{
|
return &evalObj{
|
||||||
id: expr.Id,
|
id: expr.GetId(),
|
||||||
typeName: typeName,
|
typeName: typeName,
|
||||||
fields: fields,
|
fields: fields,
|
||||||
vals: vals,
|
vals: vals,
|
||||||
@ -628,7 +629,7 @@ func (p *planner) planComprehension(expr *exprpb.Expr) (Interpretable, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &evalFold{
|
return &evalFold{
|
||||||
id: expr.Id,
|
id: expr.GetId(),
|
||||||
accuVar: fold.AccuVar,
|
accuVar: fold.AccuVar,
|
||||||
accu: accu,
|
accu: accu,
|
||||||
iterVar: fold.IterVar,
|
iterVar: fold.IterVar,
|
||||||
@ -646,12 +647,12 @@ func (p *planner) planConst(expr *exprpb.Expr) (Interpretable, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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.
|
// constValue converts a proto Constant value to a ref.Val.
|
||||||
func (p *planner) constValue(c *exprpb.Constant) (ref.Val, error) {
|
func (p *planner) constValue(c *exprpb.Constant) (ref.Val, error) {
|
||||||
switch c.ConstantKind.(type) {
|
switch c.GetConstantKind().(type) {
|
||||||
case *exprpb.Constant_BoolValue:
|
case *exprpb.Constant_BoolValue:
|
||||||
return p.adapter.NativeToValue(c.GetBoolValue()), nil
|
return p.adapter.NativeToValue(c.GetBoolValue()), nil
|
||||||
case *exprpb.Constant_BytesValue:
|
case *exprpb.Constant_BytesValue:
|
||||||
|
18
vendor/github.com/google/cel-go/interpreter/prune.go
generated
vendored
18
vendor/github.com/google/cel-go/interpreter/prune.go
generated
vendored
@ -41,17 +41,23 @@ type astPruner struct {
|
|||||||
// A)
|
// A)
|
||||||
// 1) Evaluate expr with some unknowns,
|
// 1) Evaluate expr with some unknowns,
|
||||||
// 2) If result is unknown:
|
// 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
|
// Functional call results which are known would be effectively cached across
|
||||||
// iterations.
|
// iterations.
|
||||||
//
|
//
|
||||||
// B)
|
// B)
|
||||||
// 1) Compile the expression (maybe via a service and maybe after checking a
|
// 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.
|
// 2) Prepare the environment and the interpreter. Activation might be empty.
|
||||||
// 3) Eval the expression. This might return unknown or error or a concrete
|
// 3) Eval the expression. This might return unknown or error or a concrete
|
||||||
// value.
|
//
|
||||||
|
// value.
|
||||||
|
//
|
||||||
// 4) PruneAst
|
// 4) PruneAst
|
||||||
// 4) Maybe cache the expression
|
// 4) Maybe cache the expression
|
||||||
// This is effectively constant folding the expression. How the environment is
|
// 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
|
// transform, or expression was not evaluated. If possible, drill down
|
||||||
// more.
|
// more.
|
||||||
|
|
||||||
switch node.ExprKind.(type) {
|
switch node.GetExprKind().(type) {
|
||||||
case *exprpb.Expr_SelectExpr:
|
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{
|
return &exprpb.Expr{
|
||||||
Id: node.GetId(),
|
Id: node.GetId(),
|
||||||
ExprKind: &exprpb.Expr_SelectExpr{
|
ExprKind: &exprpb.Expr_SelectExpr{
|
||||||
|
2
vendor/github.com/google/cel-go/parser/helper.go
generated
vendored
2
vendor/github.com/google/cel-go/parser/helper.go
generated
vendored
@ -217,7 +217,7 @@ func (p *parserHelper) buildMacroCallArg(expr *exprpb.Expr) *exprpb.Expr {
|
|||||||
return &exprpb.Expr{Id: expr.GetId()}
|
return &exprpb.Expr{Id: expr.GetId()}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch expr.ExprKind.(type) {
|
switch expr.GetExprKind().(type) {
|
||||||
case *exprpb.Expr_CallExpr:
|
case *exprpb.Expr_CallExpr:
|
||||||
// Iterate the AST from `expr` recursively looking for macros. Because we are at most
|
// 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
|
// starting from the top level macro, this recursion is bounded by the size of the AST. This
|
||||||
|
6
vendor/github.com/google/cel-go/parser/parser.go
generated
vendored
6
vendor/github.com/google/cel-go/parser/parser.go
generated
vendored
@ -807,13 +807,13 @@ func (p *parser) extractQualifiedName(e *exprpb.Expr) (string, bool) {
|
|||||||
if e == nil {
|
if e == nil {
|
||||||
return "", false
|
return "", false
|
||||||
}
|
}
|
||||||
switch e.ExprKind.(type) {
|
switch e.GetExprKind().(type) {
|
||||||
case *exprpb.Expr_IdentExpr:
|
case *exprpb.Expr_IdentExpr:
|
||||||
return e.GetIdentExpr().GetName(), true
|
return e.GetIdentExpr().GetName(), true
|
||||||
case *exprpb.Expr_SelectExpr:
|
case *exprpb.Expr_SelectExpr:
|
||||||
s := e.GetSelectExpr()
|
s := e.GetSelectExpr()
|
||||||
if prefix, found := p.extractQualifiedName(s.Operand); found {
|
if prefix, found := p.extractQualifiedName(s.GetOperand()); found {
|
||||||
return prefix + "." + s.Field, true
|
return prefix + "." + s.GetField(), true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO: Add a method to Source to get location from character offset.
|
// TODO: Add a method to Source to get location from character offset.
|
||||||
|
4
vendor/github.com/google/cel-go/parser/unparser.go
generated
vendored
4
vendor/github.com/google/cel-go/parser/unparser.go
generated
vendored
@ -81,7 +81,7 @@ func (un *unparser) visit(expr *exprpb.Expr) error {
|
|||||||
if visited || err != nil {
|
if visited || err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
switch expr.ExprKind.(type) {
|
switch expr.GetExprKind().(type) {
|
||||||
case *exprpb.Expr_CallExpr:
|
case *exprpb.Expr_CallExpr:
|
||||||
return un.visitCall(expr)
|
return un.visitCall(expr)
|
||||||
case *exprpb.Expr_ConstExpr:
|
case *exprpb.Expr_ConstExpr:
|
||||||
@ -249,7 +249,7 @@ func (un *unparser) visitCallUnary(expr *exprpb.Expr) error {
|
|||||||
|
|
||||||
func (un *unparser) visitConst(expr *exprpb.Expr) error {
|
func (un *unparser) visitConst(expr *exprpb.Expr) error {
|
||||||
c := expr.GetConstExpr()
|
c := expr.GetConstExpr()
|
||||||
switch c.ConstantKind.(type) {
|
switch c.GetConstantKind().(type) {
|
||||||
case *exprpb.Constant_BoolValue:
|
case *exprpb.Constant_BoolValue:
|
||||||
un.str.WriteString(strconv.FormatBool(c.GetBoolValue()))
|
un.str.WriteString(strconv.FormatBool(c.GetBoolValue()))
|
||||||
case *exprpb.Constant_BytesValue:
|
case *exprpb.Constant_BytesValue:
|
||||||
|
4
vendor/modules.txt
vendored
4
vendor/modules.txt
vendored
@ -411,7 +411,7 @@ github.com/google/cadvisor/utils/sysfs
|
|||||||
github.com/google/cadvisor/utils/sysinfo
|
github.com/google/cadvisor/utils/sysinfo
|
||||||
github.com/google/cadvisor/version
|
github.com/google/cadvisor/version
|
||||||
github.com/google/cadvisor/watcher
|
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
|
## explicit; go 1.17
|
||||||
github.com/google/cel-go/cel
|
github.com/google/cel-go/cel
|
||||||
github.com/google/cel-go/checker
|
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/golangplus/testing => github.com/golangplus/testing v1.0.0
|
||||||
# github.com/google/btree => github.com/google/btree v1.0.1
|
# 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/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/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/go-cmp => github.com/google/go-cmp v0.5.6
|
||||||
# github.com/google/gofuzz => github.com/google/gofuzz v1.1.0
|
# github.com/google/gofuzz => github.com/google/gofuzz v1.1.0
|
||||||
|
Loading…
Reference in New Issue
Block a user