easycel

package module
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: MIT Imports: 11 Imported by: 4

README

Easy CEl

Go Report Card GoDoc GitHub license

Easy CEL is a wrapping of https://github.com/google/cel-go

License

Licensed under the MIT License. See LICENSE for the full license text.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Environment

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

Environment is a wrapper around CEL environment

func NewEnvironment

func NewEnvironment(opts ...cel.EnvOption) (*Environment, error)

NewEnvironment creates a new CEL environment

func (*Environment) Program

func (e *Environment) Program(src string, opts ...cel.ProgramOption) (cel.Program, error)

Program creates a new CEL program

type Registry added in v0.3.0

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

func NewRegistry added in v0.3.0

func NewRegistry(libraryName string, opts ...RegistryOption) *Registry

NewRegistry creates adapter new Registry.

func (*Registry) CompileOptions added in v0.3.0

func (r *Registry) CompileOptions() []cel.EnvOption

CompileOptions implements the Library interface method.

func (*Registry) EnumValue added in v0.3.0

func (r *Registry) EnumValue(enumName string) ref.Val

EnumValue returns the numeric value of the given enum value name.

func (*Registry) FindIdent added in v0.3.0

func (r *Registry) FindIdent(identName string) (ref.Val, bool)

FindIdent takes adapter qualified identifier name and returns adapter Value if one exists.

func (*Registry) FindStructFieldNames added in v0.6.0

func (r *Registry) FindStructFieldNames(structType string) ([]string, bool)

FindStructFieldNames returns thet field names associated with the type, if the type is found.

func (*Registry) FindStructFieldType added in v0.5.0

func (r *Registry) FindStructFieldType(structType, fieldName string) (*types.FieldType, bool)

FindStructFieldType returns the field type for a checked type value. Returns false if the field could not be found.

func (*Registry) FindStructType added in v0.5.0

func (r *Registry) FindStructType(structType string) (*types.Type, bool)

FindStructType returns the Type give a qualified type name.

func (*Registry) LibraryName added in v0.3.0

func (r *Registry) LibraryName() string

LibraryName implements the Library interface method.

func (*Registry) NativeToValue added in v0.3.0

func (r *Registry) NativeToValue(value any) ref.Val

NativeToValue converts the input `value` to adapter CEL `ref.Val`.

func (*Registry) NewValue added in v0.3.0

func (r *Registry) NewValue(typeName string, fields map[string]ref.Val) ref.Val

NewValue creates adapter new type value from adapter qualified name and map of field name to value.

func (*Registry) ProgramOptions added in v0.3.0

func (r *Registry) ProgramOptions() []cel.ProgramOption

ProgramOptions implements the Library interface method.

func (*Registry) RegisterConversion added in v0.3.0

func (r *Registry) RegisterConversion(fun any) error

RegisterConversion registers adapter conversion function with the registry.

func (*Registry) RegisterFunction added in v0.3.0

func (r *Registry) RegisterFunction(name string, fun interface{}) error

RegisterFunction registers adapter function with the registry.

func (*Registry) RegisterMethod added in v0.3.0

func (r *Registry) RegisterMethod(name string, fun interface{}) error

RegisterMethod registers adapter method with the registry.

func (*Registry) RegisterType added in v0.3.0

func (r *Registry) RegisterType(refTypes any) error

RegisterType registers adapter type with the registry.

func (*Registry) RegisterVariable added in v0.4.0

func (r *Registry) RegisterVariable(name string, val interface{}) error

RegisterVariable registers adapter value with the registry.

type RegistryOption added in v0.3.0

type RegistryOption func(*Registry)

func WithTagName added in v0.4.0

func WithTagName(tagName string) RegistryOption

WithTagName sets the tag name used to convert types to CEL types.

func WithTypeAdapter added in v0.3.0

func WithTypeAdapter(adapter types.Adapter) RegistryOption

WithTypeAdapter sets the type adapter used to convert types to CEL types.

func WithTypeProvider added in v0.3.0

func WithTypeProvider(provider types.Provider) RegistryOption

WithTypeProvider sets the type provider used to convert types to CEL types.

type Type added in v0.5.0

type Type interface {
	ref.Val
	ref.Type
	TagName() string
	GetRawType() reflect.Type
}

Type provider for native types.

Jump to

Keyboard shortcuts

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