forked from cloudfoundry/bosh-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
interfaces.go
239 lines (180 loc) · 5.11 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
package director
import (
"io"
"os"
"time"
semver "github.com/cppforlife/go-semi-semantic/version"
)
//go:generate counterfeiter . Director
type Director interface {
IsAuthenticated() (bool, error)
Info() (Info, error)
Locks() ([]Lock, error)
CurrentTasks(TasksFilter) ([]Task, error)
RecentTasks(int, TasksFilter) ([]Task, error)
FindTask(int) (Task, error)
Events(EventsFilter) ([]Event, error)
Deployments() ([]Deployment, error)
FindDeployment(string) (Deployment, error)
Releases() ([]Release, error)
HasRelease(name, version string) (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)
FindStemcell(StemcellSlug) (Stemcell, error)
UploadStemcellURL(url, sha1 string, fix bool) error
UploadStemcellFile(file UploadFile, fix bool) error
LatestCloudConfig() (CloudConfig, error)
UpdateCloudConfig([]byte) error
LatestRuntimeConfig() (RuntimeConfig, error)
UpdateRuntimeConfig([]byte) error
FindOrphanedDisk(string) (OrphanedDisk, error)
OrphanedDisks() ([]OrphanedDisk, error)
EnableResurrection(bool) error
CleanUp(bool) error
DownloadResourceUnchecked(blobstoreID string, out io.Writer) error
}
type UploadFile interface {
io.ReadCloser
Stat() (os.FileInfo, error)
}
//go:generate counterfeiter . ReleaseArchive
type ReleaseArchive interface {
Info() (string, string, error)
File() (UploadFile, error)
}
//go:generate counterfeiter . StemcellArchive
type StemcellArchive interface {
Info() (string, string, error)
File() (UploadFile, error)
}
//go:generate counterfeiter . FileReporter
type FileReporter interface {
TrackUpload(int64, io.ReadCloser) io.ReadCloser
TrackDownload(int64, io.Writer) io.Writer
}
//go:generate counterfeiter . Deployment
type Deployment interface {
Name() string
Manifest() (string, error)
CloudConfig() (string, error)
Diff([]byte, bool) (DiffLines, error)
Releases() ([]Release, error)
ExportRelease(ReleaseSlug, OSVersionSlug) (ExportReleaseResult, error)
Stemcells() ([]Stemcell, error)
VMInfos() ([]VMInfo, error)
InstanceInfos() ([]VMInfo, error)
Errands() ([]Errand, error)
RunErrand(string, bool) (ErrandResult, error)
ScanForProblems() ([]Problem, error)
ResolveProblems([]ProblemAnswer) error
Snapshots() ([]Snapshot, error)
TakeSnapshots() error
DeleteSnapshot(string) error
DeleteSnapshots() error
// Deployment, pool or instance specifics
Start(slug AllOrPoolOrInstanceSlug) error
Stop(slug AllOrPoolOrInstanceSlug, hard bool, sd SkipDrain, force bool) error
Restart(slug AllOrPoolOrInstanceSlug, sd SkipDrain, force bool) error
Recreate(slug AllOrPoolOrInstanceSlug, sd SkipDrain, force bool) error
SetUpSSH(AllOrPoolOrInstanceSlug, SSHOpts) (SSHResult, error)
CleanUpSSH(AllOrPoolOrInstanceSlug, SSHOpts) error
// Instance specifics
FetchLogs(InstanceSlug, []string, bool) (LogsResult, error)
TakeSnapshot(InstanceSlug) error
EnableResurrection(InstanceSlug, bool) error
Update(manifest []byte, opts UpdateOpts) error
Delete(force bool) error
}
type UpdateOpts struct {
Recreate bool
Fix bool
SkipDrain SkipDrain
}
//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
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
Description() string
Result() string
EventOutput(TaskReporter) error
CPIOutput(TaskReporter) error
DebugOutput(TaskReporter) error
ResultOutput(TaskReporter) error
RawOutput(TaskReporter) error
Cancel() error
}
//go:generate counterfeiter . TaskReporter
type TaskReporter interface {
TaskStarted(int)
TaskFinished(int, string)
TaskOutputChunk(int, []byte)
}
//go:generate counterfeiter . OrphanedDisk
type OrphanedDisk interface {
CID() string
Size() uint64
Deployment() Deployment
InstanceName() string
AZName() string
OrphanedAt() time.Time
Delete() error
}
type EventsFilter struct {
BeforeID string
Before string
After string
Deployment string
Task string
Instance 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{}
}