-
Notifications
You must be signed in to change notification settings - Fork 52
/
project_config.go
49 lines (40 loc) · 940 Bytes
/
project_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 projectconfig
import (
"io/ioutil"
"log"
"github.com/k0kubun/pp"
yaml "gopkg.in/yaml.v2"
)
type ZeroProjectConfig struct {
Name string
ShouldPushRepositories bool
Infrastructure Infrastructure // TODO simplify and flatten / rename?
Parameters map[string]string
Modules []string
}
type Infrastructure struct {
AWS *AWS
}
type AWS struct {
AccountID string `yaml:"accountId"`
Region string
Terraform terraform // TODO simplify and flatten?
}
type terraform struct {
RemoteState bool
}
func LoadConfig(filePath string) *ZeroProjectConfig {
config := &ZeroProjectConfig{}
data, err := ioutil.ReadFile(filePath)
if err != nil {
log.Panicf("failed to read config: %v", err)
}
err = yaml.Unmarshal(data, &config)
if err != nil {
log.Panicf("failed to parse config: %v", err)
}
return config
}
func (c *ZeroProjectConfig) Print() {
pp.Println(c)
}