From 270b147205132ed370a7e277f87855f6976b26cd Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Fri, 21 May 2021 20:36:37 +0300 Subject: [PATCH] [#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 --- cmd/neofs-node/config/config.go | 11 ++++------- cmd/neofs-node/config/internal/env.go | 8 ++++++++ 2 files changed, 12 insertions(+), 7 deletions(-) create mode 100644 cmd/neofs-node/config/internal/env.go diff --git a/cmd/neofs-node/config/config.go b/cmd/neofs-node/config/config.go index fbad8f6e..080a88f6 100644 --- a/cmd/neofs-node/config/config.go +++ b/cmd/neofs-node/config/config.go @@ -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 { diff --git a/cmd/neofs-node/config/internal/env.go b/cmd/neofs-node/config/internal/env.go new file mode 100644 index 00000000..e5174254 --- /dev/null +++ b/cmd/neofs-node/config/internal/env.go @@ -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 = "_"