Provide config helpers for environment variables
am: 99d7c23006
Change-Id: I982ed5896d997913b8b3f0d947e92dd3eb9814be
This commit is contained in:
commit
8c093e5034
1 changed files with 18 additions and 0 deletions
|
@ -291,6 +291,24 @@ func (c *config) Getenv(key string) string {
|
|||
return val
|
||||
}
|
||||
|
||||
func (c *config) GetenvWithDefault(key string, defaultValue string) string {
|
||||
ret := c.Getenv(key)
|
||||
if ret == "" {
|
||||
return defaultValue
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
func (c *config) IsEnvTrue(key string) bool {
|
||||
value := c.Getenv(key)
|
||||
return value == "1" || value == "y" || value == "yes" || value == "on" || value == "true"
|
||||
}
|
||||
|
||||
func (c *config) IsEnvFalse(key string) bool {
|
||||
value := c.Getenv(key)
|
||||
return value == "0" || value == "n" || value == "no" || value == "off" || value == "false"
|
||||
}
|
||||
|
||||
func (c *config) EnvDeps() map[string]string {
|
||||
c.envLock.Lock()
|
||||
c.envFrozen = true
|
||||
|
|
Loading…
Reference in a new issue