Documentation
¶
Index ¶
- func DecodeParameterTypes(ts *TypeSet, parameters map[string]*core.CaveatTypeReference) (map[string]VariableType, error)
- func EncodeParameterType(varType VariableType) *core.CaveatTypeReference
- func EncodeParameterTypes(parametersAndTypes map[string]VariableType) map[string]*core.CaveatTypeReference
- func RegisterBasicTypes(sts *StandardTypeSet) error
- func RegisterCustomCELOptions(ts *TypeSet, opts ...cel.EnvOption) error
- func RegisterMethodOnDefinedType(ts *TypeSet, baseType *cel.Type, name string, args []*cel.Type, ...) error
- type CustomType
- type GenericTypeBuilder
- type IPAddress
- func (ipa IPAddress) ConvertToNative(typeDesc reflect.Type) (interface{}, error)
- func (ipa IPAddress) ConvertToType(typeVal ref.Type) ref.Val
- func (ipa IPAddress) Equal(other ref.Val) ref.Val
- func (ipa IPAddress) SerializedString() string
- func (ipa IPAddress) Type() ref.Type
- func (ipa IPAddress) Value() interface{}
- type StandardTypeSet
- func (sts *StandardTypeSet) ListType(childTypes ...VariableType) (VariableType, error)
- func (sts *StandardTypeSet) MapType(childTypes ...VariableType) (VariableType, error)
- func (sts *StandardTypeSet) MustListType(childTypes ...VariableType) VariableType
- func (sts *StandardTypeSet) MustMapType(childTypes ...VariableType) VariableType
- type TypeSet
- type VariableType
- func DecodeParameterType(ts *TypeSet, parameterType *core.CaveatTypeReference) (*VariableType, error)
- func MustRegisterBasicType(ts *TypeSet, keyword string, celType *cel.Type, converter typedValueConverter) VariableType
- func RegisterBasicType(ts *TypeSet, keyword string, celType *cel.Type, converter typedValueConverter) (VariableType, error)
- func RegisterCustomType[T CustomType](ts *TypeSet, keyword string, baseCelType *cel.Type, ...) (VariableType, error)
- func RegisterIPAddressType(ts *TypeSet) (VariableType, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeParameterTypes ¶ added in v1.24.0
func DecodeParameterTypes(ts *TypeSet, parameters map[string]*core.CaveatTypeReference) (map[string]VariableType, error)
DecodeParameterTypes decodes the core caveat parameter types into internal caveat types.
func EncodeParameterType ¶
func EncodeParameterType(varType VariableType) *core.CaveatTypeReference
EncodeParameterType converts an internal caveat type into a storable core type.
func EncodeParameterTypes ¶
func EncodeParameterTypes(parametersAndTypes map[string]VariableType) map[string]*core.CaveatTypeReference
EncodeParameterTypes converts the map of internal caveat types into a map of types for storing the caveat in the core.
func RegisterBasicTypes ¶ added in v1.43.0
func RegisterBasicTypes(sts *StandardTypeSet) error
RegisterBasicTypes registers the basic types with the given keyword, CEL type, and converter.
func RegisterCustomCELOptions ¶ added in v1.43.0
RegisterCustomOptions registers custom CEL environment options for the TypeSet.
Types ¶
type CustomType ¶ added in v1.21.0
type CustomType interface { // SerializedString returns the serialized string form of the data within // this instance of the type. SerializedString() string }
CustomType is the interface for custom-defined types.
type GenericTypeBuilder ¶ added in v1.43.0
type GenericTypeBuilder func(childTypes ...VariableType) (VariableType, error)
func MustRegisterGenericType ¶ added in v1.43.0
func MustRegisterGenericType( ts *TypeSet, keyword string, childTypeCount uint8, asVariableType func(childTypes []VariableType) VariableType, ) GenericTypeBuilder
func RegisterGenericType ¶ added in v1.43.0
func RegisterGenericType( ts *TypeSet, keyword string, childTypeCount uint8, asVariableType func(childTypes []VariableType) VariableType, ) (GenericTypeBuilder, error)
RegisterGenericType registers a type with at least one generic.
type IPAddress ¶
type IPAddress struct {
// contains filtered or unexported fields
}
IPAddress defines a custom type for representing an IP Address in caveats.
func MustParseIPAddress ¶
MustParseIPAddress parses the string form of an IP Address into an IPAddress object type.
func ParseIPAddress ¶
ParseIPAddress parses the string form of an IP Address into an IPAddress object type.
func (IPAddress) ConvertToNative ¶
func (IPAddress) SerializedString ¶ added in v1.21.0
type StandardTypeSet ¶ added in v1.43.0
type StandardTypeSet struct { *TypeSet AnyType VariableType BooleanType VariableType StringType VariableType IntType VariableType UIntType VariableType DoubleType VariableType BytesType VariableType DurationType VariableType TimestampType VariableType IPAddressType VariableType // contains filtered or unexported fields }
StandardTypeSet is a TypeSet that contains all the standard types and provides nice accessors for each.
var Default *StandardTypeSet
Default is the default set of types to be used in caveats, coming with all the standard types pre-registered. This set is frozen and cannot be modified.
func MustNewStandardTypeSet ¶ added in v1.43.0
func MustNewStandardTypeSet() *StandardTypeSet
func NewStandardTypeSet ¶ added in v1.43.0
func NewStandardTypeSet() (*StandardTypeSet, error)
NewStandardTypeSet creates a new TypeSet with all the standard types pre-registered.
func (*StandardTypeSet) ListType ¶ added in v1.43.0
func (sts *StandardTypeSet) ListType(childTypes ...VariableType) (VariableType, error)
func (*StandardTypeSet) MapType ¶ added in v1.43.0
func (sts *StandardTypeSet) MapType(childTypes ...VariableType) (VariableType, error)
func (*StandardTypeSet) MustListType ¶ added in v1.43.0
func (sts *StandardTypeSet) MustListType(childTypes ...VariableType) VariableType
func (*StandardTypeSet) MustMapType ¶ added in v1.43.0
func (sts *StandardTypeSet) MustMapType(childTypes ...VariableType) VariableType
type TypeSet ¶ added in v1.43.0
type TypeSet struct {
// contains filtered or unexported fields
}
TypeSet defines a set of types that can be used in caveats. It is used to register custom types and methods that can be used in caveats. The types are registered by calling the RegisterType function. The types are then used to build the CEL environment for the caveat.
func NewTypeSet ¶ added in v1.43.0
func NewTypeSet() *TypeSet
NewTypeSet creates a new TypeSet. The TypeSet is not frozen and can be modified.
func TypeSetOrDefault ¶ added in v1.43.0
TypeSetOrDefault returns the provided TypeSet if it is not nil, otherwise it returns the default TypeSet. This is useful for functions that accept a TypeSet parameter but want to use the default if none is provided.
func (*TypeSet) BuildType ¶ added in v1.43.0
func (ts *TypeSet) BuildType(name string, childTypes []VariableType) (*VariableType, error)
BuildType builds a variable type from its name and child types.
func (*TypeSet) EnvOptions ¶ added in v1.43.0
EnvOptions returns the set of environment options that can be used to create a CEL environment for the caveat. This includes the custom types and methods defined in the TypeSet.
type VariableType ¶
type VariableType struct {
// contains filtered or unexported fields
}
VariableType defines the supported types of variables in caveats.
func DecodeParameterType ¶
func DecodeParameterType(ts *TypeSet, parameterType *core.CaveatTypeReference) (*VariableType, error)
DecodeParameterType decodes the core caveat parameter type into an internal caveat type.
func MustRegisterBasicType ¶ added in v1.43.0
func MustRegisterBasicType(ts *TypeSet, keyword string, celType *cel.Type, converter typedValueConverter) VariableType
func RegisterBasicType ¶ added in v1.43.0
func RegisterBasicType(ts *TypeSet, keyword string, celType *cel.Type, converter typedValueConverter) (VariableType, error)
RegisterBasicType registers a basic type with the given keyword, CEL type, and converter.
func RegisterCustomType ¶ added in v1.43.0
func RegisterCustomType[T CustomType](ts *TypeSet, keyword string, baseCelType *cel.Type, converter typedValueConverter, opts ...cel.EnvOption) (VariableType, error)
RegisterCustomType registers a custom type that wraps a base CEL type.
func RegisterIPAddressType ¶ added in v1.43.0
func RegisterIPAddressType(ts *TypeSet) (VariableType, error)
func (VariableType) CelType ¶
func (vt VariableType) CelType() *cel.Type
CelType returns the underlying CEL type for the variable type.
func (VariableType) ConvertValue ¶
func (vt VariableType) ConvertValue(value any) (any, error)
ConvertValue converts the given value into one expected by this variable type.
func (VariableType) String ¶
func (vt VariableType) String() string