-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig.go
49 lines (44 loc) · 986 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
package main
import (
"encoding/json"
"io/ioutil"
"os"
)
const (
DEFAULT_QUEUE_ADDR = "0.0.0.0:11300"
DEFAULT_FROM_EMAIL = "[email protected]"
)
type Configuration struct {
QueueAddr string
SmtpServer string
MailFrom string
depsPath string
deps map[string][]string
errorQueue string
}
func NewConfig(deps, smtpserver, mailfrom string) *Configuration {
config := new(Configuration)
config.QueueAddr = os.Getenv("GLOW_QUEUE")
if config.QueueAddr == "" {
config.QueueAddr = DEFAULT_QUEUE_ADDR
}
config.SmtpServer = smtpserver
config.MailFrom = mailfrom
config.depsPath = deps
if config.MailFrom == "" {
config.MailFrom = DEFAULT_FROM_EMAIL
}
config.errorQueue = "GLOW_ERRORS"
return config
}
func (this *Configuration) LoadDeps() error {
if *deps == "" {
return nil
}
this.deps = make(map[string][]string)
dependencies, err := ioutil.ReadFile(this.depsPath)
if err != nil {
return err
}
return json.Unmarshal(dependencies, &this.deps)
}