-
Notifications
You must be signed in to change notification settings - Fork 52
/
config.go
84 lines (69 loc) · 1.43 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
package config
import (
"io/ioutil"
"log"
"github.com/k0kubun/pp"
"gopkg.in/yaml.v2"
)
type Maintainers 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
}
type Commit0Config struct {
Language string `yaml:"string"`
Organization string `yaml:"organization"`
Name string `yaml:"name"`
Description string `yaml:"description"`
GitRepo string `yaml:"git-repo"`
DockerRepo string `yaml:"docker-repo"`
Maintainers []Maintainers `yaml:"maintainers"`
Network Network `yaml:"network"`
Services []Service `yaml:"services"`
React React `yaml:"react"`
Kubernetes Kubernetes `yaml:"kubernetes"`
}
type Kubernetes struct {
ClusterName string
DNSName string
}
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)
}