-
Notifications
You must be signed in to change notification settings - Fork 162
/
interfaces.go
351 lines (274 loc) · 8.16 KB
/
interfaces.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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
package director
import (
"io"
"os"
"time"
"github.com/cloudfoundry/bosh-cli/ui"
semver "github.com/cppforlife/go-semi-semantic/version"
)
//go:generate counterfeiter . Director
type Director interface {
IsAuthenticated() (bool, error)
WithContext(id string) Director
Info() (Info, error)
Locks() ([]Lock, error)
CurrentTasks(TasksFilter) ([]Task, error)
RecentTasks(int, TasksFilter) ([]Task, error)
FindTask(int) (Task, error)
FindTasksByContextId(string) ([]Task, error)
Events(EventsFilter) ([]Event, error)
Event(string) (Event, error)
Deployments() ([]Deployment, error)
FindDeployment(string) (Deployment, error)
ListDeployments() ([]DeploymentResp, error)
ListDeploymentConfigs(name string) (DeploymentConfigs, error)
Releases() ([]Release, error)
HasRelease(name, version string, stemcell OSVersionSlug) (bool, error)
FindRelease(ReleaseSlug) (Release, error)
FindReleaseSeries(ReleaseSeriesSlug) (ReleaseSeries, error)
UploadReleaseURL(url, sha1 string, rebase, fix bool) error
UploadReleaseFile(file UploadFile, rebase, fix bool) error
MatchPackages(manifest interface{}, compiled bool) ([]string, error)
Stemcells() ([]Stemcell, error)
HasStemcell(name, version string) (bool, error)
StemcellNeedsUpload(StemcellInfo) (bool, bool, error)
FindStemcell(StemcellSlug) (Stemcell, error)
UploadStemcellURL(url, sha1 string, fix bool) error
UploadStemcellFile(file UploadFile, fix bool) error
LatestConfig(configType string, name string) (Config, error)
LatestConfigByID(configID string) (Config, error)
ListConfigs(limit int, filter ConfigsFilter) ([]Config, error)
UpdateConfig(configType string, name string, expectedLatestId string, content []byte) (Config, error)
DeleteConfig(configType string, name string) (bool, error)
DeleteConfigByID(configID string) (bool, error)
DiffConfig(configType string, name string, manifest []byte) (ConfigDiff, error)
DiffConfigByIDOrContent(fromID string, fromContent []byte, toID string, toContent []byte) (ConfigDiff, error)
LatestCloudConfig() (CloudConfig, error)
UpdateCloudConfig([]byte) error
DiffCloudConfig(manifest []byte) (ConfigDiff, error)
LatestCPIConfig() (CPIConfig, error)
UpdateCPIConfig([]byte) error
DiffCPIConfig(manifest []byte, noRedact bool) (ConfigDiff, error)
LatestRuntimeConfig(name string) (RuntimeConfig, error)
UpdateRuntimeConfig(name string, manifest []byte) error
DiffRuntimeConfig(name string, manifest []byte, noRedact bool) (ConfigDiff, error)
FindOrphanDisk(string) (OrphanDisk, error)
OrphanDisks() ([]OrphanDisk, error)
OrphanDisk(string) error
FindOrphanNetwork(string) (OrphanNetwork, error)
OrphanNetworks() ([]OrphanNetwork, error)
EnableResurrection(bool) error
CleanUp(bool) error
DownloadResourceUnchecked(blobstoreID string, out io.Writer) error
OrphanedVMs() ([]OrphanedVM, error)
}
var _ Director = &DirectorImpl{}
type UploadFile interface {
io.ReadCloser
Stat() (os.FileInfo, error)
}
type ReleaseMetadata struct {
Name string `yaml:"name"`
Version string `yaml:"version"`
// other fields ignored
}
//go:generate counterfeiter . ReleaseArchive
type ReleaseArchive interface {
Info() (ReleaseMetadata, error)
File() (UploadFile, error)
}
type StemcellMetadata struct {
Name string `yaml:"name"`
OS string `yaml:"operating_system"`
Version string `yaml:"version"`
// other fields ignored
}
//go:generate counterfeiter . StemcellArchive
type StemcellArchive interface {
Info() (StemcellMetadata, error)
File() (UploadFile, error)
}
//go:generate counterfeiter . FileReporter
type FileReporter interface {
TrackUpload(int64, io.ReadCloser) ui.ReadSeekCloser
TrackDownload(int64, io.Writer) io.Writer
}
//go:generate counterfeiter . Deployment
type Deployment interface {
Name() string
Manifest() (string, error)
CloudConfig() (string, error)
Diff([]byte, bool) (DeploymentDiff, error)
Releases() ([]Release, error)
ExportRelease(ReleaseSlug, OSVersionSlug, []string) (ExportReleaseResult, error)
Teams() ([]string, error)
Stemcells() ([]Stemcell, error)
VMInfos() ([]VMInfo, error)
Instances() ([]Instance, error)
InstanceInfos() ([]VMInfo, error)
Errands() ([]Errand, error)
RunErrand(string, bool, bool, []InstanceGroupOrInstanceSlug) ([]ErrandResult, error)
ScanForProblems() ([]Problem, error)
ResolveProblems([]ProblemAnswer) error
Snapshots() ([]Snapshot, error)
TakeSnapshots() error
DeleteSnapshot(string) error
DeleteSnapshots() error
DeleteVM(string) error
Variables() ([]VariableResult, error)
// Deployment, pool or instance specifics
Start(slug AllOrInstanceGroupOrInstanceSlug, opts StartOpts) error
Stop(slug AllOrInstanceGroupOrInstanceSlug, opts StopOpts) error
Restart(slug AllOrInstanceGroupOrInstanceSlug, opts RestartOpts) error
Recreate(slug AllOrInstanceGroupOrInstanceSlug, opts RecreateOpts) error
SetUpSSH(AllOrInstanceGroupOrInstanceSlug, SSHOpts) (SSHResult, error)
CleanUpSSH(AllOrInstanceGroupOrInstanceSlug, SSHOpts) error
// Instance specifics
FetchLogs(AllOrInstanceGroupOrInstanceSlug, []string, bool) (LogsResult, error)
TakeSnapshot(InstanceSlug) error
Ignore(InstanceSlug, bool) error
EnableResurrection(InstanceSlug, bool) error
Update(manifest []byte, opts UpdateOpts) error
Delete(force bool) error
AttachDisk(slug InstanceSlug, diskCID string, diskProperties string) error
}
type StartOpts struct {
Canaries string
MaxInFlight string
}
type StopOpts struct {
Canaries string
MaxInFlight string
Force bool
SkipDrain bool
Hard bool
}
type RestartOpts struct {
Canaries string
MaxInFlight string
Force bool
SkipDrain bool
}
type RecreateOpts struct {
Canaries string
MaxInFlight string
Force bool
Fix bool
SkipDrain bool
DryRun bool
}
type UpdateOpts struct {
Recreate bool
RecreatePersistentDisks bool
Fix bool
SkipDrain SkipDrains
Canaries string
MaxInFlight string
DryRun bool
Diff DeploymentDiff
}
//go:generate counterfeiter . ReleaseSeries
type ReleaseSeries interface {
Name() string
Delete(force bool) error
}
//go:generate counterfeiter . Release
type Release interface {
Name() string
Version() semver.Version
VersionMark(mark string) string
CommitHashWithMark(mark string) string
Jobs() ([]Job, error)
Packages() ([]Package, error)
Delete(force bool) error
}
//go:generate counterfeiter . Stemcell
type Stemcell interface {
Name() string
Version() semver.Version
VersionMark(mark string) string
OSName() string
CPI() string
CID() string
Delete(force bool) error
}
type TasksFilter struct {
All bool
Deployment string
}
type Task interface {
ID() int
StartedAt() time.Time
LastActivityAt() time.Time
State() string
IsError() bool
User() string
DeploymentName() string
ContextID() string
Description() string
Result() string
EventOutput(TaskReporter) error
CPIOutput(TaskReporter) error
DebugOutput(TaskReporter) error
ResultOutput(TaskReporter) error
Cancel() error
}
//go:generate counterfeiter . TaskReporter
type TaskReporter interface {
TaskStarted(int)
TaskFinished(int, string)
TaskOutputChunk(int, []byte)
}
//go:generate counterfeiter . OrphanDisk
type OrphanDisk interface {
CID() string
Size() uint64
Deployment() Deployment
InstanceName() string
AZName() string
OrphanedAt() time.Time
Delete() error
}
//go:generate counterfeiter . OrphanNetwork
type OrphanNetwork interface {
Name() string
Type() string
OrphanedAt() time.Time
CreatedAt() time.Time
Delete() error
}
type OrphanedVM struct {
CID string
DeploymentName string
InstanceName string
AZName string
IPAddresses []string
OrphanedAt time.Time
}
type EventsFilter struct {
BeforeID string
Before string
After string
Deployment string
Task string
Instance string
User string
Action string
ObjectType string
ObjectName string
}
//go:generate counterfeiter . Event
type Event interface {
ID() string
ParentID() string
Timestamp() time.Time
User() string
Action() string
ObjectType() string
ObjectName() string
TaskID() string
DeploymentName() string
Instance() string
Context() map[string]interface{}
Error() string
}