Browse code

Create interface that clients that talk to the api must fulfill.

Signed-off-by: David Calavera <david.calavera@gmail.com>

David Calavera authored on 2015/12/05 07:02:06
Showing 29 changed files
... ...
@@ -15,7 +15,7 @@ import (
15 15
 
16 16
 	"github.com/docker/distribution/reference"
17 17
 	"github.com/docker/docker/api"
18
-	"github.com/docker/docker/api/client/lib"
18
+	"github.com/docker/docker/api/types"
19 19
 	Cli "github.com/docker/docker/cli"
20 20
 	"github.com/docker/docker/opts"
21 21
 	"github.com/docker/docker/pkg/archive"
... ...
@@ -207,7 +207,7 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
207 207
 		remoteContext = cmd.Arg(0)
208 208
 	}
209 209
 
210
-	options := lib.ImageBuildOptions{
210
+	options := types.ImageBuildOptions{
211 211
 		Context:        body,
212 212
 		Memory:         memory,
213 213
 		MemorySwap:     memorySwap,
... ...
@@ -43,7 +43,7 @@ type DockerCli struct {
43 43
 	// isTerminalOut indicates whether the client's STDOUT is a TTY
44 44
 	isTerminalOut bool
45 45
 	// client is the http client that performs all API operations
46
-	client *lib.Client
46
+	client apiClient
47 47
 
48 48
 	// DEPRECATED OPTIONS TO MAKE THE CLIENT COMPILE
49 49
 	// TODO: Remove
... ...
@@ -3,3 +3,58 @@
3 3
 // Run "docker help SUBCOMMAND" or "docker SUBCOMMAND --help" to see more information on any Docker subcommand, including the full list of options supported for the subcommand.
4 4
 // See https://docs.docker.com/installation/ for instructions on installing Docker.
5 5
 package client
6
+
7
+import (
8
+	"io"
9
+
10
+	"github.com/docker/docker/api/types"
11
+	"github.com/docker/docker/cliconfig"
12
+	"github.com/docker/docker/pkg/parsers/filters"
13
+	"github.com/docker/docker/runconfig"
14
+)
15
+
16
+// apiClient is an interface that clients that talk with a docker server must implement.
17
+type apiClient interface {
18
+	ContainerCommit(options types.ContainerCommitOptions) (types.ContainerCommitResponse, error)
19
+	ContainerCreate(config *runconfig.ContainerConfigWrapper, containerName string) (types.ContainerCreateResponse, error)
20
+	ContainerDiff(containerID string) ([]types.ContainerChange, error)
21
+	ContainerExport(containerID string) (io.ReadCloser, error)
22
+	ContainerInspect(containerID string) (types.ContainerJSON, error)
23
+	ContainerKill(containerID, signal string) error
24
+	ContainerList(options types.ContainerListOptions) ([]types.Container, error)
25
+	ContainerLogs(options types.ContainerLogsOptions) (io.ReadCloser, error)
26
+	ContainerPause(containerID string) error
27
+	ContainerRemove(options types.ContainerRemoveOptions) error
28
+	ContainerRename(containerID, newContainerName string) error
29
+	ContainerRestart(containerID string, timeout int) error
30
+	ContainerStatPath(containerID, path string) (types.ContainerPathStat, error)
31
+	ContainerStop(containerID string, timeout int) error
32
+	ContainerTop(containerID string, arguments []string) (types.ContainerProcessList, error)
33
+	ContainerUnpause(containerID string) error
34
+	ContainerWait(containerID string) (int, error)
35
+	CopyFromContainer(containerID, srcPath string) (io.ReadCloser, types.ContainerPathStat, error)
36
+	CopyToContainer(options types.CopyToContainerOptions) error
37
+	Events(options types.EventsOptions) (io.ReadCloser, error)
38
+	ImageBuild(options types.ImageBuildOptions) (types.ImageBuildResponse, error)
39
+	ImageCreate(options types.ImageCreateOptions) (io.ReadCloser, error)
40
+	ImageHistory(imageID string) ([]types.ImageHistory, error)
41
+	ImageImport(options types.ImageImportOptions) (io.ReadCloser, error)
42
+	ImageList(options types.ImageListOptions) ([]types.Image, error)
43
+	ImageLoad(input io.Reader) (io.ReadCloser, error)
44
+	ImageRemove(options types.ImageRemoveOptions) ([]types.ImageDelete, error)
45
+	ImageSave(imageIDs []string) (io.ReadCloser, error)
46
+	ImageTag(options types.ImageTagOptions) error
47
+	Info() (types.Info, error)
48
+	NetworkConnect(networkID, containerID string) error
49
+	NetworkCreate(options types.NetworkCreate) (types.NetworkCreateResponse, error)
50
+	NetworkDisconnect(networkID, containerID string) error
51
+	NetworkInspect(networkID string) (types.NetworkResource, error)
52
+	NetworkList() ([]types.NetworkResource, error)
53
+	NetworkRemove(networkID string) error
54
+	RegistryLogin(auth cliconfig.AuthConfig) (types.AuthResponse, error)
55
+	SystemVersion() (types.VersionResponse, error)
56
+	VolumeCreate(options types.VolumeCreateRequest) (types.Volume, error)
57
+	VolumeInspect(volumeID string) (types.Volume, error)
58
+	VolumeList(filter filters.Args) (types.VolumesListResponse, error)
59
+	VolumeRemove(volumeID string) error
60
+}
... ...
@@ -5,7 +5,7 @@ import (
5 5
 	"fmt"
6 6
 
7 7
 	"github.com/docker/distribution/reference"
8
-	"github.com/docker/docker/api/client/lib"
8
+	"github.com/docker/docker/api/types"
9 9
 	Cli "github.com/docker/docker/cli"
10 10
 	"github.com/docker/docker/opts"
11 11
 	flag "github.com/docker/docker/pkg/mflag"
... ...
@@ -56,7 +56,7 @@ func (cli *DockerCli) CmdCommit(args ...string) error {
56 56
 		}
57 57
 	}
58 58
 
59
-	options := lib.ContainerCommitOptions{
59
+	options := types.ContainerCommitOptions{
60 60
 		ContainerID:    name,
61 61
 		RepositoryName: repositoryName,
62 62
 		Tag:            tag,
... ...
@@ -7,7 +7,6 @@ import (
7 7
 	"path/filepath"
8 8
 	"strings"
9 9
 
10
-	"github.com/docker/docker/api/client/lib"
11 10
 	"github.com/docker/docker/api/types"
12 11
 	Cli "github.com/docker/docker/cli"
13 12
 	"github.com/docker/docker/pkg/archive"
... ...
@@ -126,7 +125,7 @@ func splitCpArg(arg string) (container, path string) {
126 126
 }
127 127
 
128 128
 func (cli *DockerCli) statContainerPath(containerName, path string) (types.ContainerPathStat, error) {
129
-	return cli.client.StatContainerPath(containerName, path)
129
+	return cli.client.ContainerStatPath(containerName, path)
130 130
 }
131 131
 
132 132
 func resolveLocalPath(localPath string) (absPath string, err error) {
... ...
@@ -286,7 +285,7 @@ func (cli *DockerCli) copyToContainer(srcPath, dstContainer, dstPath string, cpP
286 286
 		content = preparedArchive
287 287
 	}
288 288
 
289
-	options := lib.CopyToContainerOptions{
289
+	options := types.CopyToContainerOptions{
290 290
 		ContainerID:               dstContainer,
291 291
 		Path:                      resolvedDstPath,
292 292
 		Content:                   content,
... ...
@@ -51,13 +51,13 @@ func (cli *DockerCli) pullImageCustomOut(image string, out io.Writer) error {
51 51
 		return err
52 52
 	}
53 53
 
54
-	options := lib.CreateImageOptions{
54
+	options := types.ImageCreateOptions{
55 55
 		Parent:       ref.Name(),
56 56
 		Tag:          tag,
57 57
 		RegistryAuth: base64.URLEncoding.EncodeToString(buf),
58 58
 	}
59 59
 
60
-	responseBody, err := cli.client.CreateImage(options)
60
+	responseBody, err := cli.client.ImageCreate(options)
61 61
 	if err != nil {
62 62
 		return err
63 63
 	}
... ...
@@ -1,7 +1,7 @@
1 1
 package client
2 2
 
3 3
 import (
4
-	"github.com/docker/docker/api/client/lib"
4
+	"github.com/docker/docker/api/types"
5 5
 	Cli "github.com/docker/docker/cli"
6 6
 	"github.com/docker/docker/opts"
7 7
 	"github.com/docker/docker/pkg/jsonmessage"
... ...
@@ -34,7 +34,7 @@ func (cli *DockerCli) CmdEvents(args ...string) error {
34 34
 		}
35 35
 	}
36 36
 
37
-	options := lib.EventsOptions{
37
+	options := types.EventsOptions{
38 38
 		Since:   *since,
39 39
 		Until:   *until,
40 40
 		Filters: eventFilterArgs,
... ...
@@ -7,7 +7,7 @@ import (
7 7
 	"time"
8 8
 
9 9
 	"github.com/docker/distribution/reference"
10
-	"github.com/docker/docker/api/client/lib"
10
+	"github.com/docker/docker/api/types"
11 11
 	Cli "github.com/docker/docker/cli"
12 12
 	"github.com/docker/docker/opts"
13 13
 	flag "github.com/docker/docker/pkg/mflag"
... ...
@@ -48,7 +48,7 @@ func (cli *DockerCli) CmdImages(args ...string) error {
48 48
 		matchName = cmd.Arg(0)
49 49
 	}
50 50
 
51
-	options := lib.ImageListOptions{
51
+	options := types.ImageListOptions{
52 52
 		MatchName: matchName,
53 53
 		All:       *all,
54 54
 		Filters:   imageFilterArgs,
... ...
@@ -6,7 +6,7 @@ import (
6 6
 	"os"
7 7
 
8 8
 	"github.com/docker/distribution/reference"
9
-	"github.com/docker/docker/api/client/lib"
9
+	"github.com/docker/docker/api/types"
10 10
 	Cli "github.com/docker/docker/cli"
11 11
 	"github.com/docker/docker/opts"
12 12
 	"github.com/docker/docker/pkg/jsonmessage"
... ...
@@ -67,7 +67,7 @@ func (cli *DockerCli) CmdImport(args ...string) error {
67 67
 
68 68
 	}
69 69
 
70
-	options := lib.ImportImageOptions{
70
+	options := types.ImageImportOptions{
71 71
 		Source:         in,
72 72
 		SourceName:     srcName,
73 73
 		RepositoryName: repository,
... ...
@@ -76,7 +76,7 @@ func (cli *DockerCli) CmdImport(args ...string) error {
76 76
 		Changes:        changes,
77 77
 	}
78 78
 
79
-	responseBody, err := cli.client.ImportImage(options)
79
+	responseBody, err := cli.client.ImageImport(options)
80 80
 	if err != nil {
81 81
 		return err
82 82
 	}
... ...
@@ -8,18 +8,6 @@ import (
8 8
 	"github.com/docker/docker/runconfig"
9 9
 )
10 10
 
11
-// ContainerCommitOptions hods parameters to commit changes into a container.
12
-type ContainerCommitOptions struct {
13
-	ContainerID    string
14
-	RepositoryName string
15
-	Tag            string
16
-	Comment        string
17
-	Author         string
18
-	Changes        []string
19
-	Pause          bool
20
-	JSONConfig     string
21
-}
22
-
23 11
 // ContainerCommit applies changes into a container and creates a new tagged image.
24 12
 func (cli *Client) ContainerCommit(options types.ContainerCommitOptions) (types.ContainerCommitResponse, error) {
25 13
 	query := url.Values{}
... ...
@@ -9,20 +9,8 @@ import (
9 9
 	"github.com/docker/docker/pkg/parsers/filters"
10 10
 )
11 11
 
12
-// ContainerListOptions holds parameters to list containers with.
13
-type ContainerListOptions struct {
14
-	Quiet  bool
15
-	Size   bool
16
-	All    bool
17
-	Latest bool
18
-	Since  string
19
-	Before string
20
-	Limit  int
21
-	Filter filters.Args
22
-}
23
-
24 12
 // ContainerList returns the list of containers in the docker host.
25
-func (cli *Client) ContainerList(options ContainerListOptions) ([]types.Container, error) {
13
+func (cli *Client) ContainerList(options types.ContainerListOptions) ([]types.Container, error) {
26 14
 	var query url.Values
27 15
 
28 16
 	if options.All {
... ...
@@ -1,17 +1,13 @@
1 1
 package lib
2 2
 
3
-import "net/url"
3
+import (
4
+	"net/url"
4 5
 
5
-// ContainerRemoveOptions holds parameters to remove containers.
6
-type ContainerRemoveOptions struct {
7
-	ContainerID   string
8
-	RemoveVolumes bool
9
-	RemoveLinks   bool
10
-	Force         bool
11
-}
6
+	"github.com/docker/docker/api/types"
7
+)
12 8
 
13 9
 // ContainerRemove kills and removes a container from the docker host.
14
-func (cli *Client) ContainerRemove(options ContainerRemoveOptions) error {
10
+func (cli *Client) ContainerRemove(options types.ContainerRemoveOptions) error {
15 11
 	var query url.Values
16 12
 	if options.RemoveVolumes {
17 13
 		query.Set("v", "1")
... ...
@@ -13,17 +13,8 @@ import (
13 13
 	"github.com/docker/docker/api/types"
14 14
 )
15 15
 
16
-// CopyToContainerOptions holds information
17
-// about files to copy into a container
18
-type CopyToContainerOptions struct {
19
-	ContainerID               string
20
-	Path                      string
21
-	Content                   io.Reader
22
-	AllowOverwriteDirWithFile bool
23
-}
24
-
25
-// StatContainerPath returns Stat information about a path inside the container filesystem.
26
-func (cli *Client) StatContainerPath(containerID, path string) (types.ContainerPathStat, error) {
16
+// ContainerStatPath returns Stat information about a path inside the container filesystem.
17
+func (cli *Client) ContainerStatPath(containerID, path string) (types.ContainerPathStat, error) {
27 18
 	query := make(url.Values, 1)
28 19
 	query.Set("path", filepath.ToSlash(path)) // Normalize the paths used in the API.
29 20
 
... ...
@@ -37,7 +28,7 @@ func (cli *Client) StatContainerPath(containerID, path string) (types.ContainerP
37 37
 }
38 38
 
39 39
 // CopyToContainer copies content into the container filesystem.
40
-func (cli *Client) CopyToContainer(options CopyToContainerOptions) error {
40
+func (cli *Client) CopyToContainer(options types.CopyToContainerOptions) error {
41 41
 	var query url.Values
42 42
 	query.Set("path", filepath.ToSlash(options.Path)) // Normalize the paths used in the API.
43 43
 	// Do not allow for an existing directory to be overwritten by a non-directory and vice versa.
... ...
@@ -5,20 +5,14 @@ import (
5 5
 	"net/url"
6 6
 	"time"
7 7
 
8
+	"github.com/docker/docker/api/types"
8 9
 	"github.com/docker/docker/pkg/parsers/filters"
9 10
 	"github.com/docker/docker/pkg/timeutils"
10 11
 )
11 12
 
12
-// EventsOptions hold parameters to filter events with.
13
-type EventsOptions struct {
14
-	Since   string
15
-	Until   string
16
-	Filters filters.Args
17
-}
18
-
19 13
 // Events returns a stream of events in the daemon in a ReadCloser.
20 14
 // It's up to the caller to close the stream.
21
-func (cli *Client) Events(options EventsOptions) (io.ReadCloser, error) {
15
+func (cli *Client) Events(options types.EventsOptions) (io.ReadCloser, error) {
22 16
 	var query url.Values
23 17
 	ref := time.Now()
24 18
 
... ...
@@ -3,73 +3,36 @@ package lib
3 3
 import (
4 4
 	"encoding/base64"
5 5
 	"encoding/json"
6
-	"io"
7 6
 	"net/http"
8 7
 	"net/url"
9 8
 	"strconv"
10 9
 
11
-	"github.com/docker/docker/cliconfig"
10
+	"github.com/docker/docker/api/types"
12 11
 	"github.com/docker/docker/pkg/httputils"
13
-	"github.com/docker/docker/pkg/ulimit"
14 12
 	"github.com/docker/docker/pkg/units"
15 13
 	"github.com/docker/docker/runconfig"
16 14
 )
17 15
 
18
-// ImageBuildOptions holds the information
19
-// necessary to build images.
20
-type ImageBuildOptions struct {
21
-	Tags           []string
22
-	SuppressOutput bool
23
-	RemoteContext  string
24
-	NoCache        bool
25
-	Remove         bool
26
-	ForceRemove    bool
27
-	PullParent     bool
28
-	Isolation      string
29
-	CPUSetCPUs     string
30
-	CPUSetMems     string
31
-	CPUShares      int64
32
-	CPUQuota       int64
33
-	CPUPeriod      int64
34
-	Memory         int64
35
-	MemorySwap     int64
36
-	CgroupParent   string
37
-	ShmSize        string
38
-	Dockerfile     string
39
-	Ulimits        []*ulimit.Ulimit
40
-	BuildArgs      []string
41
-	AuthConfigs    map[string]cliconfig.AuthConfig
42
-	Context        io.Reader
43
-}
44
-
45
-// ImageBuildResponse holds information
46
-// returned by a server after building
47
-// an image.
48
-type ImageBuildResponse struct {
49
-	Body   io.ReadCloser
50
-	OSType string
51
-}
52
-
53 16
 // ImageBuild sends request to the daemon to build images.
54 17
 // The Body in the response implement an io.ReadCloser and it's up to the caller to
55 18
 // close it.
56
-func (cli *Client) ImageBuild(options ImageBuildOptions) (ImageBuildResponse, error) {
19
+func (cli *Client) ImageBuild(options types.ImageBuildOptions) (types.ImageBuildResponse, error) {
57 20
 	query, err := imageBuildOptionsToQuery(options)
58 21
 	if err != nil {
59
-		return ImageBuildResponse{}, err
22
+		return types.ImageBuildResponse{}, err
60 23
 	}
61 24
 
62 25
 	headers := http.Header(make(map[string][]string))
63 26
 	buf, err := json.Marshal(options.AuthConfigs)
64 27
 	if err != nil {
65
-		return ImageBuildResponse{}, err
28
+		return types.ImageBuildResponse{}, err
66 29
 	}
67 30
 	headers.Add("X-Registry-Config", base64.URLEncoding.EncodeToString(buf))
68 31
 	headers.Set("Content-Type", "application/tar")
69 32
 
70 33
 	serverResp, err := cli.POSTRaw("/build", query, options.Context, headers)
71 34
 	if err != nil {
72
-		return ImageBuildResponse{}, err
35
+		return types.ImageBuildResponse{}, err
73 36
 	}
74 37
 
75 38
 	var osType string
... ...
@@ -77,13 +40,13 @@ func (cli *Client) ImageBuild(options ImageBuildOptions) (ImageBuildResponse, er
77 77
 		osType = h.OS
78 78
 	}
79 79
 
80
-	return ImageBuildResponse{
80
+	return types.ImageBuildResponse{
81 81
 		Body:   serverResp.body,
82 82
 		OSType: osType,
83 83
 	}, nil
84 84
 }
85 85
 
86
-func imageBuildOptionsToQuery(options ImageBuildOptions) (url.Values, error) {
86
+func imageBuildOptionsToQuery(options types.ImageBuildOptions) (url.Values, error) {
87 87
 	query := url.Values{
88 88
 		"t": options.Tags,
89 89
 	}
... ...
@@ -3,21 +3,13 @@ package lib
3 3
 import (
4 4
 	"io"
5 5
 	"net/url"
6
-)
7 6
 
8
-// CreateImageOptions holds information to create images.
9
-type CreateImageOptions struct {
10
-	// Parent is the image to create this image from
11
-	Parent string
12
-	// Tag is the name to tag this image
13
-	Tag string
14
-	// RegistryAuth is the base64 encoded credentials for this server
15
-	RegistryAuth string
16
-}
7
+	"github.com/docker/docker/api/types"
8
+)
17 9
 
18
-// CreateImage creates a new image based in the parent options.
10
+// ImageCreate creates a new image based in the parent options.
19 11
 // It returns the JSON content in the response body.
20
-func (cli *Client) CreateImage(options CreateImageOptions) (io.ReadCloser, error) {
12
+func (cli *Client) ImageCreate(options types.ImageCreateOptions) (io.ReadCloser, error) {
21 13
 	var query url.Values
22 14
 	query.Set("fromImage", options.Parent)
23 15
 	query.Set("tag", options.Tag)
... ...
@@ -3,27 +3,13 @@ package lib
3 3
 import (
4 4
 	"io"
5 5
 	"net/url"
6
-)
7 6
 
8
-// ImportImageOptions holds information to import images from the client host.
9
-type ImportImageOptions struct {
10
-	// Source is the data to send to the server to create this image from
11
-	Source io.Reader
12
-	// Source is the name of the source to import this image from
13
-	SourceName string
14
-	// RepositoryName is the name of the repository to import this image
15
-	RepositoryName string
16
-	// Message is the message to tag the image with
17
-	Message string
18
-	// Tag is the name to tag this image
19
-	Tag string
20
-	// Changes are the raw changes to apply to the image
21
-	Changes []string
22
-}
7
+	"github.com/docker/docker/api/types"
8
+)
23 9
 
24
-// ImportImage creates a new image based in the source options.
10
+// ImageImport creates a new image based in the source options.
25 11
 // It returns the JSON content in the response body.
26
-func (cli *Client) ImportImage(options ImportImageOptions) (io.ReadCloser, error) {
12
+func (cli *Client) ImageImport(options types.ImageImportOptions) (io.ReadCloser, error) {
27 13
 	var query url.Values
28 14
 	query.Set("fromSrc", options.SourceName)
29 15
 	query.Set("repo", options.RepositoryName)
... ...
@@ -8,15 +8,8 @@ import (
8 8
 	"github.com/docker/docker/pkg/parsers/filters"
9 9
 )
10 10
 
11
-// ImageListOptions holds parameters to filter the list of images with.
12
-type ImageListOptions struct {
13
-	MatchName string
14
-	All       bool
15
-	Filters   filters.Args
16
-}
17
-
18 11
 // ImageList returns a list of images in the docker host.
19
-func (cli *Client) ImageList(options ImageListOptions) ([]types.Image, error) {
12
+func (cli *Client) ImageList(options types.ImageListOptions) ([]types.Image, error) {
20 13
 	var (
21 14
 		images []types.Image
22 15
 		query  url.Values
... ...
@@ -7,15 +7,8 @@ import (
7 7
 	"github.com/docker/docker/api/types"
8 8
 )
9 9
 
10
-// ImageRemoveOptions holds parameters to remove images.
11
-type ImageRemoveOptions struct {
12
-	ImageID       string
13
-	Force         bool
14
-	PruneChildren bool
15
-}
16
-
17 10
 // ImageRemove removes an image from the docker host.
18
-func (cli *Client) ImageRemove(options ImageRemoveOptions) ([]types.ImageDelete, error) {
11
+func (cli *Client) ImageRemove(options types.ImageRemoveOptions) ([]types.ImageDelete, error) {
19 12
 	var query url.Values
20 13
 
21 14
 	if options.Force {
... ...
@@ -1,14 +1,10 @@
1 1
 package lib
2 2
 
3
-import "net/url"
3
+import (
4
+	"net/url"
4 5
 
5
-// ImageTagOptions hold parameters to tag an image
6
-type ImageTagOptions struct {
7
-	ImageID        string
8
-	RepositoryName string
9
-	Tag            string
10
-	Force          bool
11
-}
6
+	"github.com/docker/docker/api/types"
7
+)
12 8
 
13 9
 // ImageTag tags an image in the docker host
14 10
 func (cli *Client) ImageTag(options types.ImageTagOptions) error {
... ...
@@ -5,23 +5,13 @@ import (
5 5
 	"net/url"
6 6
 	"time"
7 7
 
8
+	"github.com/docker/docker/api/types"
8 9
 	"github.com/docker/docker/pkg/timeutils"
9 10
 )
10 11
 
11
-// ContainerLogsOptions holds parameters to filter logs with.
12
-type ContainerLogsOptions struct {
13
-	ContainerID string
14
-	ShowStdout  bool
15
-	ShowStderr  bool
16
-	Since       string
17
-	Timestamps  bool
18
-	Follow      bool
19
-	Tail        string
20
-}
21
-
22 12
 // ContainerLogs returns the logs generated by a container in an io.ReadCloser.
23 13
 // It's up to the caller to close the stream.
24
-func (cli *Client) ContainerLogs(options ContainerLogsOptions) (io.ReadCloser, error) {
14
+func (cli *Client) ContainerLogs(options types.ContainerLogsOptions) (io.ReadCloser, error) {
25 15
 	var query url.Values
26 16
 	if options.ShowStdout {
27 17
 		query.Set("stdout", "1")
... ...
@@ -10,20 +10,8 @@ import (
10 10
 	"github.com/docker/docker/utils"
11 11
 )
12 12
 
13
-// VersionResponse holds version information for the client and the server
14
-type VersionResponse struct {
15
-	Client *types.Version
16
-	Server *types.Version
17
-}
18
-
19
-// ServerOK return true when the client could connect to the docker server
20
-// and parse the information received. It returns false otherwise.
21
-func (v VersionResponse) ServerOK() bool {
22
-	return v.Server == nil
23
-}
24
-
25 13
 // SystemVersion returns information of the docker client and server host.
26
-func (cli *Client) SystemVersion() (VersionResponse, error) {
14
+func (cli *Client) SystemVersion() (types.VersionResponse, error) {
27 15
 	client := &types.Version{
28 16
 		Version:      dockerversion.Version,
29 17
 		APIVersion:   api.Version,
... ...
@@ -37,14 +25,14 @@ func (cli *Client) SystemVersion() (VersionResponse, error) {
37 37
 
38 38
 	resp, err := cli.GET("/version", nil, nil)
39 39
 	if err != nil {
40
-		return VersionResponse{Client: client}, err
40
+		return types.VersionResponse{Client: client}, err
41 41
 	}
42 42
 	defer ensureReaderClosed(resp)
43 43
 
44 44
 	var server types.Version
45 45
 	err = json.NewDecoder(resp.body).Decode(&server)
46 46
 	if err != nil {
47
-		return VersionResponse{Client: client}, err
47
+		return types.VersionResponse{Client: client}, err
48 48
 	}
49 49
 	return types.VersionResponse{Client: client, Server: &server}, nil
50 50
 }
... ...
@@ -4,7 +4,7 @@ import (
4 4
 	"fmt"
5 5
 	"io"
6 6
 
7
-	"github.com/docker/docker/api/client/lib"
7
+	"github.com/docker/docker/api/types"
8 8
 	Cli "github.com/docker/docker/cli"
9 9
 	flag "github.com/docker/docker/pkg/mflag"
10 10
 	"github.com/docker/docker/pkg/stdcopy"
... ...
@@ -39,7 +39,7 @@ func (cli *DockerCli) CmdLogs(args ...string) error {
39 39
 		return fmt.Errorf("\"logs\" command is supported only for \"json-file\" and \"journald\" logging drivers (got: %s)", c.HostConfig.LogConfig.Type)
40 40
 	}
41 41
 
42
-	options := lib.ContainerLogsOptions{
42
+	options := types.ContainerLogsOptions{
43 43
 		ContainerID: name,
44 44
 		ShowStdout:  true,
45 45
 		ShowStderr:  true,
... ...
@@ -1,8 +1,8 @@
1 1
 package client
2 2
 
3 3
 import (
4
-	"github.com/docker/docker/api/client/lib"
5 4
 	"github.com/docker/docker/api/client/ps"
5
+	"github.com/docker/docker/api/types"
6 6
 	Cli "github.com/docker/docker/cli"
7 7
 	"github.com/docker/docker/opts"
8 8
 	flag "github.com/docker/docker/pkg/mflag"
... ...
@@ -47,7 +47,7 @@ func (cli *DockerCli) CmdPs(args ...string) error {
47 47
 		}
48 48
 	}
49 49
 
50
-	options := lib.ContainerListOptions{
50
+	options := types.ContainerListOptions{
51 51
 		All:    *all,
52 52
 		Limit:  *last,
53 53
 		Since:  *since,
... ...
@@ -4,7 +4,7 @@ import (
4 4
 	"fmt"
5 5
 	"strings"
6 6
 
7
-	"github.com/docker/docker/api/client/lib"
7
+	"github.com/docker/docker/api/types"
8 8
 	Cli "github.com/docker/docker/cli"
9 9
 	flag "github.com/docker/docker/pkg/mflag"
10 10
 )
... ...
@@ -28,7 +28,7 @@ func (cli *DockerCli) CmdRm(args ...string) error {
28 28
 		}
29 29
 		name = strings.Trim(name, "/")
30 30
 
31
-		options := lib.ContainerRemoveOptions{
31
+		options := types.ContainerRemoveOptions{
32 32
 			ContainerID:   name,
33 33
 			RemoveVolumes: *v,
34 34
 			RemoveLinks:   *link,
... ...
@@ -4,7 +4,7 @@ import (
4 4
 	"fmt"
5 5
 	"net/url"
6 6
 
7
-	"github.com/docker/docker/api/client/lib"
7
+	"github.com/docker/docker/api/types"
8 8
 	Cli "github.com/docker/docker/cli"
9 9
 	flag "github.com/docker/docker/pkg/mflag"
10 10
 )
... ...
@@ -30,7 +30,7 @@ func (cli *DockerCli) CmdRmi(args ...string) error {
30 30
 
31 31
 	var errNames []string
32 32
 	for _, name := range cmd.Args() {
33
-		options := lib.ImageRemoveOptions{
33
+		options := types.ImageRemoveOptions{
34 34
 			ImageID:       name,
35 35
 			Force:         *force,
36 36
 			PruneChildren: !*noprune,
... ...
@@ -4,7 +4,7 @@ import (
4 4
 	"errors"
5 5
 
6 6
 	"github.com/docker/distribution/reference"
7
-	"github.com/docker/docker/api/client/lib"
7
+	"github.com/docker/docker/api/types"
8 8
 	Cli "github.com/docker/docker/cli"
9 9
 	flag "github.com/docker/docker/pkg/mflag"
10 10
 	"github.com/docker/docker/registry"
... ...
@@ -41,7 +41,7 @@ func (cli *DockerCli) CmdTag(args ...string) error {
41 41
 		return err
42 42
 	}
43 43
 
44
-	options := lib.ImageTagOptions{
44
+	options := types.ImageTagOptions{
45 45
 		ImageID:        cmd.Arg(0),
46 46
 		RepositoryName: ref.Name(),
47 47
 		Tag:            tag,
... ...
@@ -22,7 +22,7 @@ import (
22 22
 	"github.com/docker/distribution/reference"
23 23
 	"github.com/docker/distribution/registry/client/auth"
24 24
 	"github.com/docker/distribution/registry/client/transport"
25
-	"github.com/docker/docker/api/client/lib"
25
+	"github.com/docker/docker/api/types"
26 26
 	"github.com/docker/docker/cliconfig"
27 27
 	"github.com/docker/docker/pkg/ansiescape"
28 28
 	"github.com/docker/docker/pkg/ioutils"
... ...
@@ -252,7 +252,7 @@ func (cli *DockerCli) trustedReference(ref reference.NamedTagged) (reference.Can
252 252
 func (cli *DockerCli) tagTrusted(trustedRef reference.Canonical, ref reference.NamedTagged) error {
253 253
 	fmt.Fprintf(cli.out, "Tagging %s as %s\n", trustedRef.String(), ref.String())
254 254
 
255
-	options := lib.ImageTagOptions{
255
+	options := types.ImageTagOptions{
256 256
 		ImageID:        trustedRef.String(),
257 257
 		RepositoryName: trustedRef.Name(),
258 258
 		Tag:            ref.Tag(),
259 259
new file mode 100644
... ...
@@ -0,0 +1,163 @@
0
+package types
1
+
2
+import (
3
+	"io"
4
+
5
+	"github.com/docker/docker/cliconfig"
6
+	"github.com/docker/docker/pkg/parsers/filters"
7
+	"github.com/docker/docker/pkg/ulimit"
8
+)
9
+
10
+// ContainerCommitOptions hods parameters to commit changes into a container.
11
+type ContainerCommitOptions struct {
12
+	ContainerID    string
13
+	RepositoryName string
14
+	Tag            string
15
+	Comment        string
16
+	Author         string
17
+	Changes        []string
18
+	Pause          bool
19
+	JSONConfig     string
20
+}
21
+
22
+// ContainerListOptions holds parameters to list containers with.
23
+type ContainerListOptions struct {
24
+	Quiet  bool
25
+	Size   bool
26
+	All    bool
27
+	Latest bool
28
+	Since  string
29
+	Before string
30
+	Limit  int
31
+	Filter filters.Args
32
+}
33
+
34
+// ContainerLogsOptions holds parameters to filter logs with.
35
+type ContainerLogsOptions struct {
36
+	ContainerID string
37
+	ShowStdout  bool
38
+	ShowStderr  bool
39
+	Since       string
40
+	Timestamps  bool
41
+	Follow      bool
42
+	Tail        string
43
+}
44
+
45
+// ContainerRemoveOptions holds parameters to remove containers.
46
+type ContainerRemoveOptions struct {
47
+	ContainerID   string
48
+	RemoveVolumes bool
49
+	RemoveLinks   bool
50
+	Force         bool
51
+}
52
+
53
+// CopyToContainerOptions holds information
54
+// about files to copy into a container
55
+type CopyToContainerOptions struct {
56
+	ContainerID               string
57
+	Path                      string
58
+	Content                   io.Reader
59
+	AllowOverwriteDirWithFile bool
60
+}
61
+
62
+// EventsOptions hold parameters to filter events with.
63
+type EventsOptions struct {
64
+	Since   string
65
+	Until   string
66
+	Filters filters.Args
67
+}
68
+
69
+// ImageBuildOptions holds the information
70
+// necessary to build images.
71
+type ImageBuildOptions struct {
72
+	Tags           []string
73
+	SuppressOutput bool
74
+	RemoteContext  string
75
+	NoCache        bool
76
+	Remove         bool
77
+	ForceRemove    bool
78
+	PullParent     bool
79
+	Isolation      string
80
+	CPUSetCPUs     string
81
+	CPUSetMems     string
82
+	CPUShares      int64
83
+	CPUQuota       int64
84
+	CPUPeriod      int64
85
+	Memory         int64
86
+	MemorySwap     int64
87
+	CgroupParent   string
88
+	ShmSize        string
89
+	Dockerfile     string
90
+	Ulimits        []*ulimit.Ulimit
91
+	BuildArgs      []string
92
+	AuthConfigs    map[string]cliconfig.AuthConfig
93
+	Context        io.Reader
94
+}
95
+
96
+// ImageBuildResponse holds information
97
+// returned by a server after building
98
+// an image.
99
+type ImageBuildResponse struct {
100
+	Body   io.ReadCloser
101
+	OSType string
102
+}
103
+
104
+// ImageCreateOptions holds information to create images.
105
+type ImageCreateOptions struct {
106
+	// Parent is the image to create this image from
107
+	Parent string
108
+	// Tag is the name to tag this image
109
+	Tag string
110
+	// RegistryAuth is the base64 encoded credentials for this server
111
+	RegistryAuth string
112
+}
113
+
114
+// ImageImportOptions holds information to import images from the client host.
115
+type ImageImportOptions struct {
116
+	// Source is the data to send to the server to create this image from
117
+	Source io.Reader
118
+	// Source is the name of the source to import this image from
119
+	SourceName string
120
+	// RepositoryName is the name of the repository to import this image
121
+	RepositoryName string
122
+	// Message is the message to tag the image with
123
+	Message string
124
+	// Tag is the name to tag this image
125
+	Tag string
126
+	// Changes are the raw changes to apply to the image
127
+	Changes []string
128
+}
129
+
130
+// ImageListOptions holds parameters to filter the list of images with.
131
+type ImageListOptions struct {
132
+	MatchName string
133
+	All       bool
134
+	Filters   filters.Args
135
+}
136
+
137
+// ImageRemoveOptions holds parameters to remove images.
138
+type ImageRemoveOptions struct {
139
+	ImageID       string
140
+	Force         bool
141
+	PruneChildren bool
142
+}
143
+
144
+// ImageTagOptions hold parameters to tag an image
145
+type ImageTagOptions struct {
146
+	ImageID        string
147
+	RepositoryName string
148
+	Tag            string
149
+	Force          bool
150
+}
151
+
152
+// VersionResponse holds version information for the client and the server
153
+type VersionResponse struct {
154
+	Client *Version
155
+	Server *Version
156
+}
157
+
158
+// ServerOK return true when the client could connect to the docker server
159
+// and parse the information received. It returns false otherwise.
160
+func (v VersionResponse) ServerOK() bool {
161
+	return v.Server != nil
162
+}