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)
| 546 | // as the type provider configured at the time when the config is processed is the one used to derive |
| 547 | // type references from the configuration. |
| 548 | func FromConfig(config *env.Config, optFactories ...ConfigOptionFactory) EnvOption { |
| 549 | return func(e *Env) (*Env, error) { |
| 550 | if err := config.Validate(); err != nil { |
| 551 | return nil, err |
| 552 | } |
| 553 | opts, err := configToEnvOptions(config, e.CELTypeProvider(), optFactories) |
| 554 | if err != nil { |
| 555 | return nil, err |
| 556 | } |
| 557 | for _, o := range opts { |
| 558 | e, err = o(e) |
| 559 | if err != nil { |
| 560 | return nil, err |
| 561 | } |
| 562 | } |
| 563 | return e, nil |
| 564 | } |
| 565 | } |
| 566 | |
| 567 | // configToEnvOptions generates a set of EnvOption values (or error) based on a config, a type provider, |
| 568 | // and an optional set of environment options. |