ParseConfig loads the opencloud configuration and copies applicable parts into the commons part, from where the services can copy it into their own config
(cfg *config.Config, skipValidate bool)
| 13 | // copies applicable parts into the commons part, from |
| 14 | // where the services can copy it into their own config |
| 15 | func ParseConfig(cfg *config.Config, skipValidate bool) error { |
| 16 | err := config.BindSourcesToStructs("opencloud", cfg) |
| 17 | if err != nil { |
| 18 | return err |
| 19 | } |
| 20 | |
| 21 | EnsureDefaults(cfg) |
| 22 | |
| 23 | // load all env variables relevant to the config in the current context. |
| 24 | if err := envdecode.Decode(cfg); err != nil { |
| 25 | // no environment variable set for this config is an expected "error" |
| 26 | if !errors.Is(err, envdecode.ErrNoTargetFieldsAreSet) { |
| 27 | return err |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | EnsureCommons(cfg) |
| 32 | |
| 33 | if skipValidate { |
| 34 | return nil |
| 35 | } |
| 36 | |
| 37 | return Validate(cfg) |
| 38 | } |
| 39 | |
| 40 | // EnsureDefaults ensures that all pointers in the |
| 41 | // OpenCloud config (not the services configs) are initialized |
no test coverage detected