-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
58 lines (50 loc) · 1.28 KB
/
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
package main
import (
"io/ioutil"
"path/filepath"
"gopkg.in/yaml.v2"
)
var config Config
type Remote struct {
Name string `yaml:"name"`
Endpoint string `yaml:"endpoint"`
AccessKey string `yaml:"accessKey"`
SecretKey string `yaml:"secretKey"`
}
type Inbound struct {
Name string `yaml:"name"`
Description string `yaml:"description"`
Source string `yaml:"source"`
Exchange string `yaml:"exchange"`
Queue string `yaml:"queue"`
Remote string `yaml:"remote"`
Destination string `yaml:"destination"`
}
type Outbound struct {
Name string `yaml:"name"`
Description string `yaml:"description"`
Sensitive bool `yaml:"sensitive"`
Source string `yaml:"source"`
Destination string `yaml:"destination"`
ProcessWith string `yaml:"process_with,omitempty"`
}
type Config struct {
LogLevel string `yaml:"log_level"`
LogJSON bool `yaml:"log_json"`
Outbound []Outbound `yaml:"outbound"`
Inbound []Inbound `yaml:"inbound"`
Remotes []Remote `yaml:"remotes"`
}
func readConfig(filename string) error {
// Read YAML config file
fullpath, _ := filepath.Abs(filename)
yamlFile, err := ioutil.ReadFile(fullpath)
if err != nil {
return err
}
err = yaml.Unmarshal(yamlFile, &config)
if err != nil {
return err
}
return nil
}