FromConfig produces and applies a set of EnvOption values derived from an env.Config object. For configuration elements which refer to features outside of the `cel` package, an optional set of ConfigOptionFactory values may be passed in to support the conversion from static configuration to configu
(config *env.Config, optFactories ...ConfigOptionFactory)
| 531 | // as the type provider configured at the time when the config is processed is the one used to derive |
| 532 | // type references from the configuration. |
| 533 | func FromConfig(config *env.Config, optFactories ...ConfigOptionFactory) EnvOption { |
| 534 | return func(e *Env) (*Env, error) { |
| 535 | if err := config.Validate(); err != nil { |
| 536 | return nil, err |
| 537 | } |
| 538 | opts, err := configToEnvOptions(config, e.CELTypeProvider(), optFactories) |
| 539 | if err != nil { |
| 540 | return nil, err |
| 541 | } |
| 542 | for _, o := range opts { |
| 543 | e, err = o(e) |
| 544 | if err != nil { |
| 545 | return nil, err |
| 546 | } |
| 547 | } |
| 548 | return e, nil |
| 549 | } |
| 550 | } |
| 551 | |
| 552 | // configToEnvOptions generates a set of EnvOption values (or error) based on a config, a type provider, |
| 553 | // and an optional set of environment options. |