-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapi.go
More file actions
46 lines (39 loc) · 950 Bytes
/
api.go
File metadata and controls
46 lines (39 loc) · 950 Bytes
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
package config
import (
"log"
"os"
"github.com/USACE/instrumentation-api/api/internal/tz"
)
// Config stores configuration information stored in environment variables
type ApiConfig struct {
BuildTag string
DBConfig
AWSS3Config
AWSSQSConfig
ServerConfig
}
// GetConfig returns environment variable config
func NewApiConfig() *ApiConfig {
var cfg ApiConfig
cfg.BuildTag = os.Getenv("BUILD_TAG")
if err := parsePrefix("INSTRUMENTATION_", &cfg); err != nil {
log.Fatal(err.Error())
}
switch cfg.BuildTag {
case "local":
cfg.ServerBaseUrl = "http://localhost:8080"
case "dev":
cfg.ServerBaseUrl = "https://develop-midas-api.rsgis.dev"
case "test":
cfg.ServerBaseUrl = "https://midas-test.cwbi.us/api"
case "prod":
cfg.ServerBaseUrl = "https://midas.sec.usace.army.mil/api"
default:
}
zz, err := tz.ListTimezones("/usr/share/zoneinfo/")
if err != nil {
log.Fatal(err)
}
cfg.AvailableTimezones = zz
return &cfg
}