[#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>
This commit is contained in:
Leonard Lyubich 2021-05-21 20:30:19 +03:00 committed by Leonard Lyubich
parent 1aa88159ca
commit 32dc80e7bc

View file

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