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

Function NewEnv

cel/env.go:361–372  ·  view source on GitHub ↗

NewEnv creates a program environment configured with the standard library of CEL functions and macros. The Env value returned can parse and check any CEL program which builds upon the core features documented in the CEL specification. See the EnvOption helper functions for the options that can be u

(opts ...EnvOption)

Source from the content-addressed store, hash-verified

359// See the EnvOption helper functions for the options that can be used to configure the
360// environment.
361func NewEnv(opts ...EnvOption) (*Env, error) {
362 // Extend the statically configured standard environment, disabling eager validation to ensure
363 // the cost of setup for the environment is still just as cheap as it is in v0.11.x and earlier
364 // releases. The user provided options can easily re-enable the eager validation as they are
365 // processed after this default option.
366 stdOpts := append([]EnvOption{EagerlyValidateDeclarations(false)}, opts...)
367 env, err := getStdEnv()
368 if err != nil {
369 return nil, err
370 }
371 return env.Extend(stdOpts...)
372}
373
374// NewCustomEnv creates a custom program environment which is not automatically configured with the
375// standard library of functions and macros documented in the CEL spec.

Callers 15

TestConfigFunction · 0.92
TestConfigErrorsFunction · 0.92
TestSimpleVariablesFunction · 0.92
TestCompose_SourceInfoFunction · 0.92
TestCompose_UnnestFunction · 0.92
TestRuleComposerErrorFunction · 0.92
BenchmarkReferenceCasesFunction · 0.92
bench.goFile · 0.92
TestNetwork_SuccessFunction · 0.92

Calls 3

getStdEnvFunction · 0.85
ExtendMethod · 0.45

Tested by 15

TestConfigFunction · 0.74
TestConfigErrorsFunction · 0.74
TestSimpleVariablesFunction · 0.74
TestCompose_SourceInfoFunction · 0.74
TestCompose_UnnestFunction · 0.74
TestRuleComposerErrorFunction · 0.74
BenchmarkReferenceCasesFunction · 0.74
TestNetwork_SuccessFunction · 0.74
testCostFunction · 0.74