2018-02-05 16:05:59 -05:00
|
|
|
package types // import "github.com/docker/docker/api/types"
|
2016-09-06 14:18:12 -04:00
|
|
|
|
|
|
|
import (
|
|
|
|
"bufio"
|
|
|
|
"io"
|
|
|
|
"net"
|
|
|
|
|
|
|
|
"github.com/docker/docker/api/types/container"
|
|
|
|
"github.com/docker/docker/api/types/filters"
|
2018-07-02 22:31:05 -04:00
|
|
|
units "github.com/docker/go-units"
|
2016-09-06 14:18:12 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
// CheckpointCreateOptions holds parameters to create a checkpoint from a container
|
|
|
|
type CheckpointCreateOptions struct {
|
2016-09-19 12:01:16 -04:00
|
|
|
CheckpointID string
|
|
|
|
CheckpointDir string
|
|
|
|
Exit bool
|
|
|
|
}
|
|
|
|
|
|
|
|
// CheckpointListOptions holds parameters to list checkpoints for a container
|
|
|
|
type CheckpointListOptions struct {
|
|
|
|
CheckpointDir string
|
|
|
|
}
|
|
|
|
|
|
|
|
// CheckpointDeleteOptions holds parameters to delete a checkpoint from a container
|
|
|
|
type CheckpointDeleteOptions struct {
|
|
|
|
CheckpointID string
|
|
|
|
CheckpointDir string
|
2016-09-06 14:18:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// ContainerAttachOptions holds parameters to attach to a container.
|
|
|
|
type ContainerAttachOptions struct {
|
|
|
|
Stream bool
|
|
|
|
Stdin bool
|
|
|
|
Stdout bool
|
|
|
|
Stderr bool
|
|
|
|
DetachKeys string
|
2016-09-19 14:55:52 -04:00
|
|
|
Logs bool
|
2016-09-06 14:18:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// ContainerCommitOptions holds parameters to commit changes into a container.
|
|
|
|
type ContainerCommitOptions struct {
|
|
|
|
Reference string
|
|
|
|
Comment string
|
|
|
|
Author string
|
|
|
|
Changes []string
|
|
|
|
Pause bool
|
|
|
|
Config *container.Config
|
|
|
|
}
|
|
|
|
|
|
|
|
// ContainerExecInspect holds information returned by exec inspect.
|
|
|
|
type ContainerExecInspect struct {
|
2020-02-07 17:01:37 -05:00
|
|
|
ExecID string `json:"ID"`
|
2016-09-06 14:18:12 -04:00
|
|
|
ContainerID string
|
|
|
|
Running bool
|
|
|
|
ExitCode int
|
2016-10-17 13:49:36 -04:00
|
|
|
Pid int
|
2016-09-06 14:18:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// ContainerListOptions holds parameters to list containers with.
|
|
|
|
type ContainerListOptions struct {
|
2016-11-01 10:01:16 -04:00
|
|
|
Size bool
|
|
|
|
All bool
|
|
|
|
Latest bool
|
|
|
|
Since string
|
|
|
|
Before string
|
|
|
|
Limit int
|
|
|
|
Filters filters.Args
|
2016-09-06 14:18:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// ContainerLogsOptions holds parameters to filter logs with.
|
|
|
|
type ContainerLogsOptions struct {
|
|
|
|
ShowStdout bool
|
|
|
|
ShowStderr bool
|
|
|
|
Since string
|
2017-04-28 07:53:00 -04:00
|
|
|
Until string
|
2016-09-06 14:18:12 -04:00
|
|
|
Timestamps bool
|
|
|
|
Follow bool
|
|
|
|
Tail string
|
|
|
|
Details bool
|
|
|
|
}
|
|
|
|
|
|
|
|
// ContainerRemoveOptions holds parameters to remove containers.
|
|
|
|
type ContainerRemoveOptions struct {
|
|
|
|
RemoveVolumes bool
|
|
|
|
RemoveLinks bool
|
|
|
|
Force bool
|
|
|
|
}
|
|
|
|
|
|
|
|
// ContainerStartOptions holds parameters to start containers.
|
|
|
|
type ContainerStartOptions struct {
|
2016-09-19 12:01:16 -04:00
|
|
|
CheckpointID string
|
|
|
|
CheckpointDir string
|
2016-09-06 14:18:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// CopyToContainerOptions holds information
|
|
|
|
// about files to copy into a container
|
|
|
|
type CopyToContainerOptions struct {
|
|
|
|
AllowOverwriteDirWithFile bool
|
2016-11-14 08:37:08 -05:00
|
|
|
CopyUIDGID bool
|
2016-09-06 14:18:12 -04:00
|
|
|
}
|
|
|
|
|
2016-09-24 11:17:18 -04:00
|
|
|
// EventsOptions holds parameters to filter events with.
|
2016-09-06 14:18:12 -04:00
|
|
|
type EventsOptions struct {
|
|
|
|
Since string
|
|
|
|
Until string
|
|
|
|
Filters filters.Args
|
|
|
|
}
|
|
|
|
|
|
|
|
// NetworkListOptions holds parameters to filter the list of networks with.
|
|
|
|
type NetworkListOptions struct {
|
|
|
|
Filters filters.Args
|
|
|
|
}
|
|
|
|
|
2019-08-28 07:46:32 -04:00
|
|
|
// NewHijackedResponse intializes a HijackedResponse type
|
|
|
|
func NewHijackedResponse(conn net.Conn, mediaType string) HijackedResponse {
|
|
|
|
return HijackedResponse{Conn: conn, Reader: bufio.NewReader(conn), mediaType: mediaType}
|
|
|
|
}
|
|
|
|
|
2016-09-06 14:18:12 -04:00
|
|
|
// HijackedResponse holds connection information for a hijacked request.
|
|
|
|
type HijackedResponse struct {
|
2019-08-28 07:46:32 -04:00
|
|
|
mediaType string
|
|
|
|
Conn net.Conn
|
|
|
|
Reader *bufio.Reader
|
2016-09-06 14:18:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Close closes the hijacked connection and reader.
|
|
|
|
func (h *HijackedResponse) Close() {
|
|
|
|
h.Conn.Close()
|
|
|
|
}
|
|
|
|
|
2019-08-28 07:46:32 -04:00
|
|
|
// MediaType let client know if HijackedResponse hold a raw or multiplexed stream.
|
|
|
|
// returns false if HTTP Content-Type is not relevant, and container must be inspected
|
|
|
|
func (h *HijackedResponse) MediaType() (string, bool) {
|
|
|
|
if h.mediaType == "" {
|
|
|
|
return "", false
|
|
|
|
}
|
|
|
|
return h.mediaType, true
|
|
|
|
}
|
|
|
|
|
2016-09-06 14:18:12 -04:00
|
|
|
// CloseWriter is an interface that implements structs
|
|
|
|
// that close input streams to prevent from writing.
|
|
|
|
type CloseWriter interface {
|
|
|
|
CloseWrite() error
|
|
|
|
}
|
|
|
|
|
|
|
|
// CloseWrite closes a readWriter for writing.
|
|
|
|
func (h *HijackedResponse) CloseWrite() error {
|
|
|
|
if conn, ok := h.Conn.(CloseWriter); ok {
|
|
|
|
return conn.CloseWrite()
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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 container.Isolation
|
|
|
|
CPUSetCPUs string
|
|
|
|
CPUSetMems string
|
|
|
|
CPUShares int64
|
|
|
|
CPUQuota int64
|
|
|
|
CPUPeriod int64
|
|
|
|
Memory int64
|
|
|
|
MemorySwap int64
|
|
|
|
CgroupParent string
|
2016-03-06 07:29:23 -05:00
|
|
|
NetworkMode string
|
2016-09-06 14:18:12 -04:00
|
|
|
ShmSize int64
|
|
|
|
Dockerfile string
|
|
|
|
Ulimits []*units.Ulimit
|
2017-02-20 22:17:52 -05:00
|
|
|
// BuildArgs needs to be a *string instead of just a string so that
|
|
|
|
// we can tell the difference between "" (empty string) and no value
|
|
|
|
// at all (nil). See the parsing of buildArgs in
|
|
|
|
// api/server/router/build/build_routes.go for even more info.
|
2016-12-03 08:46:04 -05:00
|
|
|
BuildArgs map[string]*string
|
|
|
|
AuthConfigs map[string]AuthConfig
|
|
|
|
Context io.Reader
|
|
|
|
Labels map[string]string
|
2016-09-06 14:18:12 -04:00
|
|
|
// squash the resulting image's layers to the parent
|
|
|
|
// preserves the original image and creates a new one from the parent with all
|
|
|
|
// the changes applied to a single layer
|
|
|
|
Squash bool
|
2016-09-22 17:38:00 -04:00
|
|
|
// CacheFrom specifies images that are used for matching cache. Images
|
|
|
|
// specified here do not need to have a valid parent chain to match cache.
|
2016-06-07 15:15:50 -04:00
|
|
|
CacheFrom []string
|
|
|
|
SecurityOpt []string
|
2017-01-13 10:01:58 -05:00
|
|
|
ExtraHosts []string // List of extra hosts
|
2017-04-10 18:27:42 -04:00
|
|
|
Target string
|
2017-05-15 15:59:15 -04:00
|
|
|
SessionID string
|
2018-07-02 22:31:05 -04:00
|
|
|
Platform string
|
2018-05-25 18:18:24 -04:00
|
|
|
// Version specifies the version of the unerlying builder to use
|
|
|
|
Version BuilderVersion
|
|
|
|
// BuildID is an optional identifier that can be passed together with the
|
|
|
|
// build request. The same identifier can be used to gracefully cancel the
|
|
|
|
// build with the cancel request.
|
|
|
|
BuildID string
|
2019-03-17 12:54:52 -04:00
|
|
|
// Outputs defines configurations for exporting build results. Only supported
|
|
|
|
// in BuildKit mode
|
|
|
|
Outputs []ImageBuildOutput
|
|
|
|
}
|
|
|
|
|
|
|
|
// ImageBuildOutput defines configuration for exporting a build result
|
|
|
|
type ImageBuildOutput struct {
|
|
|
|
Type string
|
|
|
|
Attrs map[string]string
|
2016-09-06 14:18:12 -04:00
|
|
|
}
|
|
|
|
|
2018-05-18 01:47:34 -04:00
|
|
|
// BuilderVersion sets the version of underlying builder to use
|
|
|
|
type BuilderVersion string
|
|
|
|
|
|
|
|
const (
|
2018-05-23 18:53:14 -04:00
|
|
|
// BuilderV1 is the first generation builder in docker daemon
|
|
|
|
BuilderV1 BuilderVersion = "1"
|
|
|
|
// BuilderBuildKit is builder based on moby/buildkit project
|
2019-10-13 08:34:29 -04:00
|
|
|
BuilderBuildKit BuilderVersion = "2"
|
2018-05-18 01:47:34 -04:00
|
|
|
)
|
|
|
|
|
2016-09-06 14:18:12 -04:00
|
|
|
// 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 {
|
2017-09-13 15:49:04 -04:00
|
|
|
RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry.
|
|
|
|
Platform string // Platform is the target platform of the image if it needs to be pulled from the registry.
|
2016-09-06 14:18:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// ImageImportSource holds source information for ImageImport
|
|
|
|
type ImageImportSource struct {
|
2016-11-01 00:07:36 -04:00
|
|
|
Source io.Reader // Source is the data to send to the server to create this image from. You must set SourceName to "-" to leverage this.
|
|
|
|
SourceName string // SourceName is the name of the image to pull. Set to "-" to leverage the Source attribute.
|
2016-09-06 14:18:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// ImageImportOptions holds information to import images from the client host.
|
|
|
|
type ImageImportOptions struct {
|
2017-09-13 15:49:04 -04:00
|
|
|
Tag string // Tag is the name to tag this image with. This attribute is deprecated.
|
|
|
|
Message string // Message is the message to tag the image with
|
|
|
|
Changes []string // Changes are the raw changes to apply to this image
|
|
|
|
Platform string // Platform is the target platform of the image
|
2016-09-06 14:18:12 -04:00
|
|
|
}
|
|
|
|
|
2021-06-22 13:09:58 -04:00
|
|
|
// ImageListOptions holds parameters to list images with.
|
2016-09-06 14:18:12 -04:00
|
|
|
type ImageListOptions struct {
|
2021-06-22 13:09:58 -04:00
|
|
|
// All controls whether all images in the graph are filtered, or just
|
|
|
|
// the heads.
|
|
|
|
All bool
|
|
|
|
|
|
|
|
// Filters is a JSON-encoded set of filter arguments.
|
2016-11-11 09:34:01 -05:00
|
|
|
Filters filters.Args
|
2021-06-22 13:09:58 -04:00
|
|
|
|
|
|
|
// SharedSize indicates whether the shared size of images should be computed.
|
|
|
|
SharedSize bool
|
|
|
|
|
|
|
|
// ContainerCount indicates whether container count should be computed.
|
|
|
|
ContainerCount bool
|
2016-09-06 14:18:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// ImageLoadResponse returns information to the client about a load process.
|
|
|
|
type ImageLoadResponse struct {
|
|
|
|
// Body must be closed to avoid a resource leak
|
|
|
|
Body io.ReadCloser
|
|
|
|
JSON bool
|
|
|
|
}
|
|
|
|
|
|
|
|
// ImagePullOptions holds information to pull images.
|
|
|
|
type ImagePullOptions struct {
|
|
|
|
All bool
|
|
|
|
RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry
|
|
|
|
PrivilegeFunc RequestPrivilegeFunc
|
2017-09-13 15:49:04 -04:00
|
|
|
Platform string
|
2016-09-06 14:18:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// RequestPrivilegeFunc is a function interface that
|
|
|
|
// clients can supply to retry operations after
|
|
|
|
// getting an authorization error.
|
|
|
|
// This function returns the registry authentication
|
|
|
|
// header value in base 64 format, or an error
|
|
|
|
// if the privilege request fails.
|
|
|
|
type RequestPrivilegeFunc func() (string, error)
|
|
|
|
|
2019-11-27 09:37:30 -05:00
|
|
|
// ImagePushOptions holds information to push images.
|
2016-09-06 14:18:12 -04:00
|
|
|
type ImagePushOptions ImagePullOptions
|
|
|
|
|
|
|
|
// ImageRemoveOptions holds parameters to remove images.
|
|
|
|
type ImageRemoveOptions struct {
|
|
|
|
Force bool
|
|
|
|
PruneChildren bool
|
|
|
|
}
|
|
|
|
|
|
|
|
// ImageSearchOptions holds parameters to search images with.
|
|
|
|
type ImageSearchOptions struct {
|
|
|
|
RegistryAuth string
|
|
|
|
PrivilegeFunc RequestPrivilegeFunc
|
|
|
|
Filters filters.Args
|
|
|
|
Limit int
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResizeOptions holds parameters to resize a tty.
|
|
|
|
// It can be used to resize container ttys and
|
|
|
|
// exec process ttys too.
|
|
|
|
type ResizeOptions struct {
|
2016-09-14 14:55:07 -04:00
|
|
|
Height uint
|
|
|
|
Width uint
|
2016-09-06 14:18:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// NodeListOptions holds parameters to list nodes with.
|
|
|
|
type NodeListOptions struct {
|
2016-11-01 10:01:16 -04:00
|
|
|
Filters filters.Args
|
2016-09-06 14:18:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// NodeRemoveOptions holds parameters to remove nodes with.
|
|
|
|
type NodeRemoveOptions struct {
|
|
|
|
Force bool
|
|
|
|
}
|
|
|
|
|
|
|
|
// ServiceCreateOptions contains the options to use when creating a service.
|
|
|
|
type ServiceCreateOptions struct {
|
|
|
|
// EncodedRegistryAuth is the encoded registry authorization credentials to
|
|
|
|
// use when updating the service.
|
|
|
|
//
|
|
|
|
// This field follows the format of the X-Registry-Auth header.
|
|
|
|
EncodedRegistryAuth string
|
2017-04-05 18:43:17 -04:00
|
|
|
|
|
|
|
// QueryRegistry indicates whether the service update requires
|
|
|
|
// contacting a registry. A registry may be contacted to retrieve
|
|
|
|
// the image digest and manifest, which in turn can be used to update
|
|
|
|
// platform or other information about the service.
|
|
|
|
QueryRegistry bool
|
2016-09-06 14:18:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// ServiceCreateResponse contains the information returned to a client
|
2016-11-14 21:08:24 -05:00
|
|
|
// on the creation of a new service.
|
2016-09-06 14:18:12 -04:00
|
|
|
type ServiceCreateResponse struct {
|
|
|
|
// ID is the ID of the created service.
|
|
|
|
ID string
|
2016-11-14 21:08:24 -05:00
|
|
|
// Warnings is a set of non-fatal warning messages to pass on to the user.
|
|
|
|
Warnings []string `json:",omitempty"`
|
2016-09-06 14:18:12 -04:00
|
|
|
}
|
|
|
|
|
2016-09-07 19:32:44 -04:00
|
|
|
// Values for RegistryAuthFrom in ServiceUpdateOptions
|
|
|
|
const (
|
|
|
|
RegistryAuthFromSpec = "spec"
|
|
|
|
RegistryAuthFromPreviousSpec = "previous-spec"
|
|
|
|
)
|
|
|
|
|
2016-09-06 14:18:12 -04:00
|
|
|
// ServiceUpdateOptions contains the options to be used for updating services.
|
|
|
|
type ServiceUpdateOptions struct {
|
|
|
|
// EncodedRegistryAuth is the encoded registry authorization credentials to
|
|
|
|
// use when updating the service.
|
|
|
|
//
|
|
|
|
// This field follows the format of the X-Registry-Auth header.
|
|
|
|
EncodedRegistryAuth string
|
|
|
|
|
|
|
|
// TODO(stevvooe): Consider moving the version parameter of ServiceUpdate
|
|
|
|
// into this field. While it does open API users up to racy writes, most
|
|
|
|
// users may not need that level of consistency in practice.
|
2016-09-07 19:32:44 -04:00
|
|
|
|
|
|
|
// RegistryAuthFrom specifies where to find the registry authorization
|
|
|
|
// credentials if they are not given in EncodedRegistryAuth. Valid
|
|
|
|
// values are "spec" and "previous-spec".
|
|
|
|
RegistryAuthFrom string
|
2017-02-16 12:27:01 -05:00
|
|
|
|
|
|
|
// Rollback indicates whether a server-side rollback should be
|
|
|
|
// performed. When this is set, the provided spec will be ignored.
|
|
|
|
// The valid values are "previous" and "none". An empty value is the
|
|
|
|
// same as "none".
|
|
|
|
Rollback string
|
2017-04-05 18:43:17 -04:00
|
|
|
|
|
|
|
// QueryRegistry indicates whether the service update requires
|
|
|
|
// contacting a registry. A registry may be contacted to retrieve
|
|
|
|
// the image digest and manifest, which in turn can be used to update
|
|
|
|
// platform or other information about the service.
|
|
|
|
QueryRegistry bool
|
2016-09-06 14:18:12 -04:00
|
|
|
}
|
|
|
|
|
2017-03-30 20:15:54 -04:00
|
|
|
// ServiceListOptions holds parameters to list services with.
|
2016-09-06 14:18:12 -04:00
|
|
|
type ServiceListOptions struct {
|
2016-11-01 10:01:16 -04:00
|
|
|
Filters filters.Args
|
2019-05-16 18:43:48 -04:00
|
|
|
|
|
|
|
// Status indicates whether the server should include the service task
|
|
|
|
// count of running and desired tasks.
|
|
|
|
Status bool
|
2016-09-06 14:18:12 -04:00
|
|
|
}
|
|
|
|
|
2017-03-30 20:15:54 -04:00
|
|
|
// ServiceInspectOptions holds parameters related to the "service inspect"
|
|
|
|
// operation.
|
|
|
|
type ServiceInspectOptions struct {
|
|
|
|
InsertDefaults bool
|
|
|
|
}
|
|
|
|
|
|
|
|
// TaskListOptions holds parameters to list tasks with.
|
2016-09-06 14:18:12 -04:00
|
|
|
type TaskListOptions struct {
|
2016-11-01 10:01:16 -04:00
|
|
|
Filters filters.Args
|
2016-09-06 14:18:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// PluginRemoveOptions holds parameters to remove plugins.
|
|
|
|
type PluginRemoveOptions struct {
|
|
|
|
Force bool
|
|
|
|
}
|
2016-10-05 16:25:09 -04:00
|
|
|
|
2016-11-21 12:24:01 -05:00
|
|
|
// PluginEnableOptions holds parameters to enable plugins.
|
|
|
|
type PluginEnableOptions struct {
|
|
|
|
Timeout int
|
|
|
|
}
|
|
|
|
|
2016-12-20 11:26:58 -05:00
|
|
|
// PluginDisableOptions holds parameters to disable plugins.
|
|
|
|
type PluginDisableOptions struct {
|
|
|
|
Force bool
|
|
|
|
}
|
|
|
|
|
2016-10-05 16:25:09 -04:00
|
|
|
// PluginInstallOptions holds parameters to install a plugin.
|
|
|
|
type PluginInstallOptions struct {
|
|
|
|
Disabled bool
|
|
|
|
AcceptAllPermissions bool
|
|
|
|
RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry
|
2016-12-12 18:05:53 -05:00
|
|
|
RemoteRef string // RemoteRef is the plugin name on the registry
|
2016-10-05 16:25:09 -04:00
|
|
|
PrivilegeFunc RequestPrivilegeFunc
|
|
|
|
AcceptPermissionsFunc func(PluginPrivileges) (bool, error)
|
2016-11-07 20:43:11 -05:00
|
|
|
Args []string
|
2016-10-05 16:25:09 -04:00
|
|
|
}
|
2016-11-03 11:08:22 -04:00
|
|
|
|
2016-11-15 14:45:20 -05:00
|
|
|
// SwarmUnlockKeyResponse contains the response for Engine API:
|
2016-10-27 21:50:49 -04:00
|
|
|
// GET /swarm/unlockkey
|
|
|
|
type SwarmUnlockKeyResponse struct {
|
|
|
|
// UnlockKey is the unlock key in ASCII-armored format.
|
|
|
|
UnlockKey string
|
|
|
|
}
|
2016-10-04 15:01:19 -04:00
|
|
|
|
|
|
|
// PluginCreateOptions hold all options to plugin create.
|
|
|
|
type PluginCreateOptions struct {
|
|
|
|
RepoName string
|
|
|
|
}
|