/
root.go
81 lines (68 loc) · 1.07 KB
/
root.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
package config
import (
"io/ioutil"
"gopkg.in/yaml.v2"
)
func Read(p string) (Root, error) {
b, err := ioutil.ReadFile(p)
if err != nil {
return Root{}, err
}
var cfg Root
if err := yaml.Unmarshal(b, &cfg); err != nil {
return Root{}, err
}
return cfg, nil
}
// Root is top level config.
type Root struct {
Data Data
Contexts []Context
Score Score
Parameters []Parameter
Containers []Container
}
type Data struct {
DB string `yaml:"db"`
Dir string
}
type Context struct {
Name string
Image string
}
type Score struct {
Command Command
Timeout string
Capture string // The regex that capture the score
}
type Command struct {
Shell string
Dir string
Envs []Env
}
type Parameter struct {
Name string
Default int
}
type Container struct {
Name string
Abstract bool
Extends string
Image string
Resource Resource
Envs []Env
Mounts []Mount
}
type Resource struct {
CPU int
RAM string
}
type Env struct {
Key string
Value string
}
// TODO: only bind mount is supported
type Mount struct {
Src string
Dst string
}