package common
import "k8s.io/apiserver/pkg/cel/mutation/common"
Index ¶
- Constants
- type ObjectVal
- func NewObjectVal(typeRef TypeRef, fields map[string]ref.Val) *ObjectVal
- func (v *ObjectVal) ConvertToNative(typeDesc reflect.Type) (any, error)
- func (v *ObjectVal) ConvertToType(typeValue ref.Type) ref.Val
- func (v *ObjectVal) Equal(other ref.Val) ref.Val
- func (v *ObjectVal) IsZeroValue() bool
- func (v *ObjectVal) Type() ref.Type
- func (v *ObjectVal) Value() any
- type TypeRef
- type TypeResolver
Constants ¶
const ObjectTraits = traits.ContainerType
ObjectTraits is the bitmask that represents traits that an object should have.
const RootTypeReferenceName = "Object"
RootTypeReferenceName is the root reference that all type names should start with.
Types ¶
type ObjectVal ¶
type ObjectVal struct {
// contains filtered or unexported fields
}
ObjectVal is the CEL Val for an object that is constructed via the object construction syntax.
func NewObjectVal ¶
NewObjectVal creates an ObjectVal by its TypeRef and its fields.
func (*ObjectVal) ConvertToNative ¶
ConvertToNative converts the object to map[string]any. All nested lists are converted into []any native type.
It returns an error if the target type is not map[string]any, or any recursive conversion fails.
func (*ObjectVal) ConvertToType ¶
ConvertToType supports type conversions between CEL value types supported by the expression language.
func (*ObjectVal) Equal ¶
Equal returns true if the `other` value has the same type and content as the implementing struct.
func (*ObjectVal) IsZeroValue ¶
IsZeroValue indicates whether the object is the zero value for the type. For the ObjectVal, it is zero value if and only if the fields map is empty.
func (*ObjectVal) Type ¶
Type returns the TypeValue of the value.
func (*ObjectVal) Value ¶
Value returns its value as a map[string]any.
type TypeRef ¶
type TypeRef interface { ref.Type // CELType wraps the TypeRef to be a type that is understood by CEL. CELType() *types.Type // Field finds the field by the field name, or false if the field is not known. // This function directly return a FieldType that is known to CEL to be more customizable. Field(name string) (*types.FieldType, bool) // Val creates an instance for the TypeRef, given its fields and their values. Val(fields map[string]ref.Val) ref.Val }
TypeRef refers an object type that can be looked up for its fields.
type TypeResolver ¶
type TypeResolver interface { // Resolve resolves the type by its name, starting with "Object" as its root. // The type that the name refers to must be an object. // This function returns false if the name does not refer to a known object type. Resolve(name string) (TypeRef, bool) }
TypeResolver resolves a type by a given name.
Source Files ¶
constants.go interface.go val.go
- Version
- v0.31.2
- Published
- Oct 23, 2024
- Platform
- js/wasm
- Imports
- 5 packages
- Last checked
- 1 second ago –
Tools for package owners.