-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.go
More file actions
36 lines (29 loc) · 764 Bytes
/
config.go
File metadata and controls
36 lines (29 loc) · 764 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
package main
import (
"io/ioutil"
"log"
"github.com/davecgh/go-spew/spew"
yaml "gopkg.in/yaml.v2"
)
// Events in the .yaml are events to be forwarded, and what SIA code to apply
type Config struct {
Account string `yaml:"account"`
Zone string `yaml:"zone"`
Events []SiaEvent `yaml:"events"`
}
type SiaEvent struct {
EventType string `yaml:"eventType"`
EventState string `yaml:"eventState"`
SiaCode string `yaml:"siaCode"`
}
func LoadConfig() *Config {
fileName := "config.yaml"
var c Config
data, err := ioutil.ReadFile(fileName)
failOnError(err, "error reading "+fileName)
err = yaml.Unmarshal(data, &c)
failOnError(err, "error unmarshalling "+fileName)
log.Println("Config loaded: " + fileName)
spew.Dump(c)
return &c
}