-
Notifications
You must be signed in to change notification settings - Fork 53
/
config.go
111 lines (92 loc) · 1.72 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package config
import (
"io/ioutil"
"log"
"github.com/k0kubun/pp"
"gopkg.in/yaml.v2"
)
type maintainer struct {
Name string
Email string
}
type grpc struct {
Host string
Port int
}
type graphql struct {
Enabled bool
Port int
}
type http struct {
Enabled bool
Port int
}
type web struct {
Enabled bool
Port int
}
type network struct {
Grpc grpc
Http http
Web web
Graphql graphql
}
type Service struct {
Name string
Description string
Language string
GitRepo string `yaml:"gitRepo"`
DockerRepo string `yaml:"dockerRepo"`
Network network
CI CI
}
type CI struct {
System string
Language string
BuildImage string `yaml:"buildImage"`
BuildTag string `yaml:"buildTag"`
BuildCommand string `yaml:"buildCommand"`
TestCommand string `yaml:"testCommand"`
}
type Commit0Config struct {
Organization string
Name string
Description string
Maintainers []maintainer
Services []Service
Frontend frontend
Infrastructure infrastructure
}
type infrastructure struct {
AWS aws
}
type aws struct {
AccountId string `yaml:"accountId"`
Region string
EKS eks
Cognito bool
Terraform terraform
}
type terraform struct {
RemoteState bool
}
type eks struct {
ClusterName string `yaml:"clusterName"`
WorkerAMI string `yaml:"workerAMI"`
Deploy bool
}
func LoadConfig(filePath string) *Commit0Config {
config := &Commit0Config{}
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 *Commit0Config) Print() {
pp.Println(c)
}