MCPcopy Create free account
hub / github.com/cel-expr/cel-go / NewCustomEnv

Function NewCustomEnv

cel/env.go:384–404  ·  view source on GitHub ↗

NewCustomEnv creates a custom program environment which is not automatically configured with the standard library of functions and macros documented in the CEL spec. The purpose for using a custom environment might be for subsetting the standard library produced by the cel.StdLib() function. Subset

(opts ...EnvOption)

Source from the content-addressed store, hash-verified

382// See the EnvOption helper functions for the options that can be used to configure the
383// environment.
384func NewCustomEnv(opts ...EnvOption) (*Env, error) {
385 registry, err := types.NewRegistry()
386 if err != nil {
387 return nil, err
388 }
389 return (&Env{
390 variables: []*decls.VariableDecl{},
391 functions: map[string]*decls.FunctionDecl{},
392 macros: []parser.Macro{},
393 Container: containers.DefaultContainer,
394 adapter: registry,
395 provider: registry,
396 features: map[int]bool{},
397 appliedFeatures: map[int]bool{},
398 limits: map[limitID]int{},
399 libraries: map[string]SingletonLibrary{},
400 validators: []ASTValidator{},
401 progOpts: []ProgramOption{},
402 costOptions: []checker.CostOption{},
403 }).configure(opts)
404}
405
406// Check performs type-checking on the input Ast and yields a checked Ast and/or set of Issues.
407// If any `ASTValidators` are configured on the environment, they will be applied after a valid

Callers 15

envOptionToConfigFunction · 0.92
CreateEnvMethod · 0.92
compileRuleMethod · 0.92
compileFunction · 0.92
TestFunctionsForVersionsFunction · 0.92
initFunction · 0.92
ToConfigMethod · 0.85
getStdEnvFunction · 0.85
TestFunctionMergeFunction · 0.85

Calls 2

NewRegistryFunction · 0.92
configureMethod · 0.80