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)
| 605 | // as the type provider configured at the time when the config is processed is the one used to derive |
| 606 | // type references from the configuration. |
| 607 | func FromConfig(config *env.Config, optFactories ...ConfigOptionFactory) EnvOption { |
| 608 | return func(e *Env) (*Env, error) { |
| 609 | if err := config.Validate(); err != nil { |
| 610 | return nil, err |
| 611 | } |
| 612 | opts, err := configToEnvOptions(config, e.CELTypeProvider(), optFactories) |
| 613 | if err != nil { |
| 614 | return nil, err |
| 615 | } |
| 616 | for _, o := range opts { |
| 617 | e, err = o(e) |
| 618 | if err != nil { |
| 619 | return nil, err |
| 620 | } |
| 621 | } |
| 622 | return e, nil |
| 623 | } |
| 624 | } |
| 625 | |
| 626 | // configToEnvOptions generates a set of EnvOption values (or error) based on a config, a type provider, |
| 627 | // and an optional set of environment options. |