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

Function NewCustomEnv

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

361// See the EnvOption helper functions for the options that can be used to configure the
362// environment.
363func NewCustomEnv(opts ...EnvOption) (*Env, error) {
364 registry, err := types.NewProtoRegistry()
365 if err != nil {
366 return nil, err
367 }
368 return (&Env{
369 variables: []*decls.VariableDecl{},
370 functions: map[string]*decls.FunctionDecl{},
371 functionBindings: []*functions.Overload{},
372 macros: []parser.Macro{},
373 Container: containers.DefaultContainer,
374 adapter: registry,
375 provider: registry,
376 features: map[int]bool{},
377 appliedFeatures: map[int]bool{},
378 limits: map[limitID]int{},
379 libraries: map[string]SingletonLibrary{},
380 validators: []ASTValidator{},
381 progOpts: []ProgramOption{},
382 costOptions: []checker.CostOption{},
383 }).configure(opts)
384}
385
386// Check performs type-checking on the input Ast and yields a checked Ast and/or set of Issues.
387// 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

NewProtoRegistryFunction · 0.92
configureMethod · 0.80