-
Notifications
You must be signed in to change notification settings - Fork 0
/
load_envs.go
90 lines (76 loc) · 2.12 KB
/
load_envs.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
package utils
import (
"context"
"github.com/bujosa/xihe/env"
)
type ContextKey string
const (
ProjectIdKey ContextKey = "projectId"
BucketNameKey ContextKey = "bucketName"
SubFolderPathKey ContextKey = "subFolderPath"
CountryVersionId ContextKey = "countryVersionId"
CategoryId ContextKey = "categoryId"
GeoCode ContextKey = "geoCode"
DbUri ContextKey = "dbUri"
ProductionApiUrl ContextKey = "productionApiUrl"
SessionSecret ContextKey = "sessionSecret"
CityId ContextKey = "cityId"
SpotId ContextKey = "spotId"
)
func LoadEnvs(ctx *context.Context) {
projectId, err := env.GetString("GOOGLE_PROJECT_ID")
if err != nil {
panic(err)
}
bucketName, err := env.GetString("GOOGLE_BUCKET_NAME")
if err != nil {
panic(err)
}
subFolderPath, err := env.GetString("GOOGLE_SUBFOLDER_PATH")
if err != nil {
subFolderPath = ""
}
countryVersion, err := env.GetString("COUNTRY_VERSION_ID")
if err != nil {
panic(err)
}
category, err := env.GetString("CATEGORY_ID")
if err != nil {
panic(err)
}
value, err := env.GetString("GEOCODE")
if err != nil {
panic(err)
}
databaseURL, err := env.GetString(DB_URL_ENV_KEY)
if err != nil {
panic(err)
}
productionURL, err := env.GetString("PRODUCTION_API_URL")
if err != nil {
panic(err)
}
token, err := env.GetString("SESSION_SECRET")
if err != nil {
panic(err)
}
city, err := env.GetString("CITY_ID")
if err != nil {
panic(err)
}
spot, err := env.GetString("SPOT_ID")
if err != nil {
panic(err)
}
*ctx = context.WithValue(*ctx, ProjectIdKey, projectId)
*ctx = context.WithValue(*ctx, BucketNameKey, bucketName)
*ctx = context.WithValue(*ctx, SubFolderPathKey, subFolderPath)
*ctx = context.WithValue(*ctx, CountryVersionId, countryVersion)
*ctx = context.WithValue(*ctx, CategoryId, category)
*ctx = context.WithValue(*ctx, GeoCode, value)
*ctx = context.WithValue(*ctx, DbUri, databaseURL)
*ctx = context.WithValue(*ctx, ProductionApiUrl, productionURL)
*ctx = context.WithValue(*ctx, SessionSecret, token)
*ctx = context.WithValue(*ctx, CityId, city)
*ctx = context.WithValue(*ctx, SpotId, spot)
}