forked from jbdalido/gomarathon
-
Notifications
You must be signed in to change notification settings - Fork 3
/
types.go
192 lines (172 loc) · 7.18 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
package gomarathon
// RequestOptions passed for query api
type RequestOptions struct {
Method string
Path string
Datas interface{}
Params *Parameters
}
// Parameters to build url query
type Parameters struct {
Cmd string
Host string
Scale bool
CallbackURL string
Embed string
Label string
Force bool
}
// Response representation of a full marathon response
type Response struct {
Code int
Apps []*Application `json:"apps,omitempty"`
App *Application `json:"app,omitempty"`
Versions []string `json:",omitempty"`
Tasks []*Task `json:"tasks,omitempty"`
DeploymentId string `json:"deployment_id,omitempty"`
Version string `json:"version,omitempty"`
}
// Application marathon application see :
// https://github.com/mesosphere/marathon/blob/master/REST.md#apps
type Application struct {
ID string `json:"id"`
Cmd string `json:"cmd,omitempty"`
Constraints [][]string `json:"constraints,omitempty"`
Container *Container `json:"container,omitempty"`
CPUs float32 `json:"cpus,omitempty"`
Dependencies []string `json:"dependencies,omitempty"`
Deployments []*Deployment `json:"deployments,omitempty"`
Env map[string]string `json:"env,omitempty"`
Executor string `json:"executor,omitempty"`
HealthChecks []*HealthCheck `json:"healthChecks,omitempty"`
Instances int `json:"instances,omitemptys"`
Mem float32 `json:"mem,omitempty"`
Tasks []*Task `json:"tasks,omitempty"`
Ports []int `json:"ports,omitempty"`
RequirePorts bool `json:"requirePorts,omitempty"`
BackoffSeconds int `json:"backoffSeconds,omitempty"`
BackoffFactor float32 `json:"backoffFactor,omitempty"`
MaxLaunchDelaySeconds float32 `json:"maxLaunchDelaySeconds,omitempty"`
TasksHealthy int `json:"tasksHealthy,omitempty"`
TasksUnhealthy int `json:"tasksUnhealthy,omitempty"`
TasksRunning int `json:"tasksRunning,omitempty"`
TasksStaged int `json:"tasksStaged,omitempty"`
UpgradeStrategy *UpgradeStrategy `json:"upgradeStrategy,omitempty"`
Uris []string `json:"uris,omitempty"`
Version string `json:"version,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
TaskStats *TaskStats `json:"taskStats,omitempty"`
}
type TaskStats struct {
StartedAfterLastScaling *TaskStatWrapper `json:"startedAfterLastScaling"`
WithLatestConfig *TaskStatWrapper `json:"withLatestConfig"`
totalSummary *TaskStatWrapper `json:"totalSummary"`
}
type TaskStatWrapper struct {
Stats *TaskStat `json:"stats"`
}
type TaskStat struct {
Counts *TaskCounts `json:"counts"`
LifeTime *TaskLifetime `json:"lifeTime"`
}
type TaskCounts struct {
Staged int `json:"staged"`
Running int `json:"running"`
Healthy int `json:"healthy"`
Unhealthy int `json:"unhealthy"`
}
type TaskLifetime struct {
AverageSeconds float32 `json:"averageSeconds"`
MedianSeconds float32 `json:"medianSeconds"`
}
// Container is docker parameters
type Container struct {
Type string `json:"type,omitempty"`
Docker *Docker `json:"docker,omitempty"`
Volumes []*Volume `json:"volumes,omitempty"`
}
// Docker options
type Docker struct {
Image string `json:"image,omitempty"`
Network string `json:"network,omitempty"`
PortMappings []*PortMapping `json:"portMappings,omitempty"`
Privileged bool `json:"privileged`
Parameters []*DockerParam `json:"parameters,omitempty"`
}
type DockerParam struct {
Key string `json:"key"`
Value string `json:"value"`
}
// Volume is used for mounting a host directory as a container volume
type Volume struct {
ContainerPath string `json:"containerPath,omitempty"`
HostPath string `json:"hostPath,omitempty"`
Mode string `json:"mode,omitempty"`
}
// Container PortMappings
type PortMapping struct {
ContainerPort int `json:"containerPort,omitempty"`
HostPort int `json:"hostPort,omitempty"`
ServicePort int `json:"servicePort,omitempty"`
Protocol string `json:"protocol,omitempty"`
}
// UpgradeStrategy has a minimumHealthCapacity which defines the minimum number of healty nodes
type UpgradeStrategy struct {
MinimumHealthCapacity float32 `json:"minimumHealthCapacity,omitempty"`
}
// HealthCheck is described here:
// https://github.com/mesosphere/marathon/blob/master/REST.md#healthchecks
type HealthCheck struct {
Protocol string `json:"protocol,omitempty"`
Path string `json:"path,omitempty"`
GracePeriodSeconds int `json:"gracePeriodSeconds,omitempty"`
IntervalSeconds int `json:"intervalSeconds,omitempty"`
PortIndex int `json:"portIndex,omitempty"`
TimeoutSeconds int `json:"timeoutSeconds,omitempty"`
MaxConsecutiveFailures int `json:"maxConsecutiveFailures"`
}
type HealthCheckResult struct {
Alive bool `json:"alive,omitempty"`
ConsecutiveFailures int `json:"consecutiveFailures,omitempty"`
FirstSuccess string `json:"firstSuccess,omitempty"`
LastFailure string `json:"lastFailure,omitempty"`
LastSuccess string `json:"lastSuccess,omitempty"`
TaskID string `json:"taskId,omitempty"`
}
// Task is described here:
// https://github.com/mesosphere/marathon/blob/master/REST.md#tasks
type Task struct {
AppID string `json:"appId"`
Host string `json:"host"`
SlaveID string `json:"slaveId"`
ID string `json:"id"`
Ports []int `json:"ports"`
StagedAt string `json:"stagedAt"`
StartedAt string `json:"startedAt"`
Version string `json:"version"`
HealthCheckResults []*HealthCheckResult `json:"healthCheckResults"`
}
// Deployment is described here:
// https://mesosphere.github.io/marathon/docs/rest-api.html#get-/v2/deployments
type Deployment struct {
AffectedApps []string `json:"affectedApps"`
ID string `json:"id"`
Steps []*DeploymentStep `json:"steps"`
CurrentActions []*DeploymentStep `json:"currentActions"`
CurrentStep int `json:"currentStep"`
TotalSteps int `json:"totalSteps"`
Version string `json:"version"`
}
// Deployment steps
type DeploymentStep struct {
Action string `json:"action"`
App string `json:"app"`
}
// EventSubscription is described here:
// https://github.com/mesosphere/marathon/blob/master/REST.md#event-subscriptions
type EventSubscription struct {
CallbackURL string `json:"CallbackUrl"`
ClientIP string `json:"ClientIp"`
EventType string `json:"eventType"`
CallbackURLs []string `json:"CallbackUrls"`
}