diff --git a/cmd/neofs-node/config/internal/env.go b/cmd/neofs-node/config/internal/env.go index e517425438..43cd8d446e 100644 --- a/cmd/neofs-node/config/internal/env.go +++ b/cmd/neofs-node/config/internal/env.go @@ -1,8 +1,22 @@ package internal +import ( + "strings" +) + // 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 = "_" + +// Env returns ENV variable key for particular config parameter. +func Env(path ...string) string { + return strings.ToUpper( + strings.Join( + append([]string{EnvPrefix}, path...), + EnvSeparator, + ), + ) +} diff --git a/cmd/neofs-node/config/internal/env_test.go b/cmd/neofs-node/config/internal/env_test.go new file mode 100644 index 0000000000..a599ad457a --- /dev/null +++ b/cmd/neofs-node/config/internal/env_test.go @@ -0,0 +1,15 @@ +package internal_test + +import ( + "testing" + + "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/internal" + "github.com/stretchr/testify/require" +) + +func TestEnv(t *testing.T) { + require.Equal(t, + "NEOFS_SECTION_PARAMETER", + internal.Env("section", "parameter"), + ) +}