mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 17:30:00 +00:00
CEL: add QuantityDeclType
Most functions in k8s.io/apiserver/pkg/cel work with DeclType for type definitions, which made the existing QuantityType unusable with them. The new QuantityDeclType fills that gap.
This commit is contained in:
parent
62d21589ef
commit
bcececadfb
@ -28,6 +28,7 @@ import (
|
||||
|
||||
exprpb "google.golang.org/genproto/googleapis/api/expr/v1alpha1"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -576,6 +577,10 @@ var (
|
||||
// labeled as Timestamp will necessarily have the same MinSerializedSize.
|
||||
TimestampType = NewSimpleTypeWithMinSize("timestamp", cel.TimestampType, types.Timestamp{Time: time.Time{}}, JSONDateSize)
|
||||
|
||||
// QuantityDeclType wraps a [QuantityType] and makes it usable with functions that expect
|
||||
// a [DeclType].
|
||||
QuantityDeclType = NewSimpleTypeWithMinSize("quantity", QuantityType, Quantity{Quantity: resource.NewQuantity(0, resource.DecimalSI)}, 8)
|
||||
|
||||
// UintType is equivalent to the CEL 'uint' type.
|
||||
UintType = NewSimpleTypeWithMinSize("uint", cel.UintType, types.Uint(0), 1)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user