forked from TrueCloudLab/frostfs-node
[#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:
parent
1aa88159ca
commit
32dc80e7bc
1 changed files with 4 additions and 3 deletions
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue