-
Notifications
You must be signed in to change notification settings - Fork 2
/
config.go
64 lines (53 loc) · 950 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package gobearmon
import "gopkg.in/gcfg.v1"
import "log"
type DefaultConfig struct {
Debug bool
Password string
}
type ControllerConfig struct {
Addr string
Database []string
Confirmations int
}
type WorkerConfig struct {
ViewAddr string
NumThreads int
}
type SmtpConfig struct {
Host string
Port int
From string
Username string
Password string
Admin string
}
type DNSConfig struct {
Server string
}
type TwilioConfig struct {
AccountSid string
AuthToken string
From string
}
type ViewServerConfig struct {
Addr string
Controller []string
}
type Config struct {
Default DefaultConfig
Controller ControllerConfig
Worker WorkerConfig
Smtp SmtpConfig
DNS DNSConfig
Twilio TwilioConfig
ViewServer ViewServerConfig
}
func LoadConfig(cfgPath string) *Config {
var cfg Config
err := gcfg.ReadFileInto(&cfg, cfgPath)
if err != nil {
log.Fatalf("Error while reading configuration: %s", err.Error())
}
return &cfg
}