MCPcopy Index your code
hub / github.com/opencloud-eu/opencloud / ParseConfig

Function ParseConfig

pkg/config/parser/parse.go:15–38  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

13// copies applicable parts into the commons part, from
14// where the services can copy it into their own config
15func 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

Callers 6

BackupCommandFunction · 0.92
ServerFunction · 0.92
TrashCommandFunction · 0.92
RevisionsCommandFunction · 0.92
ServiceCommandFunction · 0.92
ListCommandFunction · 0.92

Calls 5

BindSourcesToStructsFunction · 0.92
DecodeFunction · 0.92
EnsureCommonsFunction · 0.85
EnsureDefaultsFunction · 0.70
ValidateFunction · 0.70

Tested by

no test coverage detected