-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
45 lines (36 loc) · 827 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
package main
import (
"io/ioutil"
"time"
yaml "gopkg.in/yaml.v2"
)
type Config struct {
Targets []Target `yaml:"targets"`
LookbackDelta time.Duration `yaml:"lookbackDelta"`
}
type Target struct {
Index IndexConfig `yaml:"index"`
Archive ArchiveConfig `yaml:"archive"`
}
type IndexConfig struct {
Region []string `yaml:"region"`
Namespace []string `yaml:"namespace"`
Retention string `yaml:"retention"`
}
type ArchiveConfig struct {
Region []string `yaml:"region"`
Namespace []string `yaml:"namespace"`
Retention string `yaml:"retention"`
}
func LoadConfig(configFile string) (*Config, error) {
buf, err := ioutil.ReadFile(configFile)
if err != nil {
return nil, err
}
var cfg Config
err = yaml.Unmarshal(buf, &cfg)
if err != nil {
return nil, err
}
return &cfg, nil
}