mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-15 00:13:30 +01:00
lib/envflag: check for incorrect flag values read from environment vars
This commit is contained in:
parent
9c5db9400c
commit
fcdd95a6ef
@ -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 New Issue
Block a user