-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
42 lines (35 loc) · 980 Bytes
/
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
package dockertest
import (
"time"
"gopkg.in/yaml.v2"
)
type YamlConfig struct {
Version string `yaml:"version"`
Services map[string]*ImageCfg `yaml:"services"`
}
type ImageCfg struct {
Image string `yaml:"image"`
Ports []string `yaml:"ports"`
Environment []string `yaml:"environment"`
Command []string `yaml:"command"`
Volumes []string `yaml:"volumes"`
HealthCheck *HealthyCheck `yaml:"healthcheck"`
Hooks []*Hooks `yaml:"hooks"`
}
type HealthyCheck struct {
Test []string `yaml:"test"`
Interval time.Duration `yaml:"interval"`
Timeout time.Duration `yaml:"timeout"`
Retries int `yaml:"retries"`
}
type Hooks struct {
// 通过exec执行容器命令
Cmd []string `yaml:"cmd"`
// 使用自定义命令
Custom string `yaml:"custom"`
}
func DecodeConfig(text []byte) (cfg *YamlConfig, err error) {
cfg = &YamlConfig{}
err = yaml.Unmarshal(text, cfg)
return
}