forked from docker/libcompose
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nop.go
376 lines (301 loc) · 16.2 KB
/
nop.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
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
package test
import (
"errors"
"io"
"time"
"golang.org/x/net/context"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/events"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/api/types/registry"
"github.com/docker/docker/client"
)
var (
errNoEngine = errors.New("Engine no longer exists")
// Make sure NopClient implements ContainerAPIclient and other required interface
_ client.ContainerAPIClient = (*NopClient)(nil)
_ client.ImageAPIClient = (*NopClient)(nil)
_ client.NetworkAPIClient = (*NopClient)(nil)
_ client.VolumeAPIClient = (*NopClient)(nil)
_ client.SystemAPIClient = (*NopClient)(nil)
)
// NopClient is a nop API Client based on engine-api
type NopClient struct {
}
// NewNopClient creates a new nop client
func NewNopClient() *NopClient {
return &NopClient{}
}
// ClientVersion returns the version string associated with this instance of the Client
func (client *NopClient) ClientVersion() string {
return ""
}
// CheckpointCreate creates a checkpoint from the given container with the given name
func (client *NopClient) CheckpointCreate(ctx context.Context, container string, options types.CheckpointCreateOptions) error {
return errNoEngine
}
// CheckpointDelete deletes the checkpoint with the given name from the given container
func (client *NopClient) CheckpointDelete(ctx context.Context, container string, checkpointID string) error {
return errNoEngine
}
// CheckpointList returns the volumes configured in the docker host.
func (client *NopClient) CheckpointList(ctx context.Context, container string) ([]types.Checkpoint, error) {
return []types.Checkpoint{}, errNoEngine
}
// ContainerAttach attaches a connection to a container in the server
func (client *NopClient) ContainerAttach(ctx context.Context, container string, options types.ContainerAttachOptions) (types.HijackedResponse, error) {
return types.HijackedResponse{}, errNoEngine
}
// ContainerCommit applies changes into a container and creates a new tagged image
func (client *NopClient) ContainerCommit(ctx context.Context, container string, options types.ContainerCommitOptions) (types.ContainerCommitResponse, error) {
return types.ContainerCommitResponse{}, errNoEngine
}
// ContainerCreate creates a new container based in the given configuration
func (client *NopClient) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, containerName string) (types.ContainerCreateResponse, error) {
return types.ContainerCreateResponse{}, errNoEngine
}
// ContainerDiff shows differences in a container filesystem since it was started
func (client *NopClient) ContainerDiff(ctx context.Context, container string) ([]types.ContainerChange, error) {
return nil, errNoEngine
}
// ContainerExecAttach attaches a connection to an exec process in the server
func (client *NopClient) ContainerExecAttach(ctx context.Context, execID string, config types.ExecConfig) (types.HijackedResponse, error) {
return types.HijackedResponse{}, errNoEngine
}
// ContainerExecCreate creates a new exec configuration to run an exec process
func (client *NopClient) ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.ContainerExecCreateResponse, error) {
return types.ContainerExecCreateResponse{}, errNoEngine
}
// ContainerExecInspect returns information about a specific exec process on the docker host
func (client *NopClient) ContainerExecInspect(ctx context.Context, execID string) (types.ContainerExecInspect, error) {
return types.ContainerExecInspect{}, errNoEngine
}
// ContainerExecResize changes the size of the tty for an exec process running inside a container
func (client *NopClient) ContainerExecResize(ctx context.Context, execID string, options types.ResizeOptions) error {
return errNoEngine
}
// ContainerExecStart starts an exec process already create in the docker host
func (client *NopClient) ContainerExecStart(ctx context.Context, execID string, config types.ExecStartCheck) error {
return errNoEngine
}
// ContainerExport retrieves the raw contents of a container and returns them as an io.ReadCloser
func (client *NopClient) ContainerExport(ctx context.Context, container string) (io.ReadCloser, error) {
return nil, errNoEngine
}
// ContainerInspect returns the container information
func (client *NopClient) ContainerInspect(ctx context.Context, container string) (types.ContainerJSON, error) {
return types.ContainerJSON{}, errNoEngine
}
// ContainerInspectWithRaw returns the container information and its raw representation
func (client *NopClient) ContainerInspectWithRaw(ctx context.Context, container string, getSize bool) (types.ContainerJSON, []byte, error) {
return types.ContainerJSON{}, nil, errNoEngine
}
// ContainerKill terminates the container process but does not remove the container from the docker host
func (client *NopClient) ContainerKill(ctx context.Context, container string, signal string) error {
return errNoEngine
}
// ContainerList returns the list of containers in the docker host
func (client *NopClient) ContainerList(ctx context.Context, options types.ContainerListOptions) ([]types.Container, error) {
return nil, errNoEngine
}
// ContainerLogs returns the logs generated by a container in an io.ReadCloser
func (client *NopClient) ContainerLogs(ctx context.Context, container string, options types.ContainerLogsOptions) (io.ReadCloser, error) {
return nil, errNoEngine
}
// ContainerPause pauses the main process of a given container without terminating it
func (client *NopClient) ContainerPause(ctx context.Context, container string) error {
return errNoEngine
}
// ContainerRemove kills and removes a container from the docker host
func (client *NopClient) ContainerRemove(ctx context.Context, container string, options types.ContainerRemoveOptions) error {
return errNoEngine
}
// ContainerRename changes the name of a given container
func (client *NopClient) ContainerRename(ctx context.Context, container, newContainerName string) error {
return errNoEngine
}
// ContainerResize changes the size of the tty for a container
func (client *NopClient) ContainerResize(ctx context.Context, container string, options types.ResizeOptions) error {
return errNoEngine
}
// ContainerRestart stops and starts a container again
func (client *NopClient) ContainerRestart(ctx context.Context, container string, timeout *time.Duration) error {
return errNoEngine
}
// ContainerStatPath returns Stat information about a path inside the container filesystem
func (client *NopClient) ContainerStatPath(ctx context.Context, container, path string) (types.ContainerPathStat, error) {
return types.ContainerPathStat{}, errNoEngine
}
// ContainerStats returns near realtime stats for a given container
func (client *NopClient) ContainerStats(ctx context.Context, container string, stream bool) (types.ContainerStats, error) {
return types.ContainerStats{}, errNoEngine
}
// ContainerStart sends a request to the docker daemon to start a container
func (client *NopClient) ContainerStart(ctx context.Context, container string, options types.ContainerStartOptions) error {
return errNoEngine
}
// ContainerStop stops a container without terminating the process
func (client *NopClient) ContainerStop(ctx context.Context, container string, timeout *time.Duration) error {
return errNoEngine
}
// ContainerTop shows process information from within a container
func (client *NopClient) ContainerTop(ctx context.Context, container string, arguments []string) (types.ContainerProcessList, error) {
return types.ContainerProcessList{}, errNoEngine
}
// ContainerUnpause resumes the process execution within a container
func (client *NopClient) ContainerUnpause(ctx context.Context, container string) error {
return errNoEngine
}
// ContainerUpdate updates resources of a container
func (client *NopClient) ContainerUpdate(ctx context.Context, container string, updateConfig container.UpdateConfig) (types.ContainerUpdateResponse, error) {
return types.ContainerUpdateResponse{}, errNoEngine
}
// ContainerWait pauses execution until a container exits
func (client *NopClient) ContainerWait(ctx context.Context, container string) (int, error) {
return 0, errNoEngine
}
// ContainersPrune requests the daemon to delete unused data
func (client *NopClient) ContainersPrune(ctx context.Context, cfg types.ContainersPruneConfig) (types.ContainersPruneReport, error) {
return types.ContainersPruneReport{}, errNoEngine
}
// CopyFromContainer gets the content from the container and returns it as a Reader to manipulate it in the host
func (client *NopClient) CopyFromContainer(ctx context.Context, container, srcPath string) (io.ReadCloser, types.ContainerPathStat, error) {
return nil, types.ContainerPathStat{}, errNoEngine
}
// CopyToContainer copies content into the container filesystem
func (client *NopClient) CopyToContainer(ctx context.Context, container, path string, content io.Reader, options types.CopyToContainerOptions) error {
return errNoEngine
}
// DiskUsage requests the current data usage from the daemon
func (client *NopClient) DiskUsage(ctx context.Context) (types.DiskUsage, error) {
return types.DiskUsage{}, errNoEngine
}
// Events returns a stream of events in the daemon in a ReadCloser
func (client *NopClient) Events(ctx context.Context, options types.EventsOptions) (<-chan events.Message, <-chan error) {
return nil, nil
}
// ImageBuild sends request to the daemon to build images
func (client *NopClient) ImageBuild(ctx context.Context, context io.Reader, options types.ImageBuildOptions) (types.ImageBuildResponse, error) {
return types.ImageBuildResponse{}, errNoEngine
}
// ImageCreate creates a new image based in the parent options
func (client *NopClient) ImageCreate(ctx context.Context, parentReference string, options types.ImageCreateOptions) (io.ReadCloser, error) {
return nil, errNoEngine
}
// ImageHistory returns the changes in an image in history format
func (client *NopClient) ImageHistory(ctx context.Context, image string) ([]types.ImageHistory, error) {
return nil, errNoEngine
}
// ImageImport creates a new image based in the source options
func (client *NopClient) ImageImport(ctx context.Context, source types.ImageImportSource, ref string, options types.ImageImportOptions) (io.ReadCloser, error) {
return nil, errNoEngine
}
// ImageInspectWithRaw returns the image information and it's raw representation
func (client *NopClient) ImageInspectWithRaw(ctx context.Context, image string) (types.ImageInspect, []byte, error) {
return types.ImageInspect{}, nil, errNoEngine
}
// ImageList returns a list of images in the docker host
func (client *NopClient) ImageList(ctx context.Context, options types.ImageListOptions) ([]types.Image, error) {
return nil, errNoEngine
}
// ImageLoad loads an image in the docker host from the client host
func (client *NopClient) ImageLoad(ctx context.Context, input io.Reader, quiet bool) (types.ImageLoadResponse, error) {
return types.ImageLoadResponse{}, errNoEngine
}
// ImagePull requests the docker host to pull an image from a remote registry
func (client *NopClient) ImagePull(ctx context.Context, ref string, options types.ImagePullOptions) (io.ReadCloser, error) {
return nil, errNoEngine
}
// ImagePush requests the docker host to push an image to a remote registry
func (client *NopClient) ImagePush(ctx context.Context, ref string, options types.ImagePushOptions) (io.ReadCloser, error) {
return nil, errNoEngine
}
// ImageRemove removes an image from the docker host
func (client *NopClient) ImageRemove(ctx context.Context, image string, options types.ImageRemoveOptions) ([]types.ImageDelete, error) {
return nil, errNoEngine
}
// ImageSearch makes the docker host to search by a term in a remote registry
func (client *NopClient) ImageSearch(ctx context.Context, term string, options types.ImageSearchOptions) ([]registry.SearchResult, error) {
return nil, errNoEngine
}
// ImageSave retrieves one or more images from the docker host as an io.ReadCloser
func (client *NopClient) ImageSave(ctx context.Context, images []string) (io.ReadCloser, error) {
return nil, errNoEngine
}
// ImageTag tags an image in the docker host
func (client *NopClient) ImageTag(ctx context.Context, image, ref string) error {
return errNoEngine
}
// ImagesPrune requests the daemon to delete unused data
func (client *NopClient) ImagesPrune(ctx context.Context, cfg types.ImagesPruneConfig) (types.ImagesPruneReport, error) {
return types.ImagesPruneReport{}, errNoEngine
}
// Info returns information about the docker server
func (client *NopClient) Info(ctx context.Context) (types.Info, error) {
return types.Info{}, errNoEngine
}
// NetworkConnect connects a container to an existent network in the docker host
func (client *NopClient) NetworkConnect(ctx context.Context, networkID, container string, config *network.EndpointSettings) error {
return errNoEngine
}
// NetworkCreate creates a new network in the docker host
func (client *NopClient) NetworkCreate(ctx context.Context, name string, options types.NetworkCreate) (types.NetworkCreateResponse, error) {
return types.NetworkCreateResponse{}, errNoEngine
}
// NetworkDisconnect disconnects a container from an existent network in the docker host
func (client *NopClient) NetworkDisconnect(ctx context.Context, networkID, container string, force bool) error {
return errNoEngine
}
// NetworkInspect returns the information for a specific network configured in the docker host
func (client *NopClient) NetworkInspect(ctx context.Context, networkID string) (types.NetworkResource, error) {
return types.NetworkResource{}, errNoEngine
}
// NetworkInspectWithRaw returns the information for a specific network configured in the docker host and it's raw representation.
func (client *NopClient) NetworkInspectWithRaw(ctx context.Context, networkID string) (types.NetworkResource, []byte, error) {
return types.NetworkResource{}, []byte{}, errNoEngine
}
// NetworkList returns the list of networks configured in the docker host
func (client *NopClient) NetworkList(ctx context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error) {
return nil, errNoEngine
}
// NetworkRemove removes an existent network from the docker host
func (client *NopClient) NetworkRemove(ctx context.Context, networkID string) error {
return errNoEngine
}
// RegistryLogin authenticates the docker server with a given docker registry
func (client *NopClient) RegistryLogin(ctx context.Context, auth types.AuthConfig) (types.AuthResponse, error) {
return types.AuthResponse{}, errNoEngine
}
// ServerVersion returns information of the docker client and server host
func (client *NopClient) ServerVersion(ctx context.Context) (types.Version, error) {
return types.Version{}, errNoEngine
}
// UpdateClientVersion updates the version string associated with this instance of the Client
func (client *NopClient) UpdateClientVersion(v string) {
}
// VolumeCreate creates a volume in the docker host
func (client *NopClient) VolumeCreate(ctx context.Context, options types.VolumeCreateRequest) (types.Volume, error) {
return types.Volume{}, errNoEngine
}
// VolumeInspect returns the information about a specific volume in the docker host
func (client *NopClient) VolumeInspect(ctx context.Context, volumeID string) (types.Volume, error) {
return types.Volume{}, errNoEngine
}
// VolumeInspectWithRaw returns the information about a specific volume in the docker host and it's raw representation
func (client *NopClient) VolumeInspectWithRaw(ctx context.Context, volumeID string) (types.Volume, []byte, error) {
return types.Volume{}, []byte{}, errNoEngine
}
// VolumeList returns the volumes configured in the docker host
func (client *NopClient) VolumeList(ctx context.Context, filter filters.Args) (types.VolumesListResponse, error) {
return types.VolumesListResponse{}, errNoEngine
}
// VolumeRemove removes a volume from the docker host
func (client *NopClient) VolumeRemove(ctx context.Context, volumeID string, force bool) error {
return errNoEngine
}
// VolumesPrune requests the daemon to delete unused data
func (client *NopClient) VolumesPrune(ctx context.Context, cfg types.VolumesPruneConfig) (types.VolumesPruneReport, error) {
return types.VolumesPruneReport{}, errNoEngine
}