-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
50 lines (41 loc) · 1.03 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
package shutter
import (
"gopkg.in/yaml.v2"
"io/ioutil"
"time"
)
type Config struct {
AwsRegion string `yaml:"aws_region"`
Watcher Watcher `yaml:"watcher"`
Finisher Finisher `yaml:"finisher"`
}
type Watcher struct {
AutoscalingGroupName string `yaml:"autoscaling_group_name"`
IntervalSec time.Duration `yaml:"interval_sec"`
}
type Finisher struct {
LifecycleHookName string `yaml:"lifecycle_hook_name"`
LifecycleActionResult string `yaml:"lifecycle_action_result"`
Terminate Terminate `yaml:"terminate"`
Wait Wait `yaml:"wait"`
}
type Terminate struct {
Command string `yaml:"command"`
}
type Wait struct {
Command string `yaml:"command"`
IntervalSec time.Duration `yaml:"interval_sec"`
MaxTries int64 `yaml:"max_tries"`
}
func NewConfig(name string) (*Config, error) {
d, err := ioutil.ReadFile(name)
if err != nil {
return nil, err
}
c := &Config{}
err = yaml.Unmarshal(d, &c)
if err != nil {
return nil, err
}
return c, nil
}