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

Function NewCustomEnv

cel/env.go:447–468  ·  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

445// See the EnvOption helper functions for the options that can be used to configure the
446// environment.
447func NewCustomEnv(opts ...EnvOption) (*Env, error) {
448 registry, err := types.NewRegistry()
449 if err != nil {
450 return nil, err
451 }
452 return (&Env{
453 variables: []*decls.VariableDecl{},
454 functions: map[string]*decls.FunctionDecl{},
455 macros: []parser.Macro{},
456 Container: containers.DefaultContainer,
457 adapter: registry,
458 provider: registry,
459 features: map[int]bool{},
460 appliedFeatures: map[int]bool{},
461 limits: map[limitID]int{},
462 libraries: map[string]SingletonLibrary{},
463 validators: []ASTValidator{},
464 progOpts: []ProgramOption{},
465 costOptions: []cost.Option{},
466 costConfig: &costConfig{},
467 }).configure(opts)
468}
469
470// Check performs type-checking on the input Ast and yields a checked Ast and/or set of Issues.
471// 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