Package env provides a representation of a CEL environment.
This section is empty.
This section is empty.
This section is empty.
type Config struct { Name string `yaml:"name,omitempty"` Description string `yaml:"description,omitempty"` Container string `yaml:"container,omitempty"` Imports []*Import `yaml:"imports,omitempty"` StdLib *LibrarySubset `yaml:"stdlib,omitempty"` Extensions []*Extension `yaml:"extensions,omitempty"` ContextVariable *ContextVariable `yaml:"context_variable,omitempty"` Variables []*Variable `yaml:"variables,omitempty"` Functions []*Function `yaml:"functions,omitempty"` Validators []*Validator `yaml:"validators,omitempty"` Features []*Feature `yaml:"features,omitempty"` }
Config represents a serializable form of the CEL environment configuration.
Note: custom validations, feature flags, and performance tuning parameters are not (yet) considered part of the core CEL environment configuration and should be managed separately until a common convention for such settings is developed.
NewConfig creates an instance of a YAML serializable CEL environment configuration.
AddExtensions appends a set of extensions to the config.
AddFeatures appends one or more features to the config.
AddFunctionDecls adds one or more functions to the config, converting them to serializable values first.
FunctionDecl inputs are expected to be well-formed.
AddFunctions adds one or more functions to the config.
AddImports appends a set of imports to the config.
AddValidators appends one or more validators to the config.
AddVariableDecls adds one or more variables to the config, converting them to serializable values first.
VariableDecl inputs are expected to be well-formed.
AddVariables adds one or more vairables to the config.
SetContainer configures the container name for this configuration.
SetContextVariable configures the ContextVariable for this configuration.
SetStdLib configures the LibrarySubset for the standard library.
Validate validates the whole configuration is well-formed.
type ContextVariable struct { TypeName string `yaml:"type_name"` }
ContextVariable represents a structured message whose fields are to be treated as the top-level variable identifiers within CEL expressions.
NewContextVariable returns a serializable context variable with a specific type name.
Validate validates the context-variable configuration is well-formed.
type Extension struct { Name string `yaml:"name"` Version string `yaml:"version,omitempty"` }
Extension represents a named and optionally versioned extension library configured in the environment.
NewExtension creates a serializable Extension from a name and version string.
Validate validates the extension configuration is well-formed.
VersionNumber returns the parsed version string, or an error if the version cannot be parsed.
type Feature struct { Name string `yaml:"name"` Enabled bool `yaml:"enabled"` }
Feature represents a named boolean feature flag supported by CEL.
NewFeature creates a new feature flag with a boolean enablement flag.
Validate validates whether the feature is well-configured.
type Function struct { Name string `yaml:"name"` Description string `yaml:"description,omitempty"` Overloads []*Overload `yaml:"overloads,omitempty"` }
Function represents the serializable format of a function and its overloads.
NewFunction creates a serializable function and overload set.
NewFunctionWithDoc creates a serializable function and overload set.
AsCELFunction converts the serializable form of the Function into CEL environment declaration.
Validate validates the function configuration is well-formed.
type Import struct { Name string `yaml:"name"` }
Import represents a type name that will be appreviated by its simple name using the cel.Abbrevs() option.
NewImport returns a serializable import value from the qualified type name.
Validate validates the import configuration is well-formed.
type LibrarySubset struct { Disabled bool `yaml:"disabled,omitempty"` DisableMacros bool `yaml:"disable_macros,omitempty"` IncludeMacros []string `yaml:"include_macros,omitempty"` ExcludeMacros []string `yaml:"exclude_macros,omitempty"` IncludeFunctions []*Function `yaml:"include_functions,omitempty"` ExcludeFunctions []*Function `yaml:"exclude_functions,omitempty"` }
LibrarySubset indicates a subset of the macros and function supported by a subsettable library.
NewLibrarySubset returns an empty library subsetting config which permits all library features.
AddExcludedFunctions deny-lists one or more functions from the subset.
AddExcludedMacros deny-lists one or more macros by function name.
AddIncludedFunctions allow-lists one or more functions from the subset.
Note, this option will override any excluded functions.
AddIncludedMacros allow-lists one or more macros by function name.
Note, this option will override any excluded macros.
SetDisableMacros disables the macros for the library.
SetDisabled disables or enables the library.
SubsetFunction produces a function declaration which matches the supported subset, or nil if the function is not supported by the LibrarySubset.
For IncludeFunctions, if the function does not specify a set of overloads to include, the whole function definition is included. If overloads are set, then a new function which includes only the specified overloads is produced.
For ExcludeFunctions, if the function does not specify a set of overloads to exclude, the whole function definition is excluded. If overloads are set, then a new function which includes only the permitted overloads is produced.
SubsetMacro indicates whether the macro function should be included in the library subset.
Validate validates the library configuration is well-formed.
For example, setting both the IncludeMacros and ExcludeMacros together could be confusing and create a broken expectation, likewise for IncludeFunctions and ExcludeFunctions.
type Overload struct { ID string `yaml:"id"` Examples []string `yaml:"examples,omitempty"` Target *TypeDesc `yaml:"target,omitempty"` Args []*TypeDesc `yaml:"args,omitempty"` Return *TypeDesc `yaml:"return,omitempty"` }
Overload represents the serializable format of a function overload.
NewMemberOverload returns a new serializable representation of a member (receiver) overload.
NewOverload returns a new serializable representation of a global overload.
AsFunctionOption converts the serializable form of the Overload into a function declaration option.
Validate validates the overload configuration is well-formed.
type TypeDesc struct { TypeName string `yaml:"type_name"` Params []*TypeDesc `yaml:"params,omitempty"` IsTypeParam bool `yaml:"is_type_param,omitempty"` }
TypeDesc represents the serializable format of a CEL *types.Type value.
NewTypeDesc describes a simple or complex type with parameters.
NewTypeParam describe a type-param type.
SerializeTypeDesc converts a CEL native *types.Type to a serializable TypeDesc.
AsCELType converts the serializable object to a *types.Type value.
String implements the strings.Stringer interface method.
Validate validates the type configuration is well-formed.
type Validator struct { Name string `yaml:"name"` Config map[string]any `yaml:"config,omitempty"` }
Validator represents a named validator with an optional map-based configuration object.
Note: the map-keys must directly correspond to the internal representation of the original validator, and should only use primitive scalar types as values at this time.
NewValidator returns a named Validator instance.
ConfigValue retrieves the value associated with the config key name, if one exists.
SetConfig sets the set of map key-value pairs associated with this validator's configuration.
Validate validates the configuration of the validator object.
type Variable struct { Name string `yaml:"name"` Description string `yaml:"description,omitempty"` Type *TypeDesc `yaml:"type,omitempty"` *TypeDesc `yaml:",inline"` }
Variable represents a typed variable declaration which will be published via the cel.VariableDecls() option.
NewVariable returns a serializable variable from a name and type definition
NewVariableWithDoc returns a serializable variable from a name, type definition, and doc string.
AsCELVariable converts the serializable form of the Variable into a CEL environment declaration.
GetType returns the variable type description.
Note, if both the embedded TypeDesc and the field Type are non-nil, the embedded TypeDesc will take precedence.
Validate validates the variable configuration is well-formed.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4