Simplify some config loading code

This commit is contained in:
Bjørn Erik Pedersen 2021-03-21 13:29:11 +01:00
parent 57d8d208ed
commit df8bb8812f
No known key found for this signature in database
GPG key ID: 330E6E2BD4859D8F

View file

@ -167,12 +167,15 @@ func LoadConfig(d ConfigSourceDescriptor, doWithConfig ...func(cfg config.Provid
}
}
// This is invoked both after we load the main config and at the end
// to support OS env override of config options used in the module collector.
applyOsEnvOverrides := func() error {
if d.Environ == nil {
return nil
}
const delim = "__env__delim"
// Apply environment overrides
if len(d.Environ) > 0 {
// Extract all that start with the HUGO prefix.
// The delimiter is the following rune, usually "_".
const hugoEnvPrefix = "HUGO"
@ -222,8 +225,6 @@ func LoadConfig(d ConfigSourceDescriptor, doWithConfig ...func(cfg config.Provid
}
}
}
return nil
}