types

package
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AnyParamType = registerParamType(
		openfgav1.ConditionParamTypeRef_TYPE_NAME_ANY,
		cel.AnyType,
		anyTypeConverterFunc,
	)
	BoolParamType = registerParamType(
		openfgav1.ConditionParamTypeRef_TYPE_NAME_BOOL,
		cel.BoolType,
		primitiveTypeConverterFunc[bool],
	)
	StringParamType = registerParamType(
		openfgav1.ConditionParamTypeRef_TYPE_NAME_STRING,
		cel.StringType,
		primitiveTypeConverterFunc[string],
	)
	IntParamType = registerParamType(
		openfgav1.ConditionParamTypeRef_TYPE_NAME_INT,
		cel.IntType,
		numericTypeConverterFunc[int64],
	)
	UIntParamType = registerParamType(
		openfgav1.ConditionParamTypeRef_TYPE_NAME_UINT,
		cel.UintType,
		numericTypeConverterFunc[uint64],
	)
	DoubleParamType = registerParamType(
		openfgav1.ConditionParamTypeRef_TYPE_NAME_DOUBLE,
		cel.DoubleType,
		numericTypeConverterFunc[float64],
	)
	DurationParamType = registerParamType(
		openfgav1.ConditionParamTypeRef_TYPE_NAME_DURATION,
		cel.DurationType,
		durationTypeConverterFunc,
	)
	TimestampParamType = registerParamType(
		openfgav1.ConditionParamTypeRef_TYPE_NAME_TIMESTAMP,
		cel.TimestampType,
		timestampTypeConverterFunc,
	)
	MapParamType = registerParamTypeWithGenerics(
		openfgav1.ConditionParamTypeRef_TYPE_NAME_MAP,
		startingGenericTypeCount,
		mapTypeConverterFunc,
	)
	ListParamType = registerParamTypeWithGenerics(
		openfgav1.ConditionParamTypeRef_TYPE_NAME_LIST,
		startingGenericTypeCount,
		listTypeConverterFunc,
	)
)
View Source
var IPAddressType = registerCustomParamType(
	openfgav1.ConditionParamTypeRef_TYPE_NAME_IPADDRESS,
	cel.ObjectType("IPAddress"),
	ipaddressTypeConverterFunc,
	cel.Function("in_cidr",
		cel.MemberOverload("ipaddr_in_cidr",
			[]*cel.Type{cel.ObjectType("IPAddress"), cel.StringType},
			cel.BoolType,
			cel.BinaryBinding(ipaddressCELBinaryBinding),
		),
	),
)

IPAddressType defines a ParameterType that is used to represent IP addresses in CEL expressions.

Functions

func IPAddressEnvOption

func IPAddressEnvOption() cel.EnvOption

Types

type IPAddress

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

IPAddress represents a network IP address.

func ParseIPAddress

func ParseIPAddress(ip string) (IPAddress, error)

ParseIPAddress attempts to parse the provided ip string. If the provided string does not define a well-formed IP address, then an error is returned.

func (*IPAddress) CompileOptions

func (ip *IPAddress) CompileOptions() []cel.EnvOption

func (IPAddress) ConvertToNative

func (ip IPAddress) ConvertToNative(typeDesc reflect.Type) (any, error)

ConvertToNative implements the CEL ref.Val.ConvertToNative.

See https://pkg.go.dev/github.com/google/cel-go/common/types/ref#Val

func (IPAddress) ConvertToType

func (ip IPAddress) ConvertToType(typeValue ref.Type) ref.Val

ConvertToType implements the CEL ref.Val.ConvertToType.

See https://pkg.go.dev/github.com/google/cel-go/common/types/ref#Val

func (IPAddress) Equal

func (ip IPAddress) Equal(other ref.Val) ref.Val

Equal implements the CEL ref.Val.Equal.

See https://pkg.go.dev/github.com/google/cel-go/common/types/ref#Val

func (*IPAddress) ProgramOptions

func (ip *IPAddress) ProgramOptions() []cel.ProgramOption

func (IPAddress) Type

func (ip IPAddress) Type() ref.Type

Type implements the CEL ref.Val.Type.

See https://pkg.go.dev/github.com/google/cel-go/common/types/ref#Val

func (IPAddress) Value

func (ip IPAddress) Value() any

Value implements ref.Val.Value.

See https://pkg.go.dev/github.com/google/cel-go/common/types/ref#Val

type ParameterType

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

ParameterType defines the canonical representation of parameter types supported in conditions.

func DecodeParameterType

func DecodeParameterType(conditionParamType *openfgav1.ConditionParamTypeRef) (*ParameterType, error)

func NewParameterType

func NewParameterType(
	name openfgav1.ConditionParamTypeRef_TypeName,
	celType *cel.Type,
	generics []ParameterType,
	typedParamConverter typedParamValueConverter,
) ParameterType

func (ParameterType) CelType

func (pt ParameterType) CelType() *cel.Type

CelType returns the underlying Google CEL type for the variable type.

func (ParameterType) ConvertValue

func (pt ParameterType) ConvertValue(value any) (any, error)

func (ParameterType) String

func (pt ParameterType) String() string

Jump to

Keyboard shortcuts

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