-
Notifications
You must be signed in to change notification settings - Fork 0
/
env.go
92 lines (72 loc) · 1.72 KB
/
env.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package env
import (
"os"
"strings"
"github.com/alomerry/go-tools/static/cons"
)
func GetElasticSearchEndpoint() string {
return os.Getenv(cons.ELASTICSEARCH_ENDPOINT)
}
func GetCloudflareAccountId() string {
return os.Getenv(cons.CloudflareAccountId)
}
func GetCloudflareR2AccountSK() string {
return os.Getenv(cons.CloudflareR2AccountSK)
}
func GetCloudflareR2AccountKey() string {
return os.Getenv(cons.CloudflareR2AccountKey)
}
func GetWithLocalElasticSearchEndpoint() string {
if GetEnv() == cons.EnvLocal {
return os.Getenv(cons.LOCAL_ELASTICSEARCH_ENDPOINT)
}
return GetElasticSearchEndpoint()
}
func GetElasticSearchAK() string {
return os.Getenv(cons.ELASTICSEARCH_PASSWORD)
}
func Debug() bool {
return os.Getenv(cons.DEBUG) == cons.DEBUG
}
func GetEnv() string {
return os.Getenv(cons.ENV)
}
func GetKubeConfig() string {
return os.Getenv(cons.KUBECONFIG)
}
func GetDBSalt() string {
return os.Getenv(cons.DATABASE_SALT)
}
func GetJwtSecret() string {
return os.Getenv(cons.JWT_SECRET)
}
func GetRedisDSN() string {
return os.Getenv(cons.REDIS_DSN)
}
func GetWithLocalRedisDSN() string {
if GetEnv() == cons.EnvLocal {
return os.Getenv(cons.LOCAL_REDIS_DSN)
}
return GetRedisDSN()
}
func GetRedisAK() string {
return os.Getenv(cons.REDIS_AK)
}
func GetWithLocalRedisAK() string {
if GetEnv() == cons.EnvLocal {
return os.Getenv(cons.LOCAL_REDIS_AK)
}
return GetRedisAK()
}
func GetMysqlAdminDSN() string {
return os.Getenv(cons.MYSQL_ADMIN_DSN)
}
func GetWithLocalMysqlAdminDSN() string {
if GetEnv() == cons.EnvLocal {
return os.Getenv(cons.LOCAL_MYSQL_ADMIN_DSN)
}
return GetMysqlAdminDSN()
}
func GetRedisClusterDSN() []string {
return strings.Split(os.Getenv(cons.REDIS_CLUSTER_DSN), ",")
}