-
Notifications
You must be signed in to change notification settings - Fork 1
/
types.go
104 lines (88 loc) · 2.54 KB
/
types.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
package config
type Config struct {
Setup Setup `yaml:"setup,omitempty"`
Slack Slack `yaml:"slack,omitempty"`
Hosts []Host `yaml:"hosts,omitempty"`
}
func (c Config) IsDockerEnabled() bool {
return c.Setup.Docker != nil
}
func (c Config) IsNetdataEnabled() (flag bool, version string, port int) {
if !(c.Setup.Docker != nil && c.Setup.Docker.Netdata != nil) {
return false, "", 0
}
if c.Setup.Docker.Netdata.Version == "" {
version = "latest"
} else {
version = c.Setup.Docker.Netdata.Version
}
if c.Setup.Docker.Netdata.PublicPort == 0 {
port = 19999
} else {
port = c.Setup.Docker.Netdata.PublicPort
}
return true, version, port
}
func (c Config) IsAlpEnabled() (flag bool, version string) {
if !(c.Setup.Alp != nil) {
return false, ""
}
if c.Setup.Alp.Version == "" {
version = "latest"
} else {
version = c.Setup.Alp.Version
}
return true, version
}
type Setup struct {
Docker *Docker `yaml:"docker,omitempty"`
Alp *Alp `yaml:"alp,omitempty"`
}
type Docker struct {
Netdata *Netdata `yaml:"netdata,omitempty"`
}
type Netdata struct {
Version string `yaml:"version,omitempty"`
PublicPort int `yaml:"public_port,omitempty"`
}
type Alp struct {
Version string `yaml:"version,omitempty"`
}
type Slack struct {
DefaultChannelId string `yaml:"default_channel_id,omitempty"`
}
type Host struct {
Host string `yaml:"host,omitempty"`
Port int `yaml:"int,omitempty"`
User string `yaml:"user,omitempty"`
Key string `yaml:"key,omitempty"`
Password string `yaml:"password,omitempty"`
Deploy Deploy `yaml:"deploy,omitempty"`
Profiling Profiling `yaml:"profiling,omitempty"`
AfterBench AfterBench `yaml:"after_bench,omitempty"`
}
func (c Host) IsLocal() bool {
return c.Host == "localhost" || c.Host == "127.0.0.1"
}
func (c Host) ListTarget() []DeployTarget {
return c.Deploy.Targets
}
type Deploy struct {
SlackChannelId string `yaml:"slack_channel_id,omitempty"`
PreCommand string `yaml:"pre_command,omitempty"`
PostCommand string `yaml:"post_command,omitempty"`
Targets []DeployTarget `yaml:"targets,omitempty"`
}
type DeployTarget struct {
Src string `yaml:"src,omitempty"`
Target string `yaml:"target,omitempty"`
Compile string `yaml:"compile,omitempty"`
}
type Profiling struct {
Command string `yaml:"command,omitempty"`
}
type AfterBench struct {
SlackChannelId string `yaml:"slack_channel_id,omitempty"`
Target string `yaml:"target,omitempty"`
Command string `yaml:"command,omitempty"`
}