Skip to content

Commit 67edae4

Browse files
committed
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.
1 parent 04f8aad commit 67edae4

File tree

1 file changed

+5
-0
lines changed
  • staging/src/k8s.io/apiserver/pkg/cel

1 file changed

+5
-0
lines changed

staging/src/k8s.io/apiserver/pkg/cel/types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828

2929
exprpb "google.golang.org/genproto/googleapis/api/expr/v1alpha1"
3030
"google.golang.org/protobuf/proto"
31+
"k8s.io/apimachinery/pkg/api/resource"
3132
)
3233

3334
const (
@@ -576,6 +577,10 @@ var (
576577
// labeled as Timestamp will necessarily have the same MinSerializedSize.
577578
TimestampType = NewSimpleTypeWithMinSize("timestamp", cel.TimestampType, types.Timestamp{Time: time.Time{}}, JSONDateSize)
578579

580+
// QuantityDeclType wraps a [QuantityType] and makes it usable with functions that expect
581+
// a [DeclType].
582+
QuantityDeclType = NewSimpleTypeWithMinSize("quantity", QuantityType, Quantity{Quantity: resource.NewQuantity(0, resource.DecimalSI)}, 8)
583+
579584
// UintType is equivalent to the CEL 'uint' type.
580585
UintType = NewSimpleTypeWithMinSize("uint", cel.UintType, types.Uint(0), 1)
581586

0 commit comments

Comments
 (0)