[#493] node/config: Export ENV constants from internal package

Replace ENV prefix and separator to `internal` package in order to reuse
them for testing.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-05-21 20:36:37 +03:00 committed by Leonard Lyubich
parent 32dc80e7bc
commit 270b147205
2 changed files with 12 additions and 7 deletions

View file

@ -4,6 +4,7 @@ import (
"fmt"
"strings"
"github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/internal"
"github.com/spf13/viper"
)
@ -19,11 +20,7 @@ type Config struct {
path []string
}
const (
separator = "."
envPrefix = "neofs"
envSeparator = "_"
)
const separator = "."
// Prm groups required parameters of the Config.
type Prm struct{}
@ -36,9 +33,9 @@ type Prm struct{}
func New(_ Prm, opts ...Option) *Config {
v := viper.New()
v.SetEnvPrefix(EnvPrefix)
v.SetEnvPrefix(internal.EnvPrefix)
v.AutomaticEnv()
v.SetEnvKeyReplacer(strings.NewReplacer(separator, EnvSeparator))
v.SetEnvKeyReplacer(strings.NewReplacer(separator, internal.EnvSeparator))
o := defaultOpts()
for i := range opts {

View file

@ -0,0 +1,8 @@
package internal
// EnvPrefix is a prefix of ENV variables related
// to storage node configuration.
const EnvPrefix = "neofs"
// EnvSeparator is a section separator in ENV variables.
const EnvSeparator = "_"