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)
| 359 | // See the EnvOption helper functions for the options that can be used to configure the |
| 360 | // environment. |
| 361 | func 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. |