dynamic

package
v0.32.0-rc.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ObjectType

type ObjectType struct {
	// contains filtered or unexported fields
}

ObjectType is the implementation of the Object type for use when compiling CEL expressions without schema information about the object. This is to provide CEL expressions with access to Object{} types constructors.

func NewObjectType

func NewObjectType(name string) *ObjectType

NewObjectType creates a ObjectType by the given field name.

func (*ObjectType) Field

func (o *ObjectType) Field(name string) (*types.FieldType, bool)

Field looks up the field by name. This is the unstructured version that allows any name as the field name. The returned field is of DynType type.

func (*ObjectType) FieldNames

func (o *ObjectType) FieldNames() ([]string, bool)

func (*ObjectType) HasTrait

func (o *ObjectType) HasTrait(trait int) bool

func (*ObjectType) Type

func (o *ObjectType) Type() *types.Type

func (*ObjectType) TypeName

func (o *ObjectType) TypeName() string

TypeName returns the name of this ObjectType.

func (*ObjectType) Val

func (o *ObjectType) Val(fields map[string]ref.Val) ref.Val

Val returns an instance given the fields.

type ObjectVal

type ObjectVal struct {
	// contains filtered or unexported fields
}

ObjectVal is the CEL Val for an object that is constructed via the Object{} in CEL expressions without schema information about the object.

func NewObjectVal

func NewObjectVal(objectType *types.Type, fields map[string]ref.Val) *ObjectVal

NewObjectVal creates an ObjectVal by its ResolvedType and its fields.

func (*ObjectVal) CheckTypeNamesMatchFieldPathNames

func (v *ObjectVal) CheckTypeNamesMatchFieldPathNames() error

CheckTypeNamesMatchFieldPathNames transitively checks the CEL object type names of this ObjectVal. Returns all found type name mismatch errors. Children ObjectVal types under <field> or this ObjectVal must have type names of the form "<ObjectVal.TypeName>.<field>", children of that type must have type names of the form "<ObjectVal.TypeName>.<field>.<field>" and so on. Intermediate maps and lists are unnamed and ignored.

func (*ObjectVal) ConvertToNative

func (v *ObjectVal) ConvertToNative(typeDesc reflect.Type) (any, error)

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

func (v *ObjectVal) ConvertToType(typeValue ref.Type) ref.Val

ConvertToType supports type conversions between CEL value types supported by the expression language.

func (*ObjectVal) Equal

func (v *ObjectVal) Equal(other ref.Val) ref.Val

Equal returns true if the `other` value has the same type and content as the implementing struct.

func (*ObjectVal) IsZeroValue

func (v *ObjectVal) IsZeroValue() bool

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

func (v *ObjectVal) Type() ref.Type

Type returns the TypeValue of the value.

func (*ObjectVal) Value

func (v *ObjectVal) Value() any

Value returns its value as a map[string]any.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL