forked from TrueCloudLab/frostfs-node
[#493] node/config: Implement ENV variable key constructor
Add `internal.Env` function which converts path to config value to ENV variable key. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
270b147205
commit
099ceeae50
2 changed files with 29 additions and 0 deletions
|
@ -1,8 +1,22 @@
|
||||||
package internal
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
// EnvPrefix is a prefix of ENV variables related
|
// EnvPrefix is a prefix of ENV variables related
|
||||||
// to storage node configuration.
|
// to storage node configuration.
|
||||||
const EnvPrefix = "neofs"
|
const EnvPrefix = "neofs"
|
||||||
|
|
||||||
// EnvSeparator is a section separator in ENV variables.
|
// EnvSeparator is a section separator in ENV variables.
|
||||||
const EnvSeparator = "_"
|
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,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
15
cmd/neofs-node/config/internal/env_test.go
Normal file
15
cmd/neofs-node/config/internal/env_test.go
Normal file
|
@ -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"),
|
||||||
|
)
|
||||||
|
}
|
Loading…
Reference in a new issue