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

Signed-off-by: David Calavera <david.calavera@gmail.com>
This commit is contained in:
David Calavera 2015-12-04 17:02:06 -05:00
parent a413be3392
commit 8b15839ee8
29 changed files with 283 additions and 208 deletions

View file

@ -15,7 +15,7 @@ import (
"github.com/docker/distribution/reference"
"github.com/docker/docker/api"
"github.com/docker/docker/api/client/lib"
"github.com/docker/docker/api/types"
Cli "github.com/docker/docker/cli"
"github.com/docker/docker/opts"
"github.com/docker/docker/pkg/archive"
@ -207,7 +207,7 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
remoteContext = cmd.Arg(0)
}
options := lib.ImageBuildOptions{
options := types.ImageBuildOptions{
Context: body,
Memory: memory,
MemorySwap: memorySwap,

View file

@ -43,7 +43,7 @@ type DockerCli struct {
// isTerminalOut indicates whether the client's STDOUT is a TTY
isTerminalOut bool
// client is the http client that performs all API operations
client *lib.Client
client apiClient
// DEPRECATED OPTIONS TO MAKE THE CLIENT COMPILE
// TODO: Remove

View file

@ -3,3 +3,58 @@
// 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.
// See https://docs.docker.com/installation/ for instructions on installing Docker.
package client
import (
"io"
"github.com/docker/docker/api/types"
"github.com/docker/docker/cliconfig"
"github.com/docker/docker/pkg/parsers/filters"
"github.com/docker/docker/runconfig"
)
// apiClient is an interface that clients that talk with a docker server must implement.
type apiClient interface {
ContainerCommit(options types.ContainerCommitOptions) (types.ContainerCommitResponse, error)
ContainerCreate(config *runconfig.ContainerConfigWrapper, containerName string) (types.ContainerCreateResponse, error)
ContainerDiff(containerID string) ([]types.ContainerChange, error)
ContainerExport(containerID string) (io.ReadCloser, error)
ContainerInspect(containerID string) (types.ContainerJSON, error)
ContainerKill(containerID, signal string) error
ContainerList(options types.ContainerListOptions) ([]types.Container, error)
ContainerLogs(options types.ContainerLogsOptions) (io.ReadCloser, error)
ContainerPause(containerID string) error
ContainerRemove(options types.ContainerRemoveOptions) error
ContainerRename(containerID, newContainerName string) error
ContainerRestart(containerID string, timeout int) error
ContainerStatPath(containerID, path string) (types.ContainerPathStat, error)
ContainerStop(containerID string, timeout int) error
ContainerTop(containerID string, arguments []string) (types.ContainerProcessList, error)
ContainerUnpause(containerID string) error
ContainerWait(containerID string) (int, error)
CopyFromContainer(containerID, srcPath string) (io.ReadCloser, types.ContainerPathStat, error)
CopyToContainer(options types.CopyToContainerOptions) error
Events(options types.EventsOptions) (io.ReadCloser, error)
ImageBuild(options types.ImageBuildOptions) (types.ImageBuildResponse, error)
ImageCreate(options types.ImageCreateOptions) (io.ReadCloser, error)
ImageHistory(imageID string) ([]types.ImageHistory, error)
ImageImport(options types.ImageImportOptions) (io.ReadCloser, error)
ImageList(options types.ImageListOptions) ([]types.Image, error)
ImageLoad(input io.Reader) (io.ReadCloser, error)
ImageRemove(options types.ImageRemoveOptions) ([]types.ImageDelete, error)
ImageSave(imageIDs []string) (io.ReadCloser, error)
ImageTag(options types.ImageTagOptions) error
Info() (types.Info, error)
NetworkConnect(networkID, containerID string) error
NetworkCreate(options types.NetworkCreate) (types.NetworkCreateResponse, error)
NetworkDisconnect(networkID, containerID string) error
NetworkInspect(networkID string) (types.NetworkResource, error)
NetworkList() ([]types.NetworkResource, error)
NetworkRemove(networkID string) error
RegistryLogin(auth cliconfig.AuthConfig) (types.AuthResponse, error)
SystemVersion() (types.VersionResponse, error)
VolumeCreate(options types.VolumeCreateRequest) (types.Volume, error)
VolumeInspect(volumeID string) (types.Volume, error)
VolumeList(filter filters.Args) (types.VolumesListResponse, error)
VolumeRemove(volumeID string) error
}

View file

@ -5,7 +5,7 @@ import (
"fmt"
"github.com/docker/distribution/reference"
"github.com/docker/docker/api/client/lib"
"github.com/docker/docker/api/types"
Cli "github.com/docker/docker/cli"
"github.com/docker/docker/opts"
flag "github.com/docker/docker/pkg/mflag"
@ -56,7 +56,7 @@ func (cli *DockerCli) CmdCommit(args ...string) error {
}
}
options := lib.ContainerCommitOptions{
options := types.ContainerCommitOptions{
ContainerID: name,
RepositoryName: repositoryName,
Tag: tag,

View file

@ -7,7 +7,6 @@ import (
"path/filepath"
"strings"
"github.com/docker/docker/api/client/lib"
"github.com/docker/docker/api/types"
Cli "github.com/docker/docker/cli"
"github.com/docker/docker/pkg/archive"
@ -126,7 +125,7 @@ func splitCpArg(arg string) (container, path string) {
}
func (cli *DockerCli) statContainerPath(containerName, path string) (types.ContainerPathStat, error) {
return cli.client.StatContainerPath(containerName, path)
return cli.client.ContainerStatPath(containerName, path)
}
func resolveLocalPath(localPath string) (absPath string, err error) {
@ -286,7 +285,7 @@ func (cli *DockerCli) copyToContainer(srcPath, dstContainer, dstPath string, cpP
content = preparedArchive
}
options := lib.CopyToContainerOptions{
options := types.CopyToContainerOptions{
ContainerID: dstContainer,
Path: resolvedDstPath,
Content: content,

View file

@ -51,13 +51,13 @@ func (cli *DockerCli) pullImageCustomOut(image string, out io.Writer) error {
return err
}
options := lib.CreateImageOptions{
options := types.ImageCreateOptions{
Parent: ref.Name(),
Tag: tag,
RegistryAuth: base64.URLEncoding.EncodeToString(buf),
}
responseBody, err := cli.client.CreateImage(options)
responseBody, err := cli.client.ImageCreate(options)
if err != nil {
return err
}

View file

@ -1,7 +1,7 @@
package client
import (
"github.com/docker/docker/api/client/lib"
"github.com/docker/docker/api/types"
Cli "github.com/docker/docker/cli"
"github.com/docker/docker/opts"
"github.com/docker/docker/pkg/jsonmessage"
@ -34,7 +34,7 @@ func (cli *DockerCli) CmdEvents(args ...string) error {
}
}
options := lib.EventsOptions{
options := types.EventsOptions{
Since: *since,
Until: *until,
Filters: eventFilterArgs,

View file

@ -7,7 +7,7 @@ import (
"time"
"github.com/docker/distribution/reference"
"github.com/docker/docker/api/client/lib"
"github.com/docker/docker/api/types"
Cli "github.com/docker/docker/cli"
"github.com/docker/docker/opts"
flag "github.com/docker/docker/pkg/mflag"
@ -48,7 +48,7 @@ func (cli *DockerCli) CmdImages(args ...string) error {
matchName = cmd.Arg(0)
}
options := lib.ImageListOptions{
options := types.ImageListOptions{
MatchName: matchName,
All: *all,
Filters: imageFilterArgs,

View file

@ -6,7 +6,7 @@ import (
"os"
"github.com/docker/distribution/reference"
"github.com/docker/docker/api/client/lib"
"github.com/docker/docker/api/types"
Cli "github.com/docker/docker/cli"
"github.com/docker/docker/opts"
"github.com/docker/docker/pkg/jsonmessage"
@ -67,7 +67,7 @@ func (cli *DockerCli) CmdImport(args ...string) error {
}
options := lib.ImportImageOptions{
options := types.ImageImportOptions{
Source: in,
SourceName: srcName,
RepositoryName: repository,
@ -76,7 +76,7 @@ func (cli *DockerCli) CmdImport(args ...string) error {
Changes: changes,
}
responseBody, err := cli.client.ImportImage(options)
responseBody, err := cli.client.ImageImport(options)
if err != nil {
return err
}

View file

@ -8,18 +8,6 @@ import (
"github.com/docker/docker/runconfig"
)
// ContainerCommitOptions hods parameters to commit changes into a container.
type ContainerCommitOptions struct {
ContainerID string
RepositoryName string
Tag string
Comment string
Author string
Changes []string
Pause bool
JSONConfig string
}
// ContainerCommit applies changes into a container and creates a new tagged image.
func (cli *Client) ContainerCommit(options types.ContainerCommitOptions) (types.ContainerCommitResponse, error) {
query := url.Values{}

View file

@ -9,20 +9,8 @@ import (
"github.com/docker/docker/pkg/parsers/filters"
)
// ContainerListOptions holds parameters to list containers with.
type ContainerListOptions struct {
Quiet bool
Size bool
All bool
Latest bool
Since string
Before string
Limit int
Filter filters.Args
}
// ContainerList returns the list of containers in the docker host.
func (cli *Client) ContainerList(options ContainerListOptions) ([]types.Container, error) {
func (cli *Client) ContainerList(options types.ContainerListOptions) ([]types.Container, error) {
var query url.Values
if options.All {

View file

@ -1,17 +1,13 @@
package lib
import "net/url"
import (
"net/url"
// ContainerRemoveOptions holds parameters to remove containers.
type ContainerRemoveOptions struct {
ContainerID string
RemoveVolumes bool
RemoveLinks bool
Force bool
}
"github.com/docker/docker/api/types"
)
// ContainerRemove kills and removes a container from the docker host.
func (cli *Client) ContainerRemove(options ContainerRemoveOptions) error {
func (cli *Client) ContainerRemove(options types.ContainerRemoveOptions) error {
var query url.Values
if options.RemoveVolumes {
query.Set("v", "1")

View file

@ -13,17 +13,8 @@ import (
"github.com/docker/docker/api/types"
)
// CopyToContainerOptions holds information
// about files to copy into a container
type CopyToContainerOptions struct {
ContainerID string
Path string
Content io.Reader
AllowOverwriteDirWithFile bool
}
// StatContainerPath returns Stat information about a path inside the container filesystem.
func (cli *Client) StatContainerPath(containerID, path string) (types.ContainerPathStat, error) {
// ContainerStatPath returns Stat information about a path inside the container filesystem.
func (cli *Client) ContainerStatPath(containerID, path string) (types.ContainerPathStat, error) {
query := make(url.Values, 1)
query.Set("path", filepath.ToSlash(path)) // Normalize the paths used in the API.
@ -37,7 +28,7 @@ func (cli *Client) StatContainerPath(containerID, path string) (types.ContainerP
}
// CopyToContainer copies content into the container filesystem.
func (cli *Client) CopyToContainer(options CopyToContainerOptions) error {
func (cli *Client) CopyToContainer(options types.CopyToContainerOptions) error {
var query url.Values
query.Set("path", filepath.ToSlash(options.Path)) // Normalize the paths used in the API.
// Do not allow for an existing directory to be overwritten by a non-directory and vice versa.

View file

@ -5,20 +5,14 @@ import (
"net/url"
"time"
"github.com/docker/docker/api/types"
"github.com/docker/docker/pkg/parsers/filters"
"github.com/docker/docker/pkg/timeutils"
)
// EventsOptions hold parameters to filter events with.
type EventsOptions struct {
Since string
Until string
Filters filters.Args
}
// Events returns a stream of events in the daemon in a ReadCloser.
// It's up to the caller to close the stream.
func (cli *Client) Events(options EventsOptions) (io.ReadCloser, error) {
func (cli *Client) Events(options types.EventsOptions) (io.ReadCloser, error) {
var query url.Values
ref := time.Now()

View file

@ -3,73 +3,36 @@ package lib
import (
"encoding/base64"
"encoding/json"
"io"
"net/http"
"net/url"
"strconv"
"github.com/docker/docker/cliconfig"
"github.com/docker/docker/api/types"
"github.com/docker/docker/pkg/httputils"
"github.com/docker/docker/pkg/ulimit"
"github.com/docker/docker/pkg/units"
"github.com/docker/docker/runconfig"
)
// ImageBuildOptions holds the information
// necessary to build images.
type ImageBuildOptions struct {
Tags []string
SuppressOutput bool
RemoteContext string
NoCache bool
Remove bool
ForceRemove bool
PullParent bool
Isolation string
CPUSetCPUs string
CPUSetMems string
CPUShares int64
CPUQuota int64
CPUPeriod int64
Memory int64
MemorySwap int64
CgroupParent string
ShmSize string
Dockerfile string
Ulimits []*ulimit.Ulimit
BuildArgs []string
AuthConfigs map[string]cliconfig.AuthConfig
Context io.Reader
}
// ImageBuildResponse holds information
// returned by a server after building
// an image.
type ImageBuildResponse struct {
Body io.ReadCloser
OSType string
}
// ImageBuild sends request to the daemon to build images.
// The Body in the response implement an io.ReadCloser and it's up to the caller to
// close it.
func (cli *Client) ImageBuild(options ImageBuildOptions) (ImageBuildResponse, error) {
func (cli *Client) ImageBuild(options types.ImageBuildOptions) (types.ImageBuildResponse, error) {
query, err := imageBuildOptionsToQuery(options)
if err != nil {
return ImageBuildResponse{}, err
return types.ImageBuildResponse{}, err
}
headers := http.Header(make(map[string][]string))
buf, err := json.Marshal(options.AuthConfigs)
if err != nil {
return ImageBuildResponse{}, err
return types.ImageBuildResponse{}, err
}
headers.Add("X-Registry-Config", base64.URLEncoding.EncodeToString(buf))
headers.Set("Content-Type", "application/tar")
serverResp, err := cli.POSTRaw("/build", query, options.Context, headers)
if err != nil {
return ImageBuildResponse{}, err
return types.ImageBuildResponse{}, err
}
var osType string
@ -77,13 +40,13 @@ func (cli *Client) ImageBuild(options ImageBuildOptions) (ImageBuildResponse, er
osType = h.OS
}
return ImageBuildResponse{
return types.ImageBuildResponse{
Body: serverResp.body,
OSType: osType,
}, nil
}
func imageBuildOptionsToQuery(options ImageBuildOptions) (url.Values, error) {
func imageBuildOptionsToQuery(options types.ImageBuildOptions) (url.Values, error) {
query := url.Values{
"t": options.Tags,
}

View file

@ -3,21 +3,13 @@ package lib
import (
"io"
"net/url"
"github.com/docker/docker/api/types"
)
// CreateImageOptions holds information to create images.
type CreateImageOptions struct {
// Parent is the image to create this image from
Parent string
// Tag is the name to tag this image
Tag string
// RegistryAuth is the base64 encoded credentials for this server
RegistryAuth string
}
// CreateImage creates a new image based in the parent options.
// ImageCreate creates a new image based in the parent options.
// It returns the JSON content in the response body.
func (cli *Client) CreateImage(options CreateImageOptions) (io.ReadCloser, error) {
func (cli *Client) ImageCreate(options types.ImageCreateOptions) (io.ReadCloser, error) {
var query url.Values
query.Set("fromImage", options.Parent)
query.Set("tag", options.Tag)

View file

@ -3,27 +3,13 @@ package lib
import (
"io"
"net/url"
"github.com/docker/docker/api/types"
)
// ImportImageOptions holds information to import images from the client host.
type ImportImageOptions struct {
// Source is the data to send to the server to create this image from
Source io.Reader
// Source is the name of the source to import this image from
SourceName string
// RepositoryName is the name of the repository to import this image
RepositoryName string
// Message is the message to tag the image with
Message string
// Tag is the name to tag this image
Tag string
// Changes are the raw changes to apply to the image
Changes []string
}
// ImportImage creates a new image based in the source options.
// ImageImport creates a new image based in the source options.
// It returns the JSON content in the response body.
func (cli *Client) ImportImage(options ImportImageOptions) (io.ReadCloser, error) {
func (cli *Client) ImageImport(options types.ImageImportOptions) (io.ReadCloser, error) {
var query url.Values
query.Set("fromSrc", options.SourceName)
query.Set("repo", options.RepositoryName)

View file

@ -8,15 +8,8 @@ import (
"github.com/docker/docker/pkg/parsers/filters"
)
// ImageListOptions holds parameters to filter the list of images with.
type ImageListOptions struct {
MatchName string
All bool
Filters filters.Args
}
// ImageList returns a list of images in the docker host.
func (cli *Client) ImageList(options ImageListOptions) ([]types.Image, error) {
func (cli *Client) ImageList(options types.ImageListOptions) ([]types.Image, error) {
var (
images []types.Image
query url.Values

View file

@ -7,15 +7,8 @@ import (
"github.com/docker/docker/api/types"
)
// ImageRemoveOptions holds parameters to remove images.
type ImageRemoveOptions struct {
ImageID string
Force bool
PruneChildren bool
}
// ImageRemove removes an image from the docker host.
func (cli *Client) ImageRemove(options ImageRemoveOptions) ([]types.ImageDelete, error) {
func (cli *Client) ImageRemove(options types.ImageRemoveOptions) ([]types.ImageDelete, error) {
var query url.Values
if options.Force {

View file

@ -1,14 +1,10 @@
package lib
import "net/url"
import (
"net/url"
// ImageTagOptions hold parameters to tag an image
type ImageTagOptions struct {
ImageID string
RepositoryName string
Tag string
Force bool
}
"github.com/docker/docker/api/types"
)
// ImageTag tags an image in the docker host
func (cli *Client) ImageTag(options types.ImageTagOptions) error {

View file

@ -5,23 +5,13 @@ import (
"net/url"
"time"
"github.com/docker/docker/api/types"
"github.com/docker/docker/pkg/timeutils"
)
// ContainerLogsOptions holds parameters to filter logs with.
type ContainerLogsOptions struct {
ContainerID string
ShowStdout bool
ShowStderr bool
Since string
Timestamps bool
Follow bool
Tail string
}
// ContainerLogs returns the logs generated by a container in an io.ReadCloser.
// It's up to the caller to close the stream.
func (cli *Client) ContainerLogs(options ContainerLogsOptions) (io.ReadCloser, error) {
func (cli *Client) ContainerLogs(options types.ContainerLogsOptions) (io.ReadCloser, error) {
var query url.Values
if options.ShowStdout {
query.Set("stdout", "1")

View file

@ -10,20 +10,8 @@ import (
"github.com/docker/docker/utils"
)
// VersionResponse holds version information for the client and the server
type VersionResponse struct {
Client *types.Version
Server *types.Version
}
// ServerOK return true when the client could connect to the docker server
// and parse the information received. It returns false otherwise.
func (v VersionResponse) ServerOK() bool {
return v.Server == nil
}
// SystemVersion returns information of the docker client and server host.
func (cli *Client) SystemVersion() (VersionResponse, error) {
func (cli *Client) SystemVersion() (types.VersionResponse, error) {
client := &types.Version{
Version: dockerversion.Version,
APIVersion: api.Version,
@ -37,14 +25,14 @@ func (cli *Client) SystemVersion() (VersionResponse, error) {
resp, err := cli.GET("/version", nil, nil)
if err != nil {
return VersionResponse{Client: client}, err
return types.VersionResponse{Client: client}, err
}
defer ensureReaderClosed(resp)
var server types.Version
err = json.NewDecoder(resp.body).Decode(&server)
if err != nil {
return VersionResponse{Client: client}, err
return types.VersionResponse{Client: client}, err
}
return types.VersionResponse{Client: client, Server: &server}, nil
}

View file

@ -4,7 +4,7 @@ import (
"fmt"
"io"
"github.com/docker/docker/api/client/lib"
"github.com/docker/docker/api/types"
Cli "github.com/docker/docker/cli"
flag "github.com/docker/docker/pkg/mflag"
"github.com/docker/docker/pkg/stdcopy"
@ -39,7 +39,7 @@ func (cli *DockerCli) CmdLogs(args ...string) error {
return fmt.Errorf("\"logs\" command is supported only for \"json-file\" and \"journald\" logging drivers (got: %s)", c.HostConfig.LogConfig.Type)
}
options := lib.ContainerLogsOptions{
options := types.ContainerLogsOptions{
ContainerID: name,
ShowStdout: true,
ShowStderr: true,

View file

@ -1,8 +1,8 @@
package client
import (
"github.com/docker/docker/api/client/lib"
"github.com/docker/docker/api/client/ps"
"github.com/docker/docker/api/types"
Cli "github.com/docker/docker/cli"
"github.com/docker/docker/opts"
flag "github.com/docker/docker/pkg/mflag"
@ -47,7 +47,7 @@ func (cli *DockerCli) CmdPs(args ...string) error {
}
}
options := lib.ContainerListOptions{
options := types.ContainerListOptions{
All: *all,
Limit: *last,
Since: *since,

View file

@ -4,7 +4,7 @@ import (
"fmt"
"strings"
"github.com/docker/docker/api/client/lib"
"github.com/docker/docker/api/types"
Cli "github.com/docker/docker/cli"
flag "github.com/docker/docker/pkg/mflag"
)
@ -28,7 +28,7 @@ func (cli *DockerCli) CmdRm(args ...string) error {
}
name = strings.Trim(name, "/")
options := lib.ContainerRemoveOptions{
options := types.ContainerRemoveOptions{
ContainerID: name,
RemoveVolumes: *v,
RemoveLinks: *link,

View file

@ -4,7 +4,7 @@ import (
"fmt"
"net/url"
"github.com/docker/docker/api/client/lib"
"github.com/docker/docker/api/types"
Cli "github.com/docker/docker/cli"
flag "github.com/docker/docker/pkg/mflag"
)
@ -30,7 +30,7 @@ func (cli *DockerCli) CmdRmi(args ...string) error {
var errNames []string
for _, name := range cmd.Args() {
options := lib.ImageRemoveOptions{
options := types.ImageRemoveOptions{
ImageID: name,
Force: *force,
PruneChildren: !*noprune,

View file

@ -4,7 +4,7 @@ import (
"errors"
"github.com/docker/distribution/reference"
"github.com/docker/docker/api/client/lib"
"github.com/docker/docker/api/types"
Cli "github.com/docker/docker/cli"
flag "github.com/docker/docker/pkg/mflag"
"github.com/docker/docker/registry"
@ -41,7 +41,7 @@ func (cli *DockerCli) CmdTag(args ...string) error {
return err
}
options := lib.ImageTagOptions{
options := types.ImageTagOptions{
ImageID: cmd.Arg(0),
RepositoryName: ref.Name(),
Tag: tag,

View file

@ -22,7 +22,7 @@ import (
"github.com/docker/distribution/reference"
"github.com/docker/distribution/registry/client/auth"
"github.com/docker/distribution/registry/client/transport"
"github.com/docker/docker/api/client/lib"
"github.com/docker/docker/api/types"
"github.com/docker/docker/cliconfig"
"github.com/docker/docker/pkg/ansiescape"
"github.com/docker/docker/pkg/ioutils"
@ -252,7 +252,7 @@ func (cli *DockerCli) trustedReference(ref reference.NamedTagged) (reference.Can
func (cli *DockerCli) tagTrusted(trustedRef reference.Canonical, ref reference.NamedTagged) error {
fmt.Fprintf(cli.out, "Tagging %s as %s\n", trustedRef.String(), ref.String())
options := lib.ImageTagOptions{
options := types.ImageTagOptions{
ImageID: trustedRef.String(),
RepositoryName: trustedRef.Name(),
Tag: ref.Tag(),

163
api/types/client.go Normal file
View file

@ -0,0 +1,163 @@
package types
import (
"io"
"github.com/docker/docker/cliconfig"
"github.com/docker/docker/pkg/parsers/filters"
"github.com/docker/docker/pkg/ulimit"
)
// ContainerCommitOptions hods parameters to commit changes into a container.
type ContainerCommitOptions struct {
ContainerID string
RepositoryName string
Tag string
Comment string
Author string
Changes []string
Pause bool
JSONConfig string
}
// ContainerListOptions holds parameters to list containers with.
type ContainerListOptions struct {
Quiet bool
Size bool
All bool
Latest bool
Since string
Before string
Limit int
Filter filters.Args
}
// ContainerLogsOptions holds parameters to filter logs with.
type ContainerLogsOptions struct {
ContainerID string
ShowStdout bool
ShowStderr bool
Since string
Timestamps bool
Follow bool
Tail string
}
// ContainerRemoveOptions holds parameters to remove containers.
type ContainerRemoveOptions struct {
ContainerID string
RemoveVolumes bool
RemoveLinks bool
Force bool
}
// CopyToContainerOptions holds information
// about files to copy into a container
type CopyToContainerOptions struct {
ContainerID string
Path string
Content io.Reader
AllowOverwriteDirWithFile bool
}
// EventsOptions hold parameters to filter events with.
type EventsOptions struct {
Since string
Until string
Filters filters.Args
}
// ImageBuildOptions holds the information
// necessary to build images.
type ImageBuildOptions struct {
Tags []string
SuppressOutput bool
RemoteContext string
NoCache bool
Remove bool
ForceRemove bool
PullParent bool
Isolation string
CPUSetCPUs string
CPUSetMems string
CPUShares int64
CPUQuota int64
CPUPeriod int64
Memory int64
MemorySwap int64
CgroupParent string
ShmSize string
Dockerfile string
Ulimits []*ulimit.Ulimit
BuildArgs []string
AuthConfigs map[string]cliconfig.AuthConfig
Context io.Reader
}
// ImageBuildResponse holds information
// returned by a server after building
// an image.
type ImageBuildResponse struct {
Body io.ReadCloser
OSType string
}
// ImageCreateOptions holds information to create images.
type ImageCreateOptions struct {
// Parent is the image to create this image from
Parent string
// Tag is the name to tag this image
Tag string
// RegistryAuth is the base64 encoded credentials for this server
RegistryAuth string
}
// ImageImportOptions holds information to import images from the client host.
type ImageImportOptions struct {
// Source is the data to send to the server to create this image from
Source io.Reader
// Source is the name of the source to import this image from
SourceName string
// RepositoryName is the name of the repository to import this image
RepositoryName string
// Message is the message to tag the image with
Message string
// Tag is the name to tag this image
Tag string
// Changes are the raw changes to apply to the image
Changes []string
}
// ImageListOptions holds parameters to filter the list of images with.
type ImageListOptions struct {
MatchName string
All bool
Filters filters.Args
}
// ImageRemoveOptions holds parameters to remove images.
type ImageRemoveOptions struct {
ImageID string
Force bool
PruneChildren bool
}
// ImageTagOptions hold parameters to tag an image
type ImageTagOptions struct {
ImageID string
RepositoryName string
Tag string
Force bool
}
// VersionResponse holds version information for the client and the server
type VersionResponse struct {
Client *Version
Server *Version
}
// ServerOK return true when the client could connect to the docker server
// and parse the information received. It returns false otherwise.
func (v VersionResponse) ServerOK() bool {
return v.Server != nil
}