Merge pull request #322 from thockin/parse-int

Allow octal and hex values for int flags
This commit is contained in:
Kubernetes Prow Robot 2021-01-07 05:57:46 -08:00 committed by GitHub
commit 6f3d9e4e16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -199,12 +199,12 @@ func envBool(key string, def bool) bool {
func envInt(key string, def int) int {
if env := os.Getenv(key); env != "" {
val, err := strconv.Atoi(env)
val, err := strconv.ParseInt(env, 0, 0)
if err != nil {
log.Error(err, "invalid env value, using default", "key", key, "val", os.Getenv(key), "default", def)
return def
}
return val
return int(val)
}
return def
}