mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/envflag: add -envflag.prefix
for setting optional prefix for environment vars
This commit is contained in:
parent
b41ee5f27d
commit
b98ca56d94
1 changed files with 8 additions and 4 deletions
|
@ -7,9 +7,12 @@ import (
|
|||
"strings"
|
||||
)
|
||||
|
||||
var enable = flag.Bool("envflag.enable", false, "Whether to enable reading flags from environment variables additionally to command line. "+
|
||||
"Command line flag values have priority over values from environment vars. "+
|
||||
"Flags are read only from command line if this flag isn't set")
|
||||
var (
|
||||
enable = flag.Bool("envflag.enable", false, "Whether to enable reading flags from environment variables additionally to command line. "+
|
||||
"Command line flag values have priority over values from environment vars. "+
|
||||
"Flags are read only from command line if this flag isn't set")
|
||||
prefix = flag.String("envflag.prefix", "", "Prefix for environment variables if -envflag.enable is set")
|
||||
)
|
||||
|
||||
// Parse parses environment vars and command-line flags.
|
||||
//
|
||||
|
@ -48,5 +51,6 @@ func Parse() {
|
|||
func getEnvFlagName(s string) string {
|
||||
// Substitute dots with underscores, since env var names cannot contain dots.
|
||||
// See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/311#issuecomment-586354129 for details.
|
||||
return strings.ReplaceAll(s, ".", "_")
|
||||
s = strings.ReplaceAll(s, ".", "_")
|
||||
return *prefix + s
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue