From 32dc80e7bcac25f43d5616177914209e55b9c938 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Fri, 21 May 2021 20:30:19 +0300 Subject: [PATCH] [#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 --- cmd/neofs-node/config/config.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cmd/neofs-node/config/config.go b/cmd/neofs-node/config/config.go index d3b06d30dd..fbad8f6eaa 100644 --- a/cmd/neofs-node/config/config.go +++ b/cmd/neofs-node/config/config.go @@ -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()