gopkg.in/docker/libcompose.v0@v0.4.0/test/nop.go (about) 1 package test 2 3 import ( 4 "errors" 5 "io" 6 "time" 7 8 "golang.org/x/net/context" 9 10 "github.com/docker/docker/api/types" 11 "github.com/docker/docker/api/types/container" 12 "github.com/docker/docker/api/types/events" 13 "github.com/docker/docker/api/types/filters" 14 "github.com/docker/docker/api/types/network" 15 "github.com/docker/docker/api/types/registry" 16 "github.com/docker/docker/client" 17 ) 18 19 var ( 20 errNoEngine = errors.New("Engine no longer exists") 21 22 // Make sure NopClient implements ContainerAPIclient and other required interface 23 _ client.ContainerAPIClient = (*NopClient)(nil) 24 _ client.ImageAPIClient = (*NopClient)(nil) 25 _ client.NetworkAPIClient = (*NopClient)(nil) 26 _ client.VolumeAPIClient = (*NopClient)(nil) 27 _ client.SystemAPIClient = (*NopClient)(nil) 28 ) 29 30 // NopClient is a nop API Client based on engine-api 31 type NopClient struct { 32 } 33 34 // NewNopClient creates a new nop client 35 func NewNopClient() *NopClient { 36 return &NopClient{} 37 } 38 39 // ClientVersion returns the version string associated with this instance of the Client 40 func (client *NopClient) ClientVersion() string { 41 return "" 42 } 43 44 // CheckpointCreate creates a checkpoint from the given container with the given name 45 func (client *NopClient) CheckpointCreate(ctx context.Context, container string, options types.CheckpointCreateOptions) error { 46 return errNoEngine 47 } 48 49 // CheckpointDelete deletes the checkpoint with the given name from the given container 50 func (client *NopClient) CheckpointDelete(ctx context.Context, container string, checkpointID string) error { 51 return errNoEngine 52 } 53 54 // CheckpointList returns the volumes configured in the docker host. 55 func (client *NopClient) CheckpointList(ctx context.Context, container string) ([]types.Checkpoint, error) { 56 return []types.Checkpoint{}, errNoEngine 57 } 58 59 // ContainerAttach attaches a connection to a container in the server 60 func (client *NopClient) ContainerAttach(ctx context.Context, container string, options types.ContainerAttachOptions) (types.HijackedResponse, error) { 61 return types.HijackedResponse{}, errNoEngine 62 } 63 64 // ContainerCommit applies changes into a container and creates a new tagged image 65 func (client *NopClient) ContainerCommit(ctx context.Context, container string, options types.ContainerCommitOptions) (types.ContainerCommitResponse, error) { 66 return types.ContainerCommitResponse{}, errNoEngine 67 } 68 69 // ContainerCreate creates a new container based in the given configuration 70 func (client *NopClient) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, containerName string) (types.ContainerCreateResponse, error) { 71 return types.ContainerCreateResponse{}, errNoEngine 72 } 73 74 // ContainerDiff shows differences in a container filesystem since it was started 75 func (client *NopClient) ContainerDiff(ctx context.Context, container string) ([]types.ContainerChange, error) { 76 return nil, errNoEngine 77 } 78 79 // ContainerExecAttach attaches a connection to an exec process in the server 80 func (client *NopClient) ContainerExecAttach(ctx context.Context, execID string, config types.ExecConfig) (types.HijackedResponse, error) { 81 return types.HijackedResponse{}, errNoEngine 82 } 83 84 // ContainerExecCreate creates a new exec configuration to run an exec process 85 func (client *NopClient) ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.ContainerExecCreateResponse, error) { 86 return types.ContainerExecCreateResponse{}, errNoEngine 87 } 88 89 // ContainerExecInspect returns information about a specific exec process on the docker host 90 func (client *NopClient) ContainerExecInspect(ctx context.Context, execID string) (types.ContainerExecInspect, error) { 91 return types.ContainerExecInspect{}, errNoEngine 92 } 93 94 // ContainerExecResize changes the size of the tty for an exec process running inside a container 95 func (client *NopClient) ContainerExecResize(ctx context.Context, execID string, options types.ResizeOptions) error { 96 return errNoEngine 97 } 98 99 // ContainerExecStart starts an exec process already create in the docker host 100 func (client *NopClient) ContainerExecStart(ctx context.Context, execID string, config types.ExecStartCheck) error { 101 return errNoEngine 102 } 103 104 // ContainerExport retrieves the raw contents of a container and returns them as an io.ReadCloser 105 func (client *NopClient) ContainerExport(ctx context.Context, container string) (io.ReadCloser, error) { 106 return nil, errNoEngine 107 } 108 109 // ContainerInspect returns the container information 110 func (client *NopClient) ContainerInspect(ctx context.Context, container string) (types.ContainerJSON, error) { 111 return types.ContainerJSON{}, errNoEngine 112 } 113 114 // ContainerInspectWithRaw returns the container information and its raw representation 115 func (client *NopClient) ContainerInspectWithRaw(ctx context.Context, container string, getSize bool) (types.ContainerJSON, []byte, error) { 116 return types.ContainerJSON{}, nil, errNoEngine 117 } 118 119 // ContainerKill terminates the container process but does not remove the container from the docker host 120 func (client *NopClient) ContainerKill(ctx context.Context, container string, signal string) error { 121 return errNoEngine 122 } 123 124 // ContainerList returns the list of containers in the docker host 125 func (client *NopClient) ContainerList(ctx context.Context, options types.ContainerListOptions) ([]types.Container, error) { 126 return nil, errNoEngine 127 } 128 129 // ContainerLogs returns the logs generated by a container in an io.ReadCloser 130 func (client *NopClient) ContainerLogs(ctx context.Context, container string, options types.ContainerLogsOptions) (io.ReadCloser, error) { 131 return nil, errNoEngine 132 } 133 134 // ContainerPause pauses the main process of a given container without terminating it 135 func (client *NopClient) ContainerPause(ctx context.Context, container string) error { 136 return errNoEngine 137 } 138 139 // ContainerRemove kills and removes a container from the docker host 140 func (client *NopClient) ContainerRemove(ctx context.Context, container string, options types.ContainerRemoveOptions) error { 141 return errNoEngine 142 } 143 144 // ContainerRename changes the name of a given container 145 func (client *NopClient) ContainerRename(ctx context.Context, container, newContainerName string) error { 146 return errNoEngine 147 } 148 149 // ContainerResize changes the size of the tty for a container 150 func (client *NopClient) ContainerResize(ctx context.Context, container string, options types.ResizeOptions) error { 151 return errNoEngine 152 } 153 154 // ContainerRestart stops and starts a container again 155 func (client *NopClient) ContainerRestart(ctx context.Context, container string, timeout *time.Duration) error { 156 return errNoEngine 157 } 158 159 // ContainerStatPath returns Stat information about a path inside the container filesystem 160 func (client *NopClient) ContainerStatPath(ctx context.Context, container, path string) (types.ContainerPathStat, error) { 161 return types.ContainerPathStat{}, errNoEngine 162 } 163 164 // ContainerStats returns near realtime stats for a given container 165 func (client *NopClient) ContainerStats(ctx context.Context, container string, stream bool) (types.ContainerStats, error) { 166 return types.ContainerStats{}, errNoEngine 167 } 168 169 // ContainerStart sends a request to the docker daemon to start a container 170 func (client *NopClient) ContainerStart(ctx context.Context, container string, options types.ContainerStartOptions) error { 171 return errNoEngine 172 } 173 174 // ContainerStop stops a container without terminating the process 175 func (client *NopClient) ContainerStop(ctx context.Context, container string, timeout *time.Duration) error { 176 return errNoEngine 177 } 178 179 // ContainerTop shows process information from within a container 180 func (client *NopClient) ContainerTop(ctx context.Context, container string, arguments []string) (types.ContainerProcessList, error) { 181 return types.ContainerProcessList{}, errNoEngine 182 } 183 184 // ContainerUnpause resumes the process execution within a container 185 func (client *NopClient) ContainerUnpause(ctx context.Context, container string) error { 186 return errNoEngine 187 } 188 189 // ContainerUpdate updates resources of a container 190 func (client *NopClient) ContainerUpdate(ctx context.Context, container string, updateConfig container.UpdateConfig) (types.ContainerUpdateResponse, error) { 191 return types.ContainerUpdateResponse{}, errNoEngine 192 } 193 194 // ContainerWait pauses execution until a container exits 195 func (client *NopClient) ContainerWait(ctx context.Context, container string) (int, error) { 196 return 0, errNoEngine 197 } 198 199 // ContainersPrune requests the daemon to delete unused data 200 func (client *NopClient) ContainersPrune(ctx context.Context, cfg types.ContainersPruneConfig) (types.ContainersPruneReport, error) { 201 return types.ContainersPruneReport{}, errNoEngine 202 } 203 204 // CopyFromContainer gets the content from the container and returns it as a Reader to manipulate it in the host 205 func (client *NopClient) CopyFromContainer(ctx context.Context, container, srcPath string) (io.ReadCloser, types.ContainerPathStat, error) { 206 return nil, types.ContainerPathStat{}, errNoEngine 207 } 208 209 // CopyToContainer copies content into the container filesystem 210 func (client *NopClient) CopyToContainer(ctx context.Context, container, path string, content io.Reader, options types.CopyToContainerOptions) error { 211 return errNoEngine 212 } 213 214 // DiskUsage requests the current data usage from the daemon 215 func (client *NopClient) DiskUsage(ctx context.Context) (types.DiskUsage, error) { 216 return types.DiskUsage{}, errNoEngine 217 } 218 219 // Events returns a stream of events in the daemon in a ReadCloser 220 func (client *NopClient) Events(ctx context.Context, options types.EventsOptions) (<-chan events.Message, <-chan error) { 221 return nil, nil 222 } 223 224 // ImageBuild sends request to the daemon to build images 225 func (client *NopClient) ImageBuild(ctx context.Context, context io.Reader, options types.ImageBuildOptions) (types.ImageBuildResponse, error) { 226 return types.ImageBuildResponse{}, errNoEngine 227 } 228 229 // ImageCreate creates a new image based in the parent options 230 func (client *NopClient) ImageCreate(ctx context.Context, parentReference string, options types.ImageCreateOptions) (io.ReadCloser, error) { 231 return nil, errNoEngine 232 } 233 234 // ImageHistory returns the changes in an image in history format 235 func (client *NopClient) ImageHistory(ctx context.Context, image string) ([]types.ImageHistory, error) { 236 return nil, errNoEngine 237 } 238 239 // ImageImport creates a new image based in the source options 240 func (client *NopClient) ImageImport(ctx context.Context, source types.ImageImportSource, ref string, options types.ImageImportOptions) (io.ReadCloser, error) { 241 return nil, errNoEngine 242 } 243 244 // ImageInspectWithRaw returns the image information and it's raw representation 245 func (client *NopClient) ImageInspectWithRaw(ctx context.Context, image string) (types.ImageInspect, []byte, error) { 246 return types.ImageInspect{}, nil, errNoEngine 247 } 248 249 // ImageList returns a list of images in the docker host 250 func (client *NopClient) ImageList(ctx context.Context, options types.ImageListOptions) ([]types.Image, error) { 251 return nil, errNoEngine 252 } 253 254 // ImageLoad loads an image in the docker host from the client host 255 func (client *NopClient) ImageLoad(ctx context.Context, input io.Reader, quiet bool) (types.ImageLoadResponse, error) { 256 return types.ImageLoadResponse{}, errNoEngine 257 } 258 259 // ImagePull requests the docker host to pull an image from a remote registry 260 func (client *NopClient) ImagePull(ctx context.Context, ref string, options types.ImagePullOptions) (io.ReadCloser, error) { 261 return nil, errNoEngine 262 } 263 264 // ImagePush requests the docker host to push an image to a remote registry 265 func (client *NopClient) ImagePush(ctx context.Context, ref string, options types.ImagePushOptions) (io.ReadCloser, error) { 266 return nil, errNoEngine 267 } 268 269 // ImageRemove removes an image from the docker host 270 func (client *NopClient) ImageRemove(ctx context.Context, image string, options types.ImageRemoveOptions) ([]types.ImageDelete, error) { 271 return nil, errNoEngine 272 } 273 274 // ImageSearch makes the docker host to search by a term in a remote registry 275 func (client *NopClient) ImageSearch(ctx context.Context, term string, options types.ImageSearchOptions) ([]registry.SearchResult, error) { 276 return nil, errNoEngine 277 } 278 279 // ImageSave retrieves one or more images from the docker host as an io.ReadCloser 280 func (client *NopClient) ImageSave(ctx context.Context, images []string) (io.ReadCloser, error) { 281 return nil, errNoEngine 282 } 283 284 // ImageTag tags an image in the docker host 285 func (client *NopClient) ImageTag(ctx context.Context, image, ref string) error { 286 return errNoEngine 287 } 288 289 // ImagesPrune requests the daemon to delete unused data 290 func (client *NopClient) ImagesPrune(ctx context.Context, cfg types.ImagesPruneConfig) (types.ImagesPruneReport, error) { 291 return types.ImagesPruneReport{}, errNoEngine 292 } 293 294 // Info returns information about the docker server 295 func (client *NopClient) Info(ctx context.Context) (types.Info, error) { 296 return types.Info{}, errNoEngine 297 } 298 299 // NetworkConnect connects a container to an existent network in the docker host 300 func (client *NopClient) NetworkConnect(ctx context.Context, networkID, container string, config *network.EndpointSettings) error { 301 return errNoEngine 302 } 303 304 // NetworkCreate creates a new network in the docker host 305 func (client *NopClient) NetworkCreate(ctx context.Context, name string, options types.NetworkCreate) (types.NetworkCreateResponse, error) { 306 return types.NetworkCreateResponse{}, errNoEngine 307 } 308 309 // NetworkDisconnect disconnects a container from an existent network in the docker host 310 func (client *NopClient) NetworkDisconnect(ctx context.Context, networkID, container string, force bool) error { 311 return errNoEngine 312 } 313 314 // NetworkInspect returns the information for a specific network configured in the docker host 315 func (client *NopClient) NetworkInspect(ctx context.Context, networkID string) (types.NetworkResource, error) { 316 return types.NetworkResource{}, errNoEngine 317 } 318 319 // NetworkInspectWithRaw returns the information for a specific network configured in the docker host and it's raw representation. 320 func (client *NopClient) NetworkInspectWithRaw(ctx context.Context, networkID string) (types.NetworkResource, []byte, error) { 321 return types.NetworkResource{}, []byte{}, errNoEngine 322 } 323 324 // NetworkList returns the list of networks configured in the docker host 325 func (client *NopClient) NetworkList(ctx context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error) { 326 return nil, errNoEngine 327 } 328 329 // NetworkRemove removes an existent network from the docker host 330 func (client *NopClient) NetworkRemove(ctx context.Context, networkID string) error { 331 return errNoEngine 332 } 333 334 // RegistryLogin authenticates the docker server with a given docker registry 335 func (client *NopClient) RegistryLogin(ctx context.Context, auth types.AuthConfig) (types.AuthResponse, error) { 336 return types.AuthResponse{}, errNoEngine 337 } 338 339 // ServerVersion returns information of the docker client and server host 340 func (client *NopClient) ServerVersion(ctx context.Context) (types.Version, error) { 341 return types.Version{}, errNoEngine 342 } 343 344 // UpdateClientVersion updates the version string associated with this instance of the Client 345 func (client *NopClient) UpdateClientVersion(v string) { 346 } 347 348 // VolumeCreate creates a volume in the docker host 349 func (client *NopClient) VolumeCreate(ctx context.Context, options types.VolumeCreateRequest) (types.Volume, error) { 350 return types.Volume{}, errNoEngine 351 } 352 353 // VolumeInspect returns the information about a specific volume in the docker host 354 func (client *NopClient) VolumeInspect(ctx context.Context, volumeID string) (types.Volume, error) { 355 return types.Volume{}, errNoEngine 356 } 357 358 // VolumeInspectWithRaw returns the information about a specific volume in the docker host and it's raw representation 359 func (client *NopClient) VolumeInspectWithRaw(ctx context.Context, volumeID string) (types.Volume, []byte, error) { 360 return types.Volume{}, []byte{}, errNoEngine 361 } 362 363 // VolumeList returns the volumes configured in the docker host 364 func (client *NopClient) VolumeList(ctx context.Context, filter filters.Args) (types.VolumesListResponse, error) { 365 return types.VolumesListResponse{}, errNoEngine 366 } 367 368 // VolumeRemove removes a volume from the docker host 369 func (client *NopClient) VolumeRemove(ctx context.Context, volumeID string, force bool) error { 370 return errNoEngine 371 } 372 373 // VolumesPrune requests the daemon to delete unused data 374 func (client *NopClient) VolumesPrune(ctx context.Context, cfg types.VolumesPruneConfig) (types.VolumesPruneReport, error) { 375 return types.VolumesPruneReport{}, errNoEngine 376 }