-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
44 lines (38 loc) · 1.25 KB
/
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
42
43
44
package config
// Load config to `dst` struct pointer from shell env variables and docker secrets.
func Load(dst interface{}) error {
return LoadEnvAndDockerSecret(dst)
}
// MustLoad load config to `dst` struct pointer from shell env variables and docker secrets.
// It panic when an error occurs.
func MustLoad(dst interface{}) {
err := Load(dst)
if err != nil {
panic(err)
}
}
// LoadEnvAndSecret load config to `dst` struct pointer from shell env variables and container secrets.
func LoadEnvAndSecret(dst interface{}, secretPath string) error {
l := loader{
Env: true,
Secret: true,
Path: secretPath,
}
return l.load(dst)
}
// LoadEnvAndDockerSecret load config to `dst` struct pointer from shell env variables and docker secrets.
func LoadEnvAndDockerSecret(dst interface{}) error {
return LoadEnvAndSecret(dst, "/run/secrets")
}
// LoadEnvAndKubernetesSecret load config to `dst` struct pointer from shell env variables and kubernetes secrets.
func LoadEnvAndKubernetesSecret(dst interface{}) error {
return LoadEnvAndSecret(dst, "/etc/secret-volume")
}
// LoadEnv load config to `dst` struct pointer from shell env variables only
func LoadEnv(dst interface{}) error {
l := loader{
Env: true,
Secret: false,
}
return l.load(dst)
}