mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-16 15:20:17 +00:00
Update k8s code to handle cel-go changes
This commit is contained in:
parent
1a850a0063
commit
640a2ec332
@ -578,7 +578,7 @@ type decisionVal struct {
|
|||||||
// any object type that has receiver functions but does not expose any fields to
|
// any object type that has receiver functions but does not expose any fields to
|
||||||
// CEL.
|
// CEL.
|
||||||
type receiverOnlyObjectVal struct {
|
type receiverOnlyObjectVal struct {
|
||||||
typeValue *types.TypeValue
|
typeValue *types.Type
|
||||||
}
|
}
|
||||||
|
|
||||||
// receiverOnlyVal returns a receiverOnlyObjectVal for the given type.
|
// receiverOnlyVal returns a receiverOnlyObjectVal for the given type.
|
||||||
|
@ -101,8 +101,8 @@ func (l *CostEstimator) EstimateCallCost(function, overloadId string, target *ch
|
|||||||
// If the list contains strings or bytes, add the cost of traversing all the strings/bytes as a way
|
// If the list contains strings or bytes, add the cost of traversing all the strings/bytes as a way
|
||||||
// of estimating the additional comparison cost.
|
// of estimating the additional comparison cost.
|
||||||
if elNode := l.listElementNode(*target); elNode != nil {
|
if elNode := l.listElementNode(*target); elNode != nil {
|
||||||
t := elNode.Type().GetPrimitive()
|
k := elNode.Type().Kind()
|
||||||
if t == exprpb.Type_STRING || t == exprpb.Type_BYTES {
|
if k == types.StructKind || k == types.BytesKind {
|
||||||
sz := l.sizeEstimate(elNode)
|
sz := l.sizeEstimate(elNode)
|
||||||
elCost = elCost.Add(sz.MultiplyByCostFactor(common.StringTraversalCostFactor))
|
elCost = elCost.Add(sz.MultiplyByCostFactor(common.StringTraversalCostFactor))
|
||||||
}
|
}
|
||||||
@ -247,7 +247,8 @@ func (l *CostEstimator) sizeEstimate(t checker.AstNode) checker.SizeEstimate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (l *CostEstimator) listElementNode(list checker.AstNode) checker.AstNode {
|
func (l *CostEstimator) listElementNode(list checker.AstNode) checker.AstNode {
|
||||||
if lt := list.Type().GetListType(); lt != nil {
|
if params := list.Type().Parameters(); len(params) > 0 {
|
||||||
|
lt := params[0]
|
||||||
nodePath := list.Path()
|
nodePath := list.Path()
|
||||||
if nodePath != nil {
|
if nodePath != nil {
|
||||||
// Provide path if we have it so that a OpenAPIv3 maxLength validation can be looked up, if it exists
|
// Provide path if we have it so that a OpenAPIv3 maxLength validation can be looked up, if it exists
|
||||||
@ -255,10 +256,10 @@ func (l *CostEstimator) listElementNode(list checker.AstNode) checker.AstNode {
|
|||||||
path := make([]string, len(nodePath)+1)
|
path := make([]string, len(nodePath)+1)
|
||||||
copy(path, nodePath)
|
copy(path, nodePath)
|
||||||
path[len(nodePath)] = "@items"
|
path[len(nodePath)] = "@items"
|
||||||
return &itemsNode{path: path, t: lt.GetElemType(), expr: nil}
|
return &itemsNode{path: path, t: lt, expr: nil}
|
||||||
} else {
|
} else {
|
||||||
// Provide just the type if no path is available so that worst case size can be looked up based on type.
|
// Provide just the type if no path is available so that worst case size can be looked up based on type.
|
||||||
return &itemsNode{t: lt.GetElemType(), expr: nil}
|
return &itemsNode{t: lt, expr: nil}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -273,7 +274,7 @@ func (l *CostEstimator) EstimateSize(element checker.AstNode) *checker.SizeEstim
|
|||||||
|
|
||||||
type itemsNode struct {
|
type itemsNode struct {
|
||||||
path []string
|
path []string
|
||||||
t *exprpb.Type
|
t *types.Type
|
||||||
expr *exprpb.Expr
|
expr *exprpb.Expr
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,7 +282,7 @@ func (i *itemsNode) Path() []string {
|
|||||||
return i.path
|
return i.path
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *itemsNode) Type() *exprpb.Type {
|
func (i *itemsNode) Type() *types.Type {
|
||||||
return i.t
|
return i.t
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user