types
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Overview¶
Package types contains the types, traits, and utilities common to allcomponents of expression handling.
Index¶
- Constants
- Variables
- func DurationGetHours(val ref.Val) ref.Val
- func DurationGetMilliseconds(val ref.Val) ref.Val
- func DurationGetMinutes(val ref.Val) ref.Val
- func DurationGetSeconds(val ref.Val) ref.Val
- func Equal(lhs ref.Val, rhs ref.Val) ref.Val
- func Format(val ref.Val) string
- func IndexOrError(index ref.Val) (int, error)
- func InsertMapKeyValue(m traits.Mapper, k, v ref.Val) ref.Val
- func IsBool(elem ref.Val) bool
- func IsError(val ref.Val) bool
- func IsPrimitiveType(val ref.Val) bool
- func IsUnknown(val ref.Val) bool
- func IsUnknownOrError(val ref.Val) bool
- func LabelErrNode(id int64, val ref.Val) ref.Val
- func MaybeNoSuchOverloadErr(val ref.Val) ref.Val
- func NewDynamicList(adapter Adapter, value any) traits.Lister
- func NewDynamicMap(adapter Adapter, value any) traits.Mapper
- func NewErr(format string, args ...any) ref.Val
- func NewErrFromString(message string) ref.Val
- func NewErrWithNodeID(id int64, format string, args ...any) ref.Val
- func NewJSONList(adapter Adapter, l *structpb.ListValue) traits.Lister
- func NewJSONStruct(adapter Adapter, value *structpb.Struct) traits.Mapper
- func NewMutableList(adapter Adapter) traits.MutableLister
- func NewMutableMap(adapter Adapter, mutableValues map[ref.Val]ref.Val) traits.MutableMapper
- func NewObject(adapter Adapter, typeDesc *pb.TypeDescription, typeValue ref.Val, ...) ref.Val
- func NewProtoList(adapter Adapter, list protoreflect.List) traits.Lister
- func NewProtoMap(adapter Adapter, value *pb.Map) traits.Mapper
- func NewRefValList(adapter Adapter, elems []ref.Val) traits.Lister
- func NewRefValMap(adapter Adapter, value map[ref.Val]ref.Val) traits.Mapper
- func NewStringInterfaceMap(adapter Adapter, value map[string]any) traits.Mapper
- func NewStringList(adapter Adapter, elems []string) traits.Lister
- func NewStringStringMap(adapter Adapter, value map[string]string) traits.Mapper
- func NoSuchOverloadErr() ref.Val
- func StringContains(s, sub ref.Val) ref.Val
- func StringEndsWith(s, suf ref.Val) ref.Val
- func StringStartsWith(s, pre ref.Val) ref.Val
- func ToFoldableList(l traits.Lister) traits.Foldable
- func ToFoldableMap(m traits.Mapper) traits.Foldable
- func TypeToExprType(t *Type) (*exprpb.Type, error)
- func TypeToProto(t *Type) (*celpb.Type, error)
- func UnsupportedRefValConversionErr(val any) ref.Val
- func ValOrErr(val ref.Val, format string, args ...any) ref.Val
- func WrapErr(err error) ref.Val
- type Adapter
- type AttributeQualifier
- type AttributeTrail
- type Bool
- func (b Bool) Compare(other ref.Val) ref.Val
- func (b Bool) ConvertToNative(typeDesc reflect.Type) (any, error)
- func (b Bool) ConvertToType(typeVal ref.Type) ref.Val
- func (b Bool) Equal(other ref.Val) ref.Val
- func (b Bool) IsZeroValue() bool
- func (b Bool) Negate() ref.Val
- func (b Bool) Type() ref.Type
- func (b Bool) Value() any
- type Bytes
- func (b Bytes) Add(other ref.Val) ref.Val
- func (b Bytes) Compare(other ref.Val) ref.Val
- func (b Bytes) ConvertToNative(typeDesc reflect.Type) (any, error)
- func (b Bytes) ConvertToType(typeVal ref.Type) ref.Val
- func (b Bytes) Equal(other ref.Val) ref.Val
- func (b Bytes) IsZeroValue() bool
- func (b Bytes) Size() ref.Val
- func (b Bytes) Type() ref.Type
- func (b Bytes) Value() any
- type Double
- func (d Double) Add(other ref.Val) ref.Val
- func (d Double) Compare(other ref.Val) ref.Val
- func (d Double) ConvertToNative(typeDesc reflect.Type) (any, error)
- func (d Double) ConvertToType(typeVal ref.Type) ref.Val
- func (d Double) Divide(other ref.Val) ref.Val
- func (d Double) Equal(other ref.Val) ref.Val
- func (d Double) IsZeroValue() bool
- func (d Double) Multiply(other ref.Val) ref.Val
- func (d Double) Negate() ref.Val
- func (d Double) Subtract(subtrahend ref.Val) ref.Val
- func (d Double) Type() ref.Type
- func (d Double) Value() any
- type Duration
- func (d Duration) Add(other ref.Val) ref.Val
- func (d Duration) Compare(other ref.Val) ref.Val
- func (d Duration) ConvertToNative(typeDesc reflect.Type) (any, error)
- func (d Duration) ConvertToType(typeVal ref.Type) ref.Val
- func (d Duration) Equal(other ref.Val) ref.Val
- func (d Duration) IsZeroValue() bool
- func (d Duration) Negate() ref.Val
- func (d Duration) Receive(function string, overload string, args []ref.Val) ref.Val
- func (d Duration) Subtract(subtrahend ref.Val) ref.Val
- func (d Duration) Type() ref.Type
- func (d Duration) Value() any
- type Err
- func (e *Err) ConvertToNative(typeDesc reflect.Type) (any, error)
- func (e *Err) ConvertToType(typeVal ref.Type) ref.Val
- func (e *Err) Equal(other ref.Val) ref.Val
- func (e *Err) Is(target error) bool
- func (e *Err) NodeID() int64
- func (e *Err) String() string
- func (e *Err) Type() ref.Type
- func (e *Err) Unwrap() error
- func (e *Err) Value() any
- type Error
- type FieldType
- type Int
- func (i Int) Add(other ref.Val) ref.Val
- func (i Int) Compare(other ref.Val) ref.Val
- func (i Int) ConvertToNative(typeDesc reflect.Type) (any, error)
- func (i Int) ConvertToType(typeVal ref.Type) ref.Val
- func (i Int) Divide(other ref.Val) ref.Val
- func (i Int) Equal(other ref.Val) ref.Val
- func (i Int) IsZeroValue() bool
- func (i Int) Modulo(other ref.Val) ref.Val
- func (i Int) Multiply(other ref.Val) ref.Val
- func (i Int) Negate() ref.Val
- func (i Int) Subtract(subtrahend ref.Val) ref.Val
- func (i Int) Type() ref.Type
- func (i Int) Value() any
- type Kind
- type Null
- type Optional
- func (o *Optional) ConvertToNative(typeDesc reflect.Type) (any, error)
- func (o *Optional) ConvertToType(typeVal ref.Type) ref.Val
- func (o *Optional) Equal(other ref.Val) ref.Val
- func (o *Optional) GetValue() ref.Val
- func (o *Optional) HasValue() bool
- func (o *Optional) String() string
- func (o *Optional) Type() ref.Type
- func (o *Optional) Value() any
- type Provider
- type Registry
- func (p *Registry) Copy() *Registry
- func (p *Registry) EnumValue(enumName string) ref.Val
- func (p *Registry) FindFieldType(structType, fieldName string) (*ref.FieldType, bool)deprecated
- func (p *Registry) FindIdent(identName string) (ref.Val, bool)
- func (p *Registry) FindStructFieldNames(structType string) ([]string, bool)
- func (p *Registry) FindStructFieldType(structType, fieldName string) (*FieldType, bool)
- func (p *Registry) FindStructType(structType string) (*Type, bool)
- func (p *Registry) FindType(structType string) (*exprpb.Type, bool)deprecated
- func (p *Registry) NativeToValue(value any) ref.Val
- func (p *Registry) NewValue(structType string, fields map[string]ref.Val) ref.Val
- func (p *Registry) RegisterDescriptor(fileDesc protoreflect.FileDescriptor) error
- func (p *Registry) RegisterMessage(message proto.Message) error
- func (p *Registry) RegisterType(types ...ref.Type) error
- type String
- func (s String) Add(other ref.Val) ref.Val
- func (s String) Compare(other ref.Val) ref.Val
- func (s String) ConvertToNative(typeDesc reflect.Type) (any, error)
- func (s String) ConvertToType(typeVal ref.Type) ref.Val
- func (s String) Equal(other ref.Val) ref.Val
- func (s String) IsZeroValue() bool
- func (s String) Match(pattern ref.Val) ref.Val
- func (s String) Receive(function string, overload string, args []ref.Val) ref.Val
- func (s String) Size() ref.Val
- func (s String) Type() ref.Type
- func (s String) Value() any
- type Timestamp
- func (t Timestamp) Add(other ref.Val) ref.Val
- func (t Timestamp) Compare(other ref.Val) ref.Val
- func (t Timestamp) ConvertToNative(typeDesc reflect.Type) (any, error)
- func (t Timestamp) ConvertToType(typeVal ref.Type) ref.Val
- func (t Timestamp) Equal(other ref.Val) ref.Val
- func (t Timestamp) IsZeroValue() bool
- func (t Timestamp) Receive(function string, overload string, args []ref.Val) ref.Val
- func (t Timestamp) Subtract(subtrahend ref.Val) ref.Val
- func (t Timestamp) Type() ref.Type
- func (t Timestamp) Value() any
- type Type
- func AlphaProtoAsType(t *exprpb.Type) (*Type, error)
- func ExprTypeToType(t *exprpb.Type) (*Type, error)
- func NewListType(elemType *Type) *Type
- func NewMapType(keyType, valueType *Type) *Type
- func NewNullableType(wrapped *Type) *Type
- func NewObjectType(typeName string, traits ...int) *Type
- func NewObjectTypeValue(typeName string) *Typedeprecated
- func NewOpaqueType(name string, params ...*Type) *Type
- func NewOptionalType(param *Type) *Type
- func NewTypeParamType(paramName string) *Type
- func NewTypeTypeWithParam(param *Type) *Type
- func NewTypeValue(typeName string, traits ...int) *Typedeprecated
- func ProtoAsType(t *celpb.Type) (*Type, error)
- func (t *Type) ConvertToNative(typeDesc reflect.Type) (any, error)
- func (t *Type) ConvertToType(typeVal ref.Type) ref.Val
- func (t *Type) DeclaredTypeName() string
- func (t *Type) Equal(other ref.Val) ref.Val
- func (t *Type) HasTrait(trait int) bool
- func (t *Type) IsAssignableRuntimeType(val ref.Val) bool
- func (t *Type) IsAssignableType(fromType *Type) bool
- func (t *Type) IsEquivalentType(other *Type) bool
- func (t *Type) IsExactType(other *Type) bool
- func (t *Type) Kind() Kind
- func (t *Type) Parameters() []*Type
- func (t *Type) String() string
- func (t *Type) Type() ref.Type
- func (t *Type) TypeName() string
- func (t *Type) Value() any
- func (t *Type) WithTraits(traits int) *Type
- type Uint
- func (i Uint) Add(other ref.Val) ref.Val
- func (i Uint) Compare(other ref.Val) ref.Val
- func (i Uint) ConvertToNative(typeDesc reflect.Type) (any, error)
- func (i Uint) ConvertToType(typeVal ref.Type) ref.Val
- func (i Uint) Divide(other ref.Val) ref.Val
- func (i Uint) Equal(other ref.Val) ref.Val
- func (i Uint) IsZeroValue() bool
- func (i Uint) Modulo(other ref.Val) ref.Val
- func (i Uint) Multiply(other ref.Val) ref.Val
- func (i Uint) Subtract(subtrahend ref.Val) ref.Val
- func (i Uint) Type() ref.Type
- func (i Uint) Value() any
- type Unknown
- func (u *Unknown) Contains(other *Unknown) bool
- func (u *Unknown) ConvertToNative(typeDesc reflect.Type) (any, error)
- func (u *Unknown) ConvertToType(typeVal ref.Type) ref.Val
- func (u *Unknown) Equal(other ref.Val) ref.Val
- func (u *Unknown) GetAttributeTrails(id int64) ([]*AttributeTrail, bool)
- func (u *Unknown) IDs() []int64
- func (u *Unknown) String() string
- func (u *Unknown) Type() ref.Type
- func (u *Unknown) Value() any
Constants¶
const (False =Bool(false)True =Bool(true))
Boolean constants
const (// IntZero is the zero-value for IntIntZero =Int(0)IntOne =Int(1)IntNegOne =Int(-1))
Int constants used for comparison results.
Variables¶
var (// OptionalType indicates the runtime type of an optional value.OptionalType =NewOpaqueType("optional_type")// OptionalNone is a sentinel value which is used to indicate an empty optional value.OptionalNone = &Optional{})
var (// AnyType represents the google.protobuf.Any type.AnyType = &Type{kind:AnyKind,runtimeTypeName: "google.protobuf.Any",traitMask:traits.FieldTesterType |traits.IndexerType,}// BoolType represents the bool type.BoolType = &Type{kind:BoolKind,runtimeTypeName: "bool",traitMask:traits.ComparerType |traits.NegatorType,}// BytesType represents the bytes type.BytesType = &Type{kind:BytesKind,runtimeTypeName: "bytes",traitMask:traits.AdderType |traits.ComparerType |traits.SizerType,}// DoubleType represents the double type.DoubleType = &Type{kind:DoubleKind,runtimeTypeName: "double",traitMask:traits.AdderType |traits.ComparerType |traits.DividerType |traits.MultiplierType |traits.NegatorType |traits.SubtractorType,}// DurationType represents the CEL duration type.DurationType = &Type{kind:DurationKind,runtimeTypeName: "google.protobuf.Duration",traitMask:traits.AdderType |traits.ComparerType |traits.NegatorType |traits.ReceiverType |traits.SubtractorType,}// DynType represents a dynamic CEL type whose type will be determined at runtime from context.DynType = &Type{kind:DynKind,runtimeTypeName: "dyn",}// ErrorType represents a CEL error value.ErrorType = &Type{kind:ErrorKind,runtimeTypeName: "error",}// IntType represents the int type.IntType = &Type{kind:IntKind,runtimeTypeName: "int",traitMask:traits.AdderType |traits.ComparerType |traits.DividerType |traits.ModderType |traits.MultiplierType |traits.NegatorType |traits.SubtractorType,}// ListType represents the runtime list type.ListType =NewListType(DynType)// MapType represents the runtime map type.MapType =NewMapType(DynType,DynType)// NullType represents the type of a null value.NullType = &Type{kind:NullTypeKind,runtimeTypeName: "null_type",}// StringType represents the string type.StringType = &Type{kind:StringKind,runtimeTypeName: "string",traitMask:traits.AdderType |traits.ComparerType |traits.MatcherType |traits.ReceiverType |traits.SizerType,}// TimestampType represents the time type.TimestampType = &Type{kind:TimestampKind,runtimeTypeName: "google.protobuf.Timestamp",traitMask:traits.AdderType |traits.ComparerType |traits.ReceiverType |traits.SubtractorType,}// TypeType represents a CEL typeTypeType = &Type{kind:TypeKind,runtimeTypeName: "type",}// UintType represents a uint type.UintType = &Type{kind:UintKind,runtimeTypeName: "uint",traitMask:traits.AdderType |traits.ComparerType |traits.DividerType |traits.ModderType |traits.MultiplierType |traits.SubtractorType,}// UnknownType represents an unknown value type.UnknownType = &Type{kind:UnknownKind,runtimeTypeName: "unknown",})
var (// DefaultTypeAdapter adapts canonical CEL types from their equivalent Go values.DefaultTypeAdapter = &defaultTypeAdapter{})var (// ErrType singleton.ErrType =NewOpaqueType("error"))
var (// IteratorType singleton.IteratorType =NewObjectType("iterator",traits.IteratorType))
var (// NullValue singleton.NullValue =Null(structpb.NullValue_NULL_VALUE))
var (// ProtoCELPrimitives provides a map from the protoreflect Kind to the equivalent CEL type.ProtoCELPrimitives = map[protoreflect.Kind]*Type{protoreflect.BoolKind:BoolType,protoreflect.BytesKind:BytesType,protoreflect.DoubleKind:DoubleType,protoreflect.FloatKind:DoubleType,protoreflect.Int32Kind:IntType,protoreflect.Int64Kind:IntType,protoreflect.Sint32Kind:IntType,protoreflect.Sint64Kind:IntType,protoreflect.Uint32Kind:UintType,protoreflect.Uint64Kind:UintType,protoreflect.Fixed32Kind:UintType,protoreflect.Fixed64Kind:UintType,protoreflect.Sfixed32Kind:IntType,protoreflect.Sfixed64Kind:IntType,protoreflect.StringKind:StringType,})
Functions¶
funcDurationGetHours¶added inv0.17.0
DurationGetHours returns the duration in hours.
funcDurationGetMilliseconds¶added inv0.17.0
DurationGetMilliseconds returns duration in milliseconds.
funcDurationGetMinutes¶added inv0.17.0
DurationGetMinutes returns duration in minutes.
funcDurationGetSeconds¶added inv0.17.0
DurationGetSeconds returns duration in seconds.
funcFormat¶added inv0.25.0
Format formats the value as a string. The result is only intended for human consumption and ignores errors.Do not depend on the output being stable. It may change at any time.
funcIndexOrError¶added inv0.13.0
IndexOrError converts an input index value into either a lossless integer index or an error.
funcInsertMapKeyValue¶added inv0.22.0
InsertMapKeyValue inserts a key, value pair into the target map if the target map does notalready contain the given key.
If the map is mutable, it is modified in-place per the MutableMapper contract.If the map is not mutable, a copy containing the new key, value pair is made.
funcIsError¶
IsError returns whether the input element ref.Type or ref.Val is equal tothe ErrType singleton.
funcIsPrimitiveType¶added inv0.3.0
IsPrimitiveType returns whether the input element ref.Val is a primitive type.Note, primitive types do not include well-known types such as Duration and Timestamp.
funcIsUnknownOrError¶
IsUnknownOrError returns whether the input element ref.Val is an ErrType or UnknownType.
funcLabelErrNode¶added inv0.19.0
LabelErrNode returns val unaltered it is not an Err or if the error has a non-zeroAST node ID already present. Otherwise the id is added to the error forrecovery with the Err.NodeID method.
funcMaybeNoSuchOverloadErr¶added inv0.4.0
MaybeNoSuchOverloadErr returns the error or unknown if the input ref.Val is one of these types,else a new no such overload error.
funcNewDynamicList¶
NewDynamicList returns a traits.Lister with heterogenous elements.value should be an array of "native" types, i.e. any type thatNativeToValue() can convert to a ref.Val.
funcNewDynamicMap¶
NewDynamicMap returns a traits.Mapper value with dynamic key, value pairs.
funcNewErr¶
NewErr creates a new Err described by the format string and args.TODO: Audit the use of this function and standardize the error messages and codes.
funcNewErrFromString¶added inv0.23.0
NewErrFromString creates a new Err with the provided message.TODO: Audit the use of this function and standardize the error messages and codes.
funcNewErrWithNodeID¶added inv0.19.0
NewErrWithNodeID creates a new Err described by the format string and args.TODO: Audit the use of this function and standardize the error messages and codes.
funcNewJSONList¶
NewJSONList returns a traits.Lister based on structpb.ListValue instance.
funcNewJSONStruct¶
NewJSONStruct creates a traits.Mapper implementation backed by a JSON struct that has beenencoded in protocol buffer form.
The `adapter` argument provides type adaptation capabilities from proto to CEL.
funcNewMutableList¶added inv0.10.0
func NewMutableList(adapterAdapter)traits.MutableLister
NewMutableList creates a new mutable list whose internal state can be modified.
funcNewMutableMap¶added inv0.22.0
NewMutableMap constructs a mutable map from an adapter and a set of map values.
funcNewObject¶
func NewObject(adapterAdapter,typeDesc *pb.TypeDescription,typeValueref.Val,valueproto.Message)ref.Val
NewObject returns an object based on a proto.Message value which handlesconversion between protobuf type values and expression type values.Objects support indexing and iteration.
Note: the type value is pulled from the list of registered types within thetype provider. If the proto type is not registered within the type provider,then this will result in an error within the type adapter / provider.
funcNewProtoList¶added inv0.7.0
func NewProtoList(adapterAdapter, listprotoreflect.List)traits.Lister
NewProtoList returns a traits.Lister based on a pb.List instance.
funcNewProtoMap¶added inv0.7.0
NewProtoMap returns a specialized traits.Mapper for handling protobuf map values.
funcNewRefValList¶added inv0.7.0
NewRefValList returns a traits.Lister with ref.Val elements.
This type specialization is used with list literals within CEL expressions.
funcNewRefValMap¶added inv0.7.0
NewRefValMap returns a specialized traits.Mapper with CEL valued keys and values.
funcNewStringInterfaceMap¶added inv0.7.0
NewStringInterfaceMap returns a specialized traits.Mapper with string keys and interface values.
funcNewStringList¶
NewStringList returns a traits.Lister containing only strings.
funcNewStringStringMap¶
NewStringStringMap returns a specialized traits.Mapper with string keys and values.
funcNoSuchOverloadErr¶added inv0.4.0
NoSuchOverloadErr returns a new types.Err instance with a no such overload message.
funcStringContains¶added inv0.17.0
StringContains returns whether the string contains a substring.
funcStringEndsWith¶added inv0.17.0
StringEndsWith returns whether the target string contains the input suffix.
funcStringStartsWith¶added inv0.17.0
StringStartsWith returns whether the target string contains the input prefix.
funcToFoldableList¶added inv0.22.0
ToFoldableList will create a Foldable version of a list suitable for key-value pair iteration.
For values which are already Foldable, this call is a no-op. For all other values, the fold isdriven via the Size() and Get() calls which means that the folding will function, but take aperformance hit.
funcToFoldableMap¶added inv0.22.0
ToFoldableMap will create a Foldable version of a map suitable for key-value pair iteration.
For values which are already Foldable, this call is a no-op. For all other values, the foldis driven via the Iterator HasNext() and Next() calls as well as the map's Get() methodwhich means that the folding will function, but take a performance hit.
funcTypeToExprType¶added inv0.17.0
TypeToExprType converts a CEL-native type representation to a protobuf CEL Type representation.
funcTypeToProto¶added inv0.23.0
TypeToProto converts from a CEL-native type representation to canonical CEL celpb.Type protobuf type.
funcUnsupportedRefValConversionErr¶added inv0.7.0
UnsupportedRefValConversionErr returns a types.NewErr instance with a no such conversionmessage that indicates that the native value could not be converted to a CEL ref.Val.
Types¶
typeAdapter¶added inv0.17.0
type Adapter =ref.TypeAdapter
Adapter converts native Go values of varying type and complexity to equivalent CEL values.
typeAttributeQualifier¶added inv0.17.0
AttributeQualifier constrains the possible types which may be used to qualify an attribute.
typeAttributeTrail¶added inv0.17.0
type AttributeTrail struct {// contains filtered or unexported fields}AttributeTrail specifies a variable with an optional qualifier path. An attribute value is expected tocorrespond to an AbsoluteAttribute, meaning a field selection which starts with a top-level variable.
The qualifer path elements adhere to the AttributeQualifier type constraint.
funcNewAttributeTrail¶added inv0.17.0
func NewAttributeTrail(variablestring) *AttributeTrail
NewAttributeTrail creates a new simple attribute from a variable name.
funcQualifyAttribute¶added inv0.17.0
func QualifyAttribute[TAttributeQualifier](attr *AttributeTrail, qualifier T) *AttributeTrail
QualifyAttribute qualifies an attribute using a valid AttributeQualifier type.
func (*AttributeTrail)Equal¶added inv0.17.0
func (a *AttributeTrail) Equal(other *AttributeTrail)bool
Equal returns whether two attribute values have the same variable name and qualifier paths.
func (*AttributeTrail)QualifierPath¶added inv0.17.0
func (a *AttributeTrail) QualifierPath() []any
QualifierPath returns the optional set of qualifying fields or indices applied to the variable.
func (*AttributeTrail)String¶added inv0.17.0
func (a *AttributeTrail) String()string
String returns the string representation of the Attribute.
func (*AttributeTrail)Variable¶added inv0.17.0
func (a *AttributeTrail) Variable()string
Variable returns the variable name associated with the attribute.
typeBool¶
type Boolbool
Bool type that implements ref.Val and supports comparison and negation.
func (Bool)ConvertToNative¶
ConvertToNative implements the ref.Val interface method.
func (Bool)ConvertToType¶
ConvertToType implements the ref.Val interface method.
func (Bool)IsZeroValue¶added inv0.13.0
IsZeroValue returns true if the boolean value is false.
typeBytes¶
type Bytes []byte
Bytes type that implements ref.Val and supports add, compare, and sizeoperations.
func (Bytes)ConvertToNative¶
ConvertToNative implements the ref.Val interface method.
func (Bytes)ConvertToType¶
ConvertToType implements the ref.Val interface method.
func (Bytes)IsZeroValue¶added inv0.13.0
IsZeroValue returns true if the byte array is empty.
typeDouble¶
type Doublefloat64
Double type that implements ref.Val, comparison, and mathematicaloperations.
func (Double)ConvertToNative¶
ConvertToNative implements ref.Val.ConvertToNative.
func (Double)ConvertToType¶
ConvertToType implements ref.Val.ConvertToType.
func (Double)IsZeroValue¶added inv0.13.0
IsZeroValue returns true if double value is 0.0
typeDuration¶
Duration type that implements ref.Val and supports add, compare, negate,and subtract operators. This type is also a receiver which means it canparticipate in dispatch to receiver functions.
func (Duration)ConvertToNative¶
ConvertToNative implements ref.Val.ConvertToNative.
func (Duration)ConvertToType¶
ConvertToType implements ref.Val.ConvertToType.
func (Duration)IsZeroValue¶added inv0.13.0
IsZeroValue returns true if the duration value is zero
typeErr¶
type Err struct {// contains filtered or unexported fields}Err type which extends the built-in go error and implements ref.Val.
func (*Err)ConvertToNative¶
ConvertToNative implements ref.Val.ConvertToNative.
func (*Err)ConvertToType¶
ConvertToType implements ref.Val.ConvertToType.
typeError¶added inv0.14.0
Error interface which allows types types.Err values to be treated as error values.
typeFieldType¶added inv0.17.0
type FieldType struct {// Type of the field as a CEL native type value.Type *Type// IsSet indicates whether the field is set on an input object.IsSetref.FieldTester// GetFrom retrieves the field value on the input object, if set.GetFromref.FieldGetter}FieldType represents a field's type value and whether that field supports presence detection.
typeInt¶
type Intint64
Int type that implements ref.Val as well as comparison and math operators.
func (Int)ConvertToNative¶
ConvertToNative implements ref.Val.ConvertToNative.
func (Int)ConvertToType¶
ConvertToType implements ref.Val.ConvertToType.
func (Int)IsZeroValue¶added inv0.13.0
IsZeroValue returns true if integer is equal to 0
typeKind¶added inv0.17.0
type Kinduint
Kind indicates a CEL type's kind which is used to differentiate quickly between simpleand complex types.
const (// UnspecifiedKind is returned when the type is nil or its kind is not specified.UnspecifiedKindKind =iota// DynKind represents a dynamic type. This kind only exists at type-check time.DynKind// AnyKind represents a google.protobuf.Any type. This kind only exists at type-check time.// Prefer DynKind to AnyKind as AnyKind has a specific meaning which is based on protobuf// well-known types.AnyKind// BoolKind represents a boolean type.BoolKind// BytesKind represents a bytes type.BytesKind// DoubleKind represents a double type.DoubleKind// DurationKind represents a CEL duration type.DurationKind// ErrorKind represents a CEL error type.ErrorKind// IntKind represents an integer type.IntKind// ListKind represents a list type.ListKind// MapKind represents a map type.MapKind// NullTypeKind represents a null type.NullTypeKind// OpaqueKind represents an abstract type which has no accessible fields.OpaqueKind// StringKind represents a string type.StringKind// StructKind represents a structured object with typed fields.StructKind// TimestampKind represents a a CEL time type.TimestampKind// TypeKind represents the CEL type.TypeKind// TypeParamKind represents a parameterized type whose type name will be resolved at type-check time, if possible.TypeParamKind// UintKind represents a uint type.UintKind// UnknownKind represents an unknown value type.UnknownKind)
typeNull¶
Null type implementation.
func (Null)ConvertToNative¶
ConvertToNative implements ref.Val.ConvertToNative.
func (Null)ConvertToType¶
ConvertToType implements ref.Val.ConvertToType.
func (Null)IsZeroValue¶added inv0.13.0
IsZeroValue returns true as null always represents an absent value.
typeOptional¶added inv0.13.0
type Optional struct {// contains filtered or unexported fields}Optional value which points to a value if non-empty.
funcOptionalOf¶added inv0.13.0
OptionalOf returns an optional value which wraps a concrete CEL value.
func (*Optional)ConvertToNative¶added inv0.13.0
ConvertToNative implements the ref.Val interface method.
func (*Optional)ConvertToType¶added inv0.13.0
ConvertToType implements the ref.Val interface method.
func (*Optional)Equal¶added inv0.13.0
Equal determines whether the values contained by two optional values are equal.
func (*Optional)GetValue¶added inv0.13.0
GetValue returns the wrapped value contained in the optional.
typeProvider¶added inv0.17.0
type Provider interface {// EnumValue returns the numeric value of the given enum value name.EnumValue(enumNamestring)ref.Val// FindIdent takes a qualified identifier name and returns a ref.Val if one exists.FindIdent(identNamestring) (ref.Val,bool)// FindStructType returns the Type give a qualified type name.//// For historical reasons, only struct types are expected to be returned through this// method, and the type values are expected to be wrapped in a TypeType instance using// TypeTypeWithParam(<structType>).//// Returns false if not found.FindStructType(structTypestring) (*Type,bool)// FindStructFieldNames returns thet field names associated with the type, if the type// is found.FindStructFieldNames(structTypestring) ([]string,bool)// FieldStructFieldType returns the field type for a checked type value. Returns// false if the field could not be found.FindStructFieldType(structType, fieldNamestring) (*FieldType,bool)// NewValue creates a new type value from a qualified name and map of field// name to value.//// Note, for each value, the Val.ConvertToNative function will be invoked// to convert the Val to the field's native type. If an error occurs during// conversion, the NewValue will be a types.Err.NewValue(structTypestring, fields map[string]ref.Val)ref.Val}Provider specifies functions for creating new object instances and for resolvingenum values by name.
typeRegistry¶added inv0.17.0
type Registry struct {// contains filtered or unexported fields}Registry provides type information for a set of registered types.
funcNewEmptyRegistry¶added inv0.4.0
func NewEmptyRegistry() *Registry
NewEmptyRegistry returns a registry which is completely unconfigured.
funcNewRegistry¶added inv0.2.0
NewRegistry accepts a list of proto message instances and returns a typeprovider which can create new instances of the provided message or anymessage that proto depends upon in its FileDescriptor.
func (*Registry)Copy¶added inv0.17.0
Copy copies the current state of the registry into its own memory space.
func (*Registry)EnumValue¶added inv0.17.0
EnumValue returns the numeric value of the given enum value name.
func (*Registry)FindIdent¶added inv0.17.0
FindIdent takes a qualified identifier name and returns a ref.Val if one exists.
func (*Registry)FindStructFieldNames¶added inv0.17.2
FindStructFieldNames returns the set of field names for the given struct type,if the type exists in the registry.
func (*Registry)FindStructFieldType¶added inv0.17.0
FindStructFieldType returns the field type for a checked type value. Returnsfalse if the field could not be found.
func (*Registry)FindStructType¶added inv0.17.0
FindStructType returns the Type give a qualified type name.
For historical reasons, only struct types are expected to be returned through thismethod, and the type values are expected to be wrapped in a TypeType instance usingTypeTypeWithParam(<structType>).
Returns false if not found.
func (*Registry)NativeToValue¶added inv0.17.0
NativeToValue converts various "native" types to ref.Val with this specific implementationproviding support for custom proto-based types.
This method should be the inverse of ref.Val.ConvertToNative.
func (*Registry)NewValue¶added inv0.17.0
NewValue creates a new type value from a qualified name and map of fieldname to value.
Note, for each value, the Val.ConvertToNative function will be invokedto convert the Val to the field's native type. If an error occurs duringconversion, the NewValue will be a types.Err.
func (*Registry)RegisterDescriptor¶added inv0.17.0
func (p *Registry) RegisterDescriptor(fileDescprotoreflect.FileDescriptor)error
RegisterDescriptor registers the contents of a protocol buffer `FileDescriptor`.
func (*Registry)RegisterMessage¶added inv0.17.0
RegisterMessage registers a protocol buffer message and its dependencies.
func (*Registry)RegisterType¶added inv0.17.0
RegisterType registers a type value with the provider which ensures the provider is aware of how tomap the type to an identifier.
If the `ref.Type` value is a `*types.Type` it will be registered directly by its runtime type name.If the `ref.Type` value is not a `*types.Type` instance, a `*types.Type` instance which reflects thetraits present on the input and the runtime type name. By default this foreign type will be treatedas a types.StructKind. To avoid potential issues where the `ref.Type` values does not match thegenerated `*types.Type` instance, consider always using the `*types.Type` to represent type extensionsto CEL, even when they're not based on protobuf types.
typeString¶
type Stringstring
String type implementation which supports addition, comparison, matching,and size functions.
func (String)ConvertToNative¶
ConvertToNative implements ref.Val.ConvertToNative.
func (String)ConvertToType¶
ConvertToType implements ref.Val.ConvertToType.
func (String)IsZeroValue¶added inv0.13.0
IsZeroValue returns true if the string is empty.
typeTimestamp¶
Timestamp type implementation which supports add, compare, and subtractoperations. Timestamps are also capable of participating in dynamicfunction dispatch to instance methods.
func (Timestamp)ConvertToNative¶
ConvertToNative implements ref.Val.ConvertToNative.
func (Timestamp)ConvertToType¶
ConvertToType implements ref.Val.ConvertToType.
func (Timestamp)IsZeroValue¶added inv0.13.0
IsZeroValue returns true if the timestamp is epoch 0.
typeType¶added inv0.17.0
type Type struct {// contains filtered or unexported fields}Type holds a reference to a runtime type with an optional type-checked set of type parameters.
funcAlphaProtoAsType¶added inv0.22.0
AlphaProtoAsType converts a CEL v1alpha1.Type protobuf type to a CEL-native type representation.
funcExprTypeToType¶added inv0.17.0
ExprTypeToType converts a protobuf CEL type representation to a CEL-native type representation.
funcNewListType¶added inv0.17.0
NewListType creates an instances of a list type value with the provided element type.
funcNewMapType¶added inv0.17.0
NewMapType creates an instance of a map type value with the provided key and value types.
funcNewNullableType¶added inv0.17.0
NewNullableType creates an instance of a nullable type with the provided wrapped type.
Note: only primitive types are supported as wrapped types.
funcNewObjectType¶added inv0.17.0
NewObjectType creates a type reference to an externally defined type, e.g. a protobuf message type.
An object type is assumed to support field presence testing and field indexing. Additionally, thetype may also indicate additional traits through the use of the optional traits vararg argument.
funcNewObjectTypeValuedeprecated
funcNewOpaqueType¶added inv0.17.0
NewOpaqueType creates an abstract parameterized type with a given name.
funcNewOptionalType¶added inv0.17.0
NewOptionalType creates an abstract parameterized type instance corresponding to CEL's notion of optional.
funcNewTypeParamType¶added inv0.17.0
NewTypeParamType creates a parameterized type instance.
funcNewTypeTypeWithParam¶added inv0.17.0
NewTypeTypeWithParam creates a type with a type parameter.Used for type-checking purposes, but equivalent to TypeType otherwise.
funcNewTypeValuedeprecated
funcProtoAsType¶added inv0.22.0
ProtoAsType converts a canonical CEL celpb.Type protobuf type to a CEL-native type representation.
func (*Type)ConvertToNative¶added inv0.17.0
ConvertToNative implements ref.Val.ConvertToNative.
func (*Type)ConvertToType¶added inv0.17.0
ConvertToType implements ref.Val.ConvertToType.
func (*Type)DeclaredTypeName¶added inv0.17.0
DeclaredTypeName indicates the fully qualified and parameterized type-check type name.
func (*Type)Equal¶added inv0.17.0
Equal indicates whether two types have the same runtime type name.
The name Equal is a bit of a misnomer, but for historical reasons, this is theruntime behavior. For a more accurate definition see IsType().
func (*Type)IsAssignableRuntimeType¶added inv0.17.0
IsAssignableRuntimeType determines whether the current type is runtime assignable from the input runtimeType.
At runtime, parameterized types are erased and so a function which type-checks to support a map(string, string)will have a runtime assignable type of a map.
func (*Type)IsAssignableType¶added inv0.17.0
IsAssignableType determines whether the current type is type-check assignable from the input fromType.
func (*Type)IsEquivalentType¶added inv0.17.0
IsEquivalentType indicates whether two types are equivalent. This check ignores type parameter type names.
func (*Type)IsExactType¶added inv0.17.0
IsExactType indicates whether the two types are exactly the same. This check also verifies type parameter type names.
func (*Type)Parameters¶added inv0.17.0
Parameters returns the list of type parameters if set.
For ListKind, Parameters()[0] represents the list element typeFor MapKind, Parameters()[0] represents the map key type, and Parameters()[1] represents the mapvalue type.
func (*Type)TypeName¶added inv0.17.0
TypeName returns the type-erased fully qualified runtime type name.
TypeName implements the ref.Type interface method.
func (*Type)WithTraits¶added inv0.19.0
WithTraits creates a copy of the current Type and sets the trait mask to the traits parameter.
This method should be used with Opaque types where the type acts like a container, e.g. vector.
typeUint¶
type Uintuint64
Uint type implementation which supports comparison and math operators.
func (Uint)ConvertToNative¶
ConvertToNative implements ref.Val.ConvertToNative.
func (Uint)ConvertToType¶
ConvertToType implements ref.Val.ConvertToType.
func (Uint)IsZeroValue¶added inv0.13.0
IsZeroValue returns true if the uint is zero.
typeUnknown¶
type Unknown struct {// contains filtered or unexported fields}Unknown type which collects expression ids which caused the current value to become unknown.
funcMaybeMergeUnknowns¶added inv0.17.0
MaybeMergeUnknowns determines whether an input value and another, possibly nil, unknown will producean unknown result.
If the input `val` is another Unknown, then the result will be the merge of the `val` and the input`unk`. If the `val` is not unknown, then the result will depend on whether the input `unk` is nil.If both values are non-nil and unknown, then the return value will be a merge of both unknowns.
funcMergeUnknowns¶added inv0.17.0
MergeUnknowns combines two unknown values into a new unknown value.
funcNewUnknown¶added inv0.17.0
func NewUnknown(idint64, attr *AttributeTrail) *Unknown
NewUnknown creates a new unknown at a given expression id for an attribute.
If the attribute is nil, the attribute value will be the `unspecifiedAttribute`.
func (*Unknown)Contains¶added inv0.17.0
Contains returns true if the input unknown is a subset of the current unknown.
func (*Unknown)ConvertToNative¶
ConvertToNative implements ref.Val.ConvertToNative.
func (*Unknown)ConvertToType¶
ConvertToType is an identity function since unknown values cannot be modified.
func (*Unknown)GetAttributeTrails¶added inv0.17.1
func (u *Unknown) GetAttributeTrails(idint64) ([]*AttributeTrail,bool)
GetAttributeTrails returns the attribute trails, if present, missing for a given expression id.
func (*Unknown)IDs¶added inv0.17.1
IDs returns the set of unknown expression ids contained by this value.
Numeric identifiers are guaranteed to be in sorted order.
Source Files¶
Directories¶
| Path | Synopsis |
|---|---|
Package pb reflects over protocol buffer descriptors to generate objects that simplify type, enum, and field lookup. | Package pb reflects over protocol buffer descriptors to generate objects that simplify type, enum, and field lookup. |
Package ref contains the reference interfaces used throughout the types components. | Package ref contains the reference interfaces used throughout the types components. |
Package traits defines interfaces that a type may implement to participate in operator overloads and function dispatch. | Package traits defines interfaces that a type may implement to participate in operator overloads and function dispatch. |