[#493] node/config: Always read the values of ENV variables

In previous implementation ENV values were read only if config filepath is
specified. From now ENVs are always read to `Config`.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
remotes/KirillovDenis/release/v0.21.1
Leonard Lyubich 2021-05-21 20:30:19 +03:00 committed by Leonard Lyubich
parent 1aa88159ca
commit 32dc80e7bc
1 changed files with 4 additions and 3 deletions

View File

@ -36,15 +36,16 @@ type Prm struct{}
func New(_ Prm, opts ...Option) *Config {
v := viper.New()
v.SetEnvPrefix(EnvPrefix)
v.AutomaticEnv()
v.SetEnvKeyReplacer(strings.NewReplacer(separator, EnvSeparator))
o := defaultOpts()
for i := range opts {
opts[i](o)
}
if o.path != "" {
v.SetEnvPrefix(envPrefix)
v.AutomaticEnv()
v.SetEnvKeyReplacer(strings.NewReplacer(separator, envSeparator))
v.SetConfigFile(o.path)
err := v.ReadInConfig()