mirror of
https://github.com/mudler/luet.git
synced 2025-09-02 07:45:02 +00:00
Update vendor
This commit is contained in:
142
vendor/github.com/fsouza/go-dockerclient/container.go
generated
vendored
142
vendor/github.com/fsouza/go-dockerclient/container.go
generated
vendored
@@ -16,7 +16,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/docker/go-units"
|
||||
units "github.com/docker/go-units"
|
||||
)
|
||||
|
||||
// ErrContainerAlreadyExists is the error returned by CreateContainer when the
|
||||
@@ -52,7 +52,8 @@ type APIMount struct {
|
||||
Driver string `json:"Driver,omitempty" yaml:"Driver,omitempty" toml:"Driver,omitempty"`
|
||||
Mode string `json:"Mode,omitempty" yaml:"Mode,omitempty" toml:"Mode,omitempty"`
|
||||
RW bool `json:"RW,omitempty" yaml:"RW,omitempty" toml:"RW,omitempty"`
|
||||
Propogation string `json:"Propogation,omitempty" yaml:"Propogation,omitempty" toml:"Propogation,omitempty"`
|
||||
Propagation string `json:"Propagation,omitempty" yaml:"Propagation,omitempty" toml:"Propagation,omitempty"`
|
||||
Type string `json:"Type,omitempty" yaml:"Type,omitempty" toml:"Type,omitempty"`
|
||||
}
|
||||
|
||||
// APIContainers represents each container in the list returned by
|
||||
@@ -84,7 +85,7 @@ type NetworkList struct {
|
||||
// See https://goo.gl/kaOHGw for more details.
|
||||
func (c *Client) ListContainers(opts ListContainersOptions) ([]APIContainers, error) {
|
||||
path := "/containers/json?" + queryString(opts)
|
||||
resp, err := c.do("GET", path, doOptions{context: opts.Context})
|
||||
resp, err := c.do(http.MethodGet, path, doOptions{context: opts.Context})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -473,6 +474,12 @@ type Container struct {
|
||||
RestartCount int `json:"RestartCount,omitempty" yaml:"RestartCount,omitempty" toml:"RestartCount,omitempty"`
|
||||
|
||||
AppArmorProfile string `json:"AppArmorProfile,omitempty" yaml:"AppArmorProfile,omitempty" toml:"AppArmorProfile,omitempty"`
|
||||
|
||||
MountLabel string `json:"MountLabel,omitempty" yaml:"MountLabel,omitempty" toml:"MountLabel,omitempty"`
|
||||
ProcessLabel string `json:"ProcessLabel,omitempty" yaml:"ProcessLabel,omitempty" toml:"ProcessLabel,omitempty"`
|
||||
Platform string `json:"Platform,omitempty" yaml:"Platform,omitempty" toml:"Platform,omitempty"`
|
||||
SizeRw int64 `json:"SizeRw,omitempty" yaml:"SizeRw,omitempty" toml:"SizeRw,omitempty"`
|
||||
SizeRootFs int64 `json:"SizeRootFs,omitempty" yaml:"SizeRootFs,omitempty" toml:"SizeRootFs,omitempty"`
|
||||
}
|
||||
|
||||
// UpdateContainerOptions specify parameters to the UpdateContainer function.
|
||||
@@ -499,7 +506,7 @@ type UpdateContainerOptions struct {
|
||||
//
|
||||
// See https://goo.gl/Y6fXUy for more details.
|
||||
func (c *Client) UpdateContainer(id string, opts UpdateContainerOptions) error {
|
||||
resp, err := c.do("POST", fmt.Sprintf("/containers/"+id+"/update"), doOptions{
|
||||
resp, err := c.do(http.MethodPost, fmt.Sprintf("/containers/"+id+"/update"), doOptions{
|
||||
data: opts,
|
||||
forceJSON: true,
|
||||
context: opts.Context,
|
||||
@@ -527,7 +534,7 @@ type RenameContainerOptions struct {
|
||||
//
|
||||
// See https://goo.gl/46inai for more details.
|
||||
func (c *Client) RenameContainer(opts RenameContainerOptions) error {
|
||||
resp, err := c.do("POST", fmt.Sprintf("/containers/"+opts.ID+"/rename?%s", queryString(opts)), doOptions{
|
||||
resp, err := c.do(http.MethodPost, fmt.Sprintf("/containers/"+opts.ID+"/rename?%s", queryString(opts)), doOptions{
|
||||
context: opts.Context,
|
||||
})
|
||||
if err != nil {
|
||||
@@ -539,25 +546,31 @@ func (c *Client) RenameContainer(opts RenameContainerOptions) error {
|
||||
|
||||
// InspectContainer returns information about a container by its ID.
|
||||
//
|
||||
// See https://goo.gl/FaI5JT for more details.
|
||||
// Deprecated: Use InspectContainerWithOptions instead.
|
||||
func (c *Client) InspectContainer(id string) (*Container, error) {
|
||||
return c.inspectContainer(id, doOptions{})
|
||||
return c.InspectContainerWithOptions(InspectContainerOptions{ID: id})
|
||||
}
|
||||
|
||||
// InspectContainerWithContext returns information about a container by its ID.
|
||||
// The context object can be used to cancel the inspect request.
|
||||
//
|
||||
// See https://goo.gl/FaI5JT for more details.
|
||||
// Deprecated: Use InspectContainerWithOptions instead.
|
||||
//nolint:golint
|
||||
func (c *Client) InspectContainerWithContext(id string, ctx context.Context) (*Container, error) {
|
||||
return c.inspectContainer(id, doOptions{context: ctx})
|
||||
return c.InspectContainerWithOptions(InspectContainerOptions{ID: id, Context: ctx})
|
||||
}
|
||||
|
||||
func (c *Client) inspectContainer(id string, opts doOptions) (*Container, error) {
|
||||
path := "/containers/" + id + "/json"
|
||||
resp, err := c.do("GET", path, opts)
|
||||
// InspectContainerWithOptions returns information about a container by its ID.
|
||||
//
|
||||
// See https://goo.gl/FaI5JT for more details.
|
||||
func (c *Client) InspectContainerWithOptions(opts InspectContainerOptions) (*Container, error) {
|
||||
path := "/containers/" + opts.ID + "/json?" + queryString(opts)
|
||||
resp, err := c.do(http.MethodGet, path, doOptions{
|
||||
context: opts.Context,
|
||||
})
|
||||
if err != nil {
|
||||
if e, ok := err.(*Error); ok && e.Status == http.StatusNotFound {
|
||||
return nil, &NoSuchContainer{ID: id}
|
||||
return nil, &NoSuchContainer{ID: opts.ID}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
@@ -569,12 +582,21 @@ func (c *Client) inspectContainer(id string, opts doOptions) (*Container, error)
|
||||
return &container, nil
|
||||
}
|
||||
|
||||
// InspectContainerOptions specifies parameters for InspectContainerWithOptions.
|
||||
//
|
||||
// See https://goo.gl/FaI5JT for more details.
|
||||
type InspectContainerOptions struct {
|
||||
Context context.Context
|
||||
ID string `qs:"-"`
|
||||
Size bool
|
||||
}
|
||||
|
||||
// ContainerChanges returns changes in the filesystem of the given container.
|
||||
//
|
||||
// See https://goo.gl/15KKzh for more details.
|
||||
func (c *Client) ContainerChanges(id string) ([]Change, error) {
|
||||
path := "/containers/" + id + "/changes"
|
||||
resp, err := c.do("GET", path, doOptions{})
|
||||
resp, err := c.do(http.MethodGet, path, doOptions{})
|
||||
if err != nil {
|
||||
if e, ok := err.(*Error); ok && e.Status == http.StatusNotFound {
|
||||
return nil, &NoSuchContainer{ID: id}
|
||||
@@ -610,7 +632,7 @@ type CreateContainerOptions struct {
|
||||
func (c *Client) CreateContainer(opts CreateContainerOptions) (*Container, error) {
|
||||
path := "/containers/create?" + queryString(opts)
|
||||
resp, err := c.do(
|
||||
"POST",
|
||||
http.MethodPost,
|
||||
path,
|
||||
doOptions{
|
||||
data: struct {
|
||||
@@ -627,7 +649,7 @@ func (c *Client) CreateContainer(opts CreateContainerOptions) (*Container, error
|
||||
)
|
||||
|
||||
if e, ok := err.(*Error); ok {
|
||||
if e.Status == http.StatusNotFound {
|
||||
if e.Status == http.StatusNotFound && strings.Contains(e.Message, "No such image") {
|
||||
return nil, ErrNoSuchImage
|
||||
}
|
||||
if e.Status == http.StatusConflict {
|
||||
@@ -708,6 +730,15 @@ type Device struct {
|
||||
CgroupPermissions string `json:"CgroupPermissions,omitempty" yaml:"CgroupPermissions,omitempty" toml:"CgroupPermissions,omitempty"`
|
||||
}
|
||||
|
||||
// DeviceRequest represents a request for device that's sent to device drivers.
|
||||
type DeviceRequest struct {
|
||||
Driver string `json:"Driver,omitempty" yaml:"Driver,omitempty" toml:"Driver,omitempty"`
|
||||
Count int `json:"Count,omitempty" yaml:"Count,omitempty" toml:"Count,omitempty"`
|
||||
DeviceIDs []string `json:"DeviceIDs,omitempty" yaml:"DeviceIDs,omitempty" toml:"DeviceIDs,omitempty"`
|
||||
Capabilities [][]string `json:"Capabilities,omitempty" yaml:"Capabilities,omitempty" toml:"Capabilities,omitempty"`
|
||||
Options map[string]string `json:"Options,omitempty" yaml:"Options,omitempty" toml:"Options,omitempty"`
|
||||
}
|
||||
|
||||
// BlockWeight represents a relative device weight for an individual device inside
|
||||
// of a container
|
||||
type BlockWeight struct {
|
||||
@@ -728,6 +759,7 @@ type HostConfig struct {
|
||||
Binds []string `json:"Binds,omitempty" yaml:"Binds,omitempty" toml:"Binds,omitempty"`
|
||||
CapAdd []string `json:"CapAdd,omitempty" yaml:"CapAdd,omitempty" toml:"CapAdd,omitempty"`
|
||||
CapDrop []string `json:"CapDrop,omitempty" yaml:"CapDrop,omitempty" toml:"CapDrop,omitempty"`
|
||||
Capabilities []string `json:"Capabilities,omitempty" yaml:"Capabilities,omitempty" toml:"Capabilities,omitempty"` // Mutually exclusive w.r.t. CapAdd and CapDrop API v1.40
|
||||
GroupAdd []string `json:"GroupAdd,omitempty" yaml:"GroupAdd,omitempty" toml:"GroupAdd,omitempty"`
|
||||
ContainerIDFile string `json:"ContainerIDFile,omitempty" yaml:"ContainerIDFile,omitempty" toml:"ContainerIDFile,omitempty"`
|
||||
LxcConf []KeyValuePair `json:"LxcConf,omitempty" yaml:"LxcConf,omitempty" toml:"LxcConf,omitempty"`
|
||||
@@ -741,20 +773,23 @@ type HostConfig struct {
|
||||
UsernsMode string `json:"UsernsMode,omitempty" yaml:"UsernsMode,omitempty" toml:"UsernsMode,omitempty"`
|
||||
NetworkMode string `json:"NetworkMode,omitempty" yaml:"NetworkMode,omitempty" toml:"NetworkMode,omitempty"`
|
||||
IpcMode string `json:"IpcMode,omitempty" yaml:"IpcMode,omitempty" toml:"IpcMode,omitempty"`
|
||||
Isolation string `json:"Isolation,omitempty" yaml:"Isolation,omitempty" toml:"Isolation,omitempty"` // Windows only
|
||||
ConsoleSize [2]int `json:"ConsoleSize,omitempty" yaml:"ConsoleSize,omitempty" toml:"ConsoleSize,omitempty"` // Windows only height x width
|
||||
PidMode string `json:"PidMode,omitempty" yaml:"PidMode,omitempty" toml:"PidMode,omitempty"`
|
||||
UTSMode string `json:"UTSMode,omitempty" yaml:"UTSMode,omitempty" toml:"UTSMode,omitempty"`
|
||||
RestartPolicy RestartPolicy `json:"RestartPolicy,omitempty" yaml:"RestartPolicy,omitempty" toml:"RestartPolicy,omitempty"`
|
||||
Devices []Device `json:"Devices,omitempty" yaml:"Devices,omitempty" toml:"Devices,omitempty"`
|
||||
DeviceCgroupRules []string `json:"DeviceCgroupRules,omitempty" yaml:"DeviceCgroupRules,omitempty" toml:"DeviceCgroupRules,omitempty"`
|
||||
DeviceRequests []DeviceRequest `json:"DeviceRequests,omitempty" yaml:"DeviceRequests,omitempty" toml:"DeviceRequests,omitempty"`
|
||||
LogConfig LogConfig `json:"LogConfig,omitempty" yaml:"LogConfig,omitempty" toml:"LogConfig,omitempty"`
|
||||
SecurityOpt []string `json:"SecurityOpt,omitempty" yaml:"SecurityOpt,omitempty" toml:"SecurityOpt,omitempty"`
|
||||
CgroupnsMode string `json:"CgroupnsMode,omitempty" yaml:"CgroupnsMode,omitempty" toml:"CgroupnsMode,omitempty"` // v1.40+
|
||||
Cgroup string `json:"Cgroup,omitempty" yaml:"Cgroup,omitempty" toml:"Cgroup,omitempty"`
|
||||
CgroupParent string `json:"CgroupParent,omitempty" yaml:"CgroupParent,omitempty" toml:"CgroupParent,omitempty"`
|
||||
Memory int64 `json:"Memory,omitempty" yaml:"Memory,omitempty" toml:"Memory,omitempty"`
|
||||
MemoryReservation int64 `json:"MemoryReservation,omitempty" yaml:"MemoryReservation,omitempty" toml:"MemoryReservation,omitempty"`
|
||||
KernelMemory int64 `json:"KernelMemory,omitempty" yaml:"KernelMemory,omitempty" toml:"KernelMemory,omitempty"`
|
||||
MemorySwap int64 `json:"MemorySwap,omitempty" yaml:"MemorySwap,omitempty" toml:"MemorySwap,omitempty"`
|
||||
MemorySwappiness int64 `json:"MemorySwappiness,omitempty" yaml:"MemorySwappiness,omitempty" toml:"MemorySwappiness,omitempty"`
|
||||
CPUShares int64 `json:"CpuShares,omitempty" yaml:"CpuShares,omitempty" toml:"CpuShares,omitempty"`
|
||||
CPUSet string `json:"Cpuset,omitempty" yaml:"Cpuset,omitempty" toml:"Cpuset,omitempty"`
|
||||
CPUSetCPUs string `json:"CpusetCpus,omitempty" yaml:"CpusetCpus,omitempty" toml:"CpusetCpus,omitempty"`
|
||||
@@ -763,6 +798,7 @@ type HostConfig struct {
|
||||
CPUPeriod int64 `json:"CpuPeriod,omitempty" yaml:"CpuPeriod,omitempty" toml:"CpuPeriod,omitempty"`
|
||||
CPURealtimePeriod int64 `json:"CpuRealtimePeriod,omitempty" yaml:"CpuRealtimePeriod,omitempty" toml:"CpuRealtimePeriod,omitempty"`
|
||||
CPURealtimeRuntime int64 `json:"CpuRealtimeRuntime,omitempty" yaml:"CpuRealtimeRuntime,omitempty" toml:"CpuRealtimeRuntime,omitempty"`
|
||||
NanoCPUs int64 `json:"NanoCpus,omitempty" yaml:"NanoCpus,omitempty" toml:"NanoCpus,omitempty"`
|
||||
BlkioWeight int64 `json:"BlkioWeight,omitempty" yaml:"BlkioWeight,omitempty" toml:"BlkioWeight,omitempty"`
|
||||
BlkioWeightDevice []BlockWeight `json:"BlkioWeightDevice,omitempty" yaml:"BlkioWeightDevice,omitempty" toml:"BlkioWeightDevice,omitempty"`
|
||||
BlkioDeviceReadBps []BlockLimit `json:"BlkioDeviceReadBps,omitempty" yaml:"BlkioDeviceReadBps,omitempty" toml:"BlkioDeviceReadBps,omitempty"`
|
||||
@@ -772,14 +808,11 @@ type HostConfig struct {
|
||||
Ulimits []ULimit `json:"Ulimits,omitempty" yaml:"Ulimits,omitempty" toml:"Ulimits,omitempty"`
|
||||
VolumeDriver string `json:"VolumeDriver,omitempty" yaml:"VolumeDriver,omitempty" toml:"VolumeDriver,omitempty"`
|
||||
OomScoreAdj int `json:"OomScoreAdj,omitempty" yaml:"OomScoreAdj,omitempty" toml:"OomScoreAdj,omitempty"`
|
||||
PidsLimit int64 `json:"PidsLimit,omitempty" yaml:"PidsLimit,omitempty" toml:"PidsLimit,omitempty"`
|
||||
MemorySwappiness *int64 `json:"MemorySwappiness,omitempty" yaml:"MemorySwappiness,omitempty" toml:"MemorySwappiness,omitempty"`
|
||||
PidsLimit *int64 `json:"PidsLimit,omitempty" yaml:"PidsLimit,omitempty" toml:"PidsLimit,omitempty"`
|
||||
OOMKillDisable *bool `json:"OomKillDisable,omitempty" yaml:"OomKillDisable,omitempty" toml:"OomKillDisable,omitempty"`
|
||||
ShmSize int64 `json:"ShmSize,omitempty" yaml:"ShmSize,omitempty" toml:"ShmSize,omitempty"`
|
||||
Tmpfs map[string]string `json:"Tmpfs,omitempty" yaml:"Tmpfs,omitempty" toml:"Tmpfs,omitempty"`
|
||||
Privileged bool `json:"Privileged,omitempty" yaml:"Privileged,omitempty" toml:"Privileged,omitempty"`
|
||||
PublishAllPorts bool `json:"PublishAllPorts,omitempty" yaml:"PublishAllPorts,omitempty" toml:"PublishAllPorts,omitempty"`
|
||||
ReadonlyRootfs bool `json:"ReadonlyRootfs,omitempty" yaml:"ReadonlyRootfs,omitempty" toml:"ReadonlyRootfs,omitempty"`
|
||||
OOMKillDisable bool `json:"OomKillDisable,omitempty" yaml:"OomKillDisable,omitempty" toml:"OomKillDisable,omitempty"`
|
||||
AutoRemove bool `json:"AutoRemove,omitempty" yaml:"AutoRemove,omitempty" toml:"AutoRemove,omitempty"`
|
||||
StorageOpt map[string]string `json:"StorageOpt,omitempty" yaml:"StorageOpt,omitempty" toml:"StorageOpt,omitempty"`
|
||||
Sysctls map[string]string `json:"Sysctls,omitempty" yaml:"Sysctls,omitempty" toml:"Sysctls,omitempty"`
|
||||
CPUCount int64 `json:"CpuCount,omitempty" yaml:"CpuCount,omitempty"`
|
||||
@@ -787,8 +820,14 @@ type HostConfig struct {
|
||||
IOMaximumBandwidth int64 `json:"IOMaximumBandwidth,omitempty" yaml:"IOMaximumBandwidth,omitempty"`
|
||||
IOMaximumIOps int64 `json:"IOMaximumIOps,omitempty" yaml:"IOMaximumIOps,omitempty"`
|
||||
Mounts []HostMount `json:"Mounts,omitempty" yaml:"Mounts,omitempty" toml:"Mounts,omitempty"`
|
||||
Init bool `json:",omitempty" yaml:",omitempty"`
|
||||
MaskedPaths []string `json:"MaskedPaths,omitempty" yaml:"MaskedPaths,omitempty" toml:"MaskedPaths,omitempty"`
|
||||
ReadonlyPaths []string `json:"ReadonlyPaths,omitempty" yaml:"ReadonlyPaths,omitempty" toml:"ReadonlyPaths,omitempty"`
|
||||
Runtime string `json:"Runtime,omitempty" yaml:"Runtime,omitempty" toml:"Runtime,omitempty"`
|
||||
Init bool `json:",omitempty" yaml:",omitempty"`
|
||||
Privileged bool `json:"Privileged,omitempty" yaml:"Privileged,omitempty" toml:"Privileged,omitempty"`
|
||||
PublishAllPorts bool `json:"PublishAllPorts,omitempty" yaml:"PublishAllPorts,omitempty" toml:"PublishAllPorts,omitempty"`
|
||||
ReadonlyRootfs bool `json:"ReadonlyRootfs,omitempty" yaml:"ReadonlyRootfs,omitempty" toml:"ReadonlyRootfs,omitempty"`
|
||||
AutoRemove bool `json:"AutoRemove,omitempty" yaml:"AutoRemove,omitempty" toml:"AutoRemove,omitempty"`
|
||||
}
|
||||
|
||||
// NetworkingConfig represents the container's networking configuration for each of its interfaces
|
||||
@@ -819,6 +858,7 @@ func (c *Client) StartContainer(id string, hostConfig *HostConfig) error {
|
||||
// API 1.24 or greater.
|
||||
//
|
||||
// See https://goo.gl/fbOSZy for more details.
|
||||
//nolint:golint
|
||||
func (c *Client) StartContainerWithContext(id string, hostConfig *HostConfig, ctx context.Context) error {
|
||||
return c.startContainer(id, hostConfig, doOptions{context: ctx})
|
||||
}
|
||||
@@ -832,7 +872,7 @@ func (c *Client) startContainer(id string, hostConfig *HostConfig, opts doOption
|
||||
opts.data = hostConfig
|
||||
opts.forceJSON = true
|
||||
}
|
||||
resp, err := c.do("POST", path, opts)
|
||||
resp, err := c.do(http.MethodPost, path, opts)
|
||||
if err != nil {
|
||||
if e, ok := err.(*Error); ok && e.Status == http.StatusNotFound {
|
||||
return &NoSuchContainer{ID: id, Err: err}
|
||||
@@ -859,13 +899,14 @@ func (c *Client) StopContainer(id string, timeout uint) error {
|
||||
// container request.
|
||||
//
|
||||
// See https://goo.gl/R9dZcV for more details.
|
||||
//nolint:golint
|
||||
func (c *Client) StopContainerWithContext(id string, timeout uint, ctx context.Context) error {
|
||||
return c.stopContainer(id, timeout, doOptions{context: ctx})
|
||||
}
|
||||
|
||||
func (c *Client) stopContainer(id string, timeout uint, opts doOptions) error {
|
||||
path := fmt.Sprintf("/containers/%s/stop?t=%d", id, timeout)
|
||||
resp, err := c.do("POST", path, opts)
|
||||
resp, err := c.do(http.MethodPost, path, opts)
|
||||
if err != nil {
|
||||
if e, ok := err.(*Error); ok && e.Status == http.StatusNotFound {
|
||||
return &NoSuchContainer{ID: id}
|
||||
@@ -885,7 +926,7 @@ func (c *Client) stopContainer(id string, timeout uint, opts doOptions) error {
|
||||
// See https://goo.gl/MrAKQ5 for more details.
|
||||
func (c *Client) RestartContainer(id string, timeout uint) error {
|
||||
path := fmt.Sprintf("/containers/%s/restart?t=%d", id, timeout)
|
||||
resp, err := c.do("POST", path, doOptions{})
|
||||
resp, err := c.do(http.MethodPost, path, doOptions{})
|
||||
if err != nil {
|
||||
if e, ok := err.(*Error); ok && e.Status == http.StatusNotFound {
|
||||
return &NoSuchContainer{ID: id}
|
||||
@@ -901,7 +942,7 @@ func (c *Client) RestartContainer(id string, timeout uint) error {
|
||||
// See https://goo.gl/D1Yaii for more details.
|
||||
func (c *Client) PauseContainer(id string) error {
|
||||
path := fmt.Sprintf("/containers/%s/pause", id)
|
||||
resp, err := c.do("POST", path, doOptions{})
|
||||
resp, err := c.do(http.MethodPost, path, doOptions{})
|
||||
if err != nil {
|
||||
if e, ok := err.(*Error); ok && e.Status == http.StatusNotFound {
|
||||
return &NoSuchContainer{ID: id}
|
||||
@@ -917,7 +958,7 @@ func (c *Client) PauseContainer(id string) error {
|
||||
// See https://goo.gl/sZ2faO for more details.
|
||||
func (c *Client) UnpauseContainer(id string) error {
|
||||
path := fmt.Sprintf("/containers/%s/unpause", id)
|
||||
resp, err := c.do("POST", path, doOptions{})
|
||||
resp, err := c.do(http.MethodPost, path, doOptions{})
|
||||
if err != nil {
|
||||
if e, ok := err.(*Error); ok && e.Status == http.StatusNotFound {
|
||||
return &NoSuchContainer{ID: id}
|
||||
@@ -947,7 +988,7 @@ func (c *Client) TopContainer(id string, psArgs string) (TopResult, error) {
|
||||
args = fmt.Sprintf("?ps_args=%s", psArgs)
|
||||
}
|
||||
path := fmt.Sprintf("/containers/%s/top%s", id, args)
|
||||
resp, err := c.do("GET", path, doOptions{})
|
||||
resp, err := c.do(http.MethodGet, path, doOptions{})
|
||||
if err != nil {
|
||||
if e, ok := err.(*Error); ok && e.Status == http.StatusNotFound {
|
||||
return result, &NoSuchContainer{ID: id}
|
||||
@@ -1103,13 +1144,8 @@ func (c *Client) Stats(opts StatsOptions) (retErr error) {
|
||||
defer func() {
|
||||
close(opts.Stats)
|
||||
|
||||
select {
|
||||
case err := <-errC:
|
||||
if err != nil && retErr == nil {
|
||||
retErr = err
|
||||
}
|
||||
default:
|
||||
// No errors
|
||||
if err := <-errC; err != nil && retErr == nil {
|
||||
retErr = err
|
||||
}
|
||||
|
||||
if err := readCloser.Close(); err != nil && retErr == nil {
|
||||
@@ -1119,7 +1155,8 @@ func (c *Client) Stats(opts StatsOptions) (retErr error) {
|
||||
|
||||
reqSent := make(chan struct{})
|
||||
go func() {
|
||||
err := c.stream("GET", fmt.Sprintf("/containers/%s/stats?stream=%v", opts.ID, opts.Stream), streamOptions{
|
||||
defer close(errC)
|
||||
err := c.stream(http.MethodGet, fmt.Sprintf("/containers/%s/stats?stream=%v", opts.ID, opts.Stream), streamOptions{
|
||||
rawJSONStream: true,
|
||||
useJSONDecoder: true,
|
||||
stdout: writeCloser,
|
||||
@@ -1140,7 +1177,6 @@ func (c *Client) Stats(opts StatsOptions) (retErr error) {
|
||||
err = closeErr
|
||||
}
|
||||
errC <- err
|
||||
close(errC)
|
||||
}()
|
||||
|
||||
quit := make(chan struct{})
|
||||
@@ -1188,7 +1224,7 @@ type KillContainerOptions struct {
|
||||
// See https://goo.gl/JnTxXZ for more details.
|
||||
func (c *Client) KillContainer(opts KillContainerOptions) error {
|
||||
path := "/containers/" + opts.ID + "/kill" + "?" + queryString(opts)
|
||||
resp, err := c.do("POST", path, doOptions{context: opts.Context})
|
||||
resp, err := c.do(http.MethodPost, path, doOptions{context: opts.Context})
|
||||
if err != nil {
|
||||
e, ok := err.(*Error)
|
||||
if !ok {
|
||||
@@ -1229,7 +1265,7 @@ type RemoveContainerOptions struct {
|
||||
// See https://goo.gl/hL5IPC for more details.
|
||||
func (c *Client) RemoveContainer(opts RemoveContainerOptions) error {
|
||||
path := "/containers/" + opts.ID + "?" + queryString(opts)
|
||||
resp, err := c.do("DELETE", path, doOptions{context: opts.Context})
|
||||
resp, err := c.do(http.MethodDelete, path, doOptions{context: opts.Context})
|
||||
if err != nil {
|
||||
if e, ok := err.(*Error); ok && e.Status == http.StatusNotFound {
|
||||
return &NoSuchContainer{ID: opts.ID}
|
||||
@@ -1258,7 +1294,7 @@ type UploadToContainerOptions struct {
|
||||
func (c *Client) UploadToContainer(id string, opts UploadToContainerOptions) error {
|
||||
url := fmt.Sprintf("/containers/%s/archive?", id) + queryString(opts)
|
||||
|
||||
return c.stream("PUT", url, streamOptions{
|
||||
return c.stream(http.MethodPut, url, streamOptions{
|
||||
in: opts.InputStream,
|
||||
context: opts.Context,
|
||||
})
|
||||
@@ -1281,7 +1317,7 @@ type DownloadFromContainerOptions struct {
|
||||
func (c *Client) DownloadFromContainer(id string, opts DownloadFromContainerOptions) error {
|
||||
url := fmt.Sprintf("/containers/%s/archive?", id) + queryString(opts)
|
||||
|
||||
return c.stream("GET", url, streamOptions{
|
||||
return c.stream(http.MethodGet, url, streamOptions{
|
||||
setRawTerminal: true,
|
||||
stdout: opts.OutputStream,
|
||||
inactivityTimeout: opts.InactivityTimeout,
|
||||
@@ -1314,7 +1350,7 @@ func (c *Client) CopyFromContainer(opts CopyFromContainerOptions) error {
|
||||
return errors.New("go-dockerclient: CopyFromContainer is no longer available in Docker >= 1.12, use DownloadFromContainer instead")
|
||||
}
|
||||
url := fmt.Sprintf("/containers/%s/copy", opts.Container)
|
||||
resp, err := c.do("POST", url, doOptions{
|
||||
resp, err := c.do(http.MethodPost, url, doOptions{
|
||||
data: opts,
|
||||
context: opts.Context,
|
||||
})
|
||||
@@ -1342,12 +1378,13 @@ func (c *Client) WaitContainer(id string) (int, error) {
|
||||
// inspect request.
|
||||
//
|
||||
// See https://goo.gl/4AGweZ for more details.
|
||||
//nolint:golint
|
||||
func (c *Client) WaitContainerWithContext(id string, ctx context.Context) (int, error) {
|
||||
return c.waitContainer(id, doOptions{context: ctx})
|
||||
}
|
||||
|
||||
func (c *Client) waitContainer(id string, opts doOptions) (int, error) {
|
||||
resp, err := c.do("POST", "/containers/"+id+"/wait", opts)
|
||||
resp, err := c.do(http.MethodPost, "/containers/"+id+"/wait", opts)
|
||||
if err != nil {
|
||||
if e, ok := err.(*Error); ok && e.Status == http.StatusNotFound {
|
||||
return 0, &NoSuchContainer{ID: id}
|
||||
@@ -1381,7 +1418,7 @@ type CommitContainerOptions struct {
|
||||
// See https://goo.gl/CzIguf for more details.
|
||||
func (c *Client) CommitContainer(opts CommitContainerOptions) (*Image, error) {
|
||||
path := "/commit?" + queryString(opts)
|
||||
resp, err := c.do("POST", path, doOptions{
|
||||
resp, err := c.do(http.MethodPost, path, doOptions{
|
||||
data: opts.Run,
|
||||
context: opts.Context,
|
||||
})
|
||||
@@ -1416,6 +1453,9 @@ type AttachToContainerOptions struct {
|
||||
// to unexpected behavior.
|
||||
Success chan struct{}
|
||||
|
||||
// Override the key sequence for detaching a container.
|
||||
DetachKeys string
|
||||
|
||||
// Use raw terminal? Usually true when the container contains a TTY.
|
||||
RawTerminal bool `qs:"-"`
|
||||
|
||||
@@ -1455,7 +1495,7 @@ func (c *Client) AttachToContainerNonBlocking(opts AttachToContainerOptions) (Cl
|
||||
return nil, &NoSuchContainer{ID: opts.Container}
|
||||
}
|
||||
path := "/containers/" + opts.Container + "/attach?" + queryString(opts)
|
||||
return c.hijack("POST", path, hijackOptions{
|
||||
return c.hijack(http.MethodPost, path, hijackOptions{
|
||||
success: opts.Success,
|
||||
setRawTerminal: opts.RawTerminal,
|
||||
in: opts.InputStream,
|
||||
@@ -1505,7 +1545,7 @@ func (c *Client) Logs(opts LogsOptions) error {
|
||||
opts.Tail = "all"
|
||||
}
|
||||
path := "/containers/" + opts.Container + "/logs?" + queryString(opts)
|
||||
return c.stream("GET", path, streamOptions{
|
||||
return c.stream(http.MethodGet, path, streamOptions{
|
||||
setRawTerminal: opts.RawTerminal,
|
||||
stdout: opts.OutputStream,
|
||||
stderr: opts.ErrorStream,
|
||||
@@ -1521,7 +1561,7 @@ func (c *Client) ResizeContainerTTY(id string, height, width int) error {
|
||||
params := make(url.Values)
|
||||
params.Set("h", strconv.Itoa(height))
|
||||
params.Set("w", strconv.Itoa(width))
|
||||
resp, err := c.do("POST", "/containers/"+id+"/resize?"+params.Encode(), doOptions{})
|
||||
resp, err := c.do(http.MethodPost, "/containers/"+id+"/resize?"+params.Encode(), doOptions{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1549,7 +1589,7 @@ func (c *Client) ExportContainer(opts ExportContainerOptions) error {
|
||||
return &NoSuchContainer{ID: opts.ID}
|
||||
}
|
||||
url := fmt.Sprintf("/containers/%s/export", opts.ID)
|
||||
return c.stream("GET", url, streamOptions{
|
||||
return c.stream(http.MethodGet, url, streamOptions{
|
||||
setRawTerminal: true,
|
||||
stdout: opts.OutputStream,
|
||||
inactivityTimeout: opts.InactivityTimeout,
|
||||
@@ -1578,7 +1618,7 @@ type PruneContainersResults struct {
|
||||
// See https://goo.gl/wnkgDT for more details.
|
||||
func (c *Client) PruneContainers(opts PruneContainersOptions) (*PruneContainersResults, error) {
|
||||
path := "/containers/prune?" + queryString(opts)
|
||||
resp, err := c.do("POST", path, doOptions{context: opts.Context})
|
||||
resp, err := c.do(http.MethodPost, path, doOptions{context: opts.Context})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Reference in New Issue
Block a user