mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/envflag: check for incorrect flag values read from environment vars
This commit is contained in:
parent
9c5db9400c
commit
fcdd95a6ef
1 changed files with 5 additions and 1 deletions
|
@ -2,6 +2,7 @@ package envflag
|
|||
|
||||
import (
|
||||
"flag"
|
||||
"log"
|
||||
"os"
|
||||
)
|
||||
|
||||
|
@ -34,7 +35,10 @@ func Parse() {
|
|||
}
|
||||
// Get flag value from environment var.
|
||||
if v, ok := os.LookupEnv(f.Name); ok {
|
||||
f.Value.Set(v)
|
||||
if err := f.Value.Set(v); err != nil {
|
||||
// Do not use lib/logger here, since it is uninitialized yet.
|
||||
log.Fatalf("cannot set flag %s to %q, which is read from environment variable: %s", f.Name, v, err)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue