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:
		@@ -28,6 +28,7 @@ import (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	exprpb "google.golang.org/genproto/googleapis/api/expr/v1alpha1"
 | 
						exprpb "google.golang.org/genproto/googleapis/api/expr/v1alpha1"
 | 
				
			||||||
	"google.golang.org/protobuf/proto"
 | 
						"google.golang.org/protobuf/proto"
 | 
				
			||||||
 | 
						"k8s.io/apimachinery/pkg/api/resource"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const (
 | 
					const (
 | 
				
			||||||
@@ -576,6 +577,10 @@ var (
 | 
				
			|||||||
	// labeled as Timestamp will necessarily have the same MinSerializedSize.
 | 
						// labeled as Timestamp will necessarily have the same MinSerializedSize.
 | 
				
			||||||
	TimestampType = NewSimpleTypeWithMinSize("timestamp", cel.TimestampType, types.Timestamp{Time: time.Time{}}, JSONDateSize)
 | 
						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 is equivalent to the CEL 'uint' type.
 | 
				
			||||||
	UintType = NewSimpleTypeWithMinSize("uint", cel.UintType, types.Uint(0), 1)
 | 
						UintType = NewSimpleTypeWithMinSize("uint", cel.UintType, types.Uint(0), 1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user