-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.go
41 lines (37 loc) · 909 Bytes
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main
import (
"os"
)
type Config struct {
LdapHost string
LdapPassword string
LdapBindDN string
LdapBaseDN string
CFApiURL string
CFUsername string
CFPassword string
CFOrg string
CFDefaultSpace string
ConfigFile string
}
func DefaultConfig() *Config {
return &Config{
LdapHost: os.Getenv("LdapHost"),
LdapPassword: os.Getenv("LdapPassword"),
LdapBindDN: os.Getenv("LdapBindDN"),
LdapBaseDN: os.Getenv("LdapBaseDN"),
CFApiURL: os.Getenv("CFApiURL"),
CFUsername: os.Getenv("CFUsername"),
CFPassword: os.Getenv("CFPassword"),
CFOrg: getEnv("CFOrg","system"),
CFDefaultSpace: getEnv("CFDefaultSpace", "system"),
ConfigFile: os.Getenv("ConfigFile"),
}
}
func getEnv(key, defaultValue string) string {
value := os.Getenv(key)
if len(value) == 0 {
return defaultValue
}
return value
}