mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-01 11:08:10 +00:00
backport of commit 3a46ecc389 (#21362)
Co-authored-by: Violet Hynes <violet.hynes@hashicorp.com>
This commit is contained in:
committed by
GitHub
parent
2251721aab
commit
0f58c6f3e0
@@ -989,33 +989,3 @@ func (d *timeValue) Get() interface{} { return *d.target }
|
||||
func (d *timeValue) String() string { return (*d.target).String() }
|
||||
func (d *timeValue) Example() string { return "time" }
|
||||
func (d *timeValue) Hidden() bool { return d.hidden }
|
||||
|
||||
// -- helpers
|
||||
func envDefault(key, def string) string {
|
||||
if v, exist := os.LookupEnv(key); exist {
|
||||
return v
|
||||
}
|
||||
return def
|
||||
}
|
||||
|
||||
func envBoolDefault(key string, def bool) bool {
|
||||
if v, exist := os.LookupEnv(key); exist {
|
||||
b, err := strconv.ParseBool(v)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return b
|
||||
}
|
||||
return def
|
||||
}
|
||||
|
||||
func envDurationDefault(key string, def time.Duration) time.Duration {
|
||||
if v, exist := os.LookupEnv(key); exist {
|
||||
d, err := time.ParseDuration(v)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return d
|
||||
}
|
||||
return def
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user