vendor: github.com/docker/docker 2ed904cad7055847796433cc56ef1d1de0da868c

- replace deprecated types
- also fixing some minor nits

full diff: 8941dcfcc5...2ed904cad7

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2022-04-29 19:26:50 +02:00
parent 15301e7cf6
commit 7aa0b273e5
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
52 changed files with 694 additions and 450 deletions

View File

@ -142,7 +142,7 @@ func runAttach(dockerCli command.Cli, opts *attachOptions) error {
return getExitStatus(errC, resultC)
}
func getExitStatus(errC <-chan error, resultC <-chan container.ContainerWaitOKBody) error {
func getExitStatus(errC <-chan error, resultC <-chan container.WaitResponse) error {
select {
case result := <-resultC:
if result.Error != nil {

View File

@ -81,16 +81,16 @@ func TestGetExitStatus(t *testing.T) {
var (
expectedErr = fmt.Errorf("unexpected error")
errC = make(chan error, 1)
resultC = make(chan container.ContainerWaitOKBody, 1)
resultC = make(chan container.WaitResponse, 1)
)
testcases := []struct {
result *container.ContainerWaitOKBody
result *container.WaitResponse
err error
expectedError error
}{
{
result: &container.ContainerWaitOKBody{
result: &container.WaitResponse{
StatusCode: 0,
},
},
@ -99,13 +99,13 @@ func TestGetExitStatus(t *testing.T) {
expectedError: expectedErr,
},
{
result: &container.ContainerWaitOKBody{
Error: &container.ContainerWaitOKBodyError{Message: expectedErr.Error()},
result: &container.WaitResponse{
Error: &container.WaitExitError{Message: expectedErr.Error()},
},
expectedError: expectedErr,
},
{
result: &container.ContainerWaitOKBody{
result: &container.WaitResponse{
StatusCode: 15,
},
expectedError: cli.StatusError{StatusCode: 15},

View File

@ -20,14 +20,14 @@ type fakeClient struct {
hostConfig *container.HostConfig,
networkingConfig *network.NetworkingConfig,
platform *specs.Platform,
containerName string) (container.ContainerCreateCreatedBody, error)
containerName string) (container.CreateResponse, error)
containerStartFunc func(container string, options types.ContainerStartOptions) error
imageCreateFunc func(parentReference string, options types.ImageCreateOptions) (io.ReadCloser, error)
infoFunc func() (types.Info, error)
containerStatPathFunc func(container, path string) (types.ContainerPathStat, error)
containerCopyFromFunc func(container, srcPath string) (io.ReadCloser, types.ContainerPathStat, error)
logFunc func(string, types.ContainerLogsOptions) (io.ReadCloser, error)
waitFunc func(string) (<-chan container.ContainerWaitOKBody, <-chan error)
waitFunc func(string) (<-chan container.WaitResponse, <-chan error)
containerListFunc func(types.ContainerListOptions) ([]types.Container, error)
containerExportFunc func(string) (io.ReadCloser, error)
containerExecResizeFunc func(id string, options types.ResizeOptions) error
@ -75,11 +75,11 @@ func (f *fakeClient) ContainerCreate(
networkingConfig *network.NetworkingConfig,
platform *specs.Platform,
containerName string,
) (container.ContainerCreateCreatedBody, error) {
) (container.CreateResponse, error) {
if f.createContainerFunc != nil {
return f.createContainerFunc(config, hostConfig, networkingConfig, platform, containerName)
}
return container.ContainerCreateCreatedBody{}, nil
return container.CreateResponse{}, nil
}
func (f *fakeClient) ContainerRemove(ctx context.Context, container string, options types.ContainerRemoveOptions) error {
@ -128,7 +128,7 @@ func (f *fakeClient) ClientVersion() string {
return f.Version
}
func (f *fakeClient) ContainerWait(_ context.Context, container string, _ container.WaitCondition) (<-chan container.ContainerWaitOKBody, <-chan error) {
func (f *fakeClient) ContainerWait(_ context.Context, container string, _ container.WaitCondition) (<-chan container.WaitResponse, <-chan error) {
if f.waitFunc != nil {
return f.waitFunc(container)
}

View File

@ -191,7 +191,7 @@ func newCIDFile(path string) (*cidFile, error) {
}
// nolint: gocyclo
func createContainer(ctx context.Context, dockerCli command.Cli, containerConfig *containerConfig, opts *createOptions) (*container.ContainerCreateCreatedBody, error) {
func createContainer(ctx context.Context, dockerCli command.Cli, containerConfig *containerConfig, opts *createOptions) (*container.CreateResponse, error) {
config := containerConfig.Config
hostConfig := containerConfig.HostConfig
networkingConfig := containerConfig.NetworkingConfig

View File

@ -88,18 +88,18 @@ func TestCreateContainerImagePullPolicy(t *testing.T) {
cases := []struct {
PullPolicy string
ExpectedPulls int
ExpectedBody container.ContainerCreateCreatedBody
ExpectedBody container.CreateResponse
ExpectedErrMsg string
ResponseCounter int
}{
{
PullPolicy: PullImageMissing,
ExpectedPulls: 1,
ExpectedBody: container.ContainerCreateCreatedBody{ID: containerID},
ExpectedBody: container.CreateResponse{ID: containerID},
}, {
PullPolicy: PullImageAlways,
ExpectedPulls: 1,
ExpectedBody: container.ContainerCreateCreatedBody{ID: containerID},
ExpectedBody: container.CreateResponse{ID: containerID},
ResponseCounter: 1, // This lets us return a container on the first pull
}, {
PullPolicy: PullImageNever,
@ -118,13 +118,13 @@ func TestCreateContainerImagePullPolicy(t *testing.T) {
networkingConfig *network.NetworkingConfig,
platform *specs.Platform,
containerName string,
) (container.ContainerCreateCreatedBody, error) {
) (container.CreateResponse, error) {
defer func() { c.ResponseCounter++ }()
switch c.ResponseCounter {
case 0:
return container.ContainerCreateCreatedBody{}, fakeNotFound{}
return container.CreateResponse{}, fakeNotFound{}
default:
return container.ContainerCreateCreatedBody{ID: containerID}, nil
return container.CreateResponse{ID: containerID}, nil
}
},
imageCreateFunc: func(parentReference string, options types.ImageCreateOptions) (io.ReadCloser, error) {
@ -187,8 +187,8 @@ func TestNewCreateCommandWithContentTrustErrors(t *testing.T) {
networkingConfig *network.NetworkingConfig,
platform *specs.Platform,
containerName string,
) (container.ContainerCreateCreatedBody, error) {
return container.ContainerCreateCreatedBody{}, fmt.Errorf("shouldn't try to pull image")
) (container.CreateResponse, error) {
return container.CreateResponse{}, fmt.Errorf("shouldn't try to pull image")
},
}, test.EnableContentTrust)
cli.SetNotaryClient(tc.notaryFunc)
@ -248,8 +248,8 @@ func TestNewCreateCommandWithWarnings(t *testing.T) {
networkingConfig *network.NetworkingConfig,
platform *specs.Platform,
containerName string,
) (container.ContainerCreateCreatedBody, error) {
return container.ContainerCreateCreatedBody{}, nil
) (container.CreateResponse, error) {
return container.CreateResponse{}, nil
},
})
cmd := NewCreateCommand(cli)
@ -287,10 +287,10 @@ func TestCreateContainerWithProxyConfig(t *testing.T) {
networkingConfig *network.NetworkingConfig,
platform *specs.Platform,
containerName string,
) (container.ContainerCreateCreatedBody, error) {
) (container.CreateResponse, error) {
sort.Strings(config.Env)
assert.DeepEqual(t, config.Env, expected)
return container.ContainerCreateCreatedBody{}, nil
return container.CreateResponse{}, nil
},
})
cli.SetConfigFile(&configfile.ConfigFile{

View File

@ -4,10 +4,10 @@ import (
"context"
"fmt"
"strings"
"time"
"github.com/docker/cli/cli"
"github.com/docker/cli/cli/command"
"github.com/docker/docker/api/types/container"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
@ -42,18 +42,19 @@ func NewRestartCommand(dockerCli command.Cli) *cobra.Command {
func runRestart(dockerCli command.Cli, opts *restartOptions) error {
ctx := context.Background()
var errs []string
var timeout *time.Duration
var timeout *int
if opts.nSecondsChanged {
timeoutValue := time.Duration(opts.nSeconds) * time.Second
timeout = &timeoutValue
timeout = &opts.nSeconds
}
for _, name := range opts.containers {
if err := dockerCli.Client().ContainerRestart(ctx, name, timeout); err != nil {
err := dockerCli.Client().ContainerRestart(ctx, name, container.StopOptions{
Timeout: timeout,
})
if err != nil {
errs = append(errs, err.Error())
continue
}
fmt.Fprintln(dockerCli.Out(), name)
_, _ = fmt.Fprintln(dockerCli.Out(), name)
}
if len(errs) > 0 {
return errors.New(strings.Join(errs, "\n"))

View File

@ -16,8 +16,8 @@ import (
func TestRunLabel(t *testing.T) {
cli := test.NewFakeCli(&fakeClient{
createContainerFunc: func(_ *container.Config, _ *container.HostConfig, _ *network.NetworkingConfig, _ *specs.Platform, _ string) (container.ContainerCreateCreatedBody, error) {
return container.ContainerCreateCreatedBody{
createContainerFunc: func(_ *container.Config, _ *container.HostConfig, _ *network.NetworkingConfig, _ *specs.Platform, _ string) (container.CreateResponse, error) {
return container.CreateResponse{
ID: "id",
}, nil
},
@ -61,8 +61,8 @@ func TestRunCommandWithContentTrustErrors(t *testing.T) {
networkingConfig *network.NetworkingConfig,
platform *specs.Platform,
containerName string,
) (container.ContainerCreateCreatedBody, error) {
return container.ContainerCreateCreatedBody{}, fmt.Errorf("shouldn't try to pull image")
) (container.CreateResponse, error) {
return container.CreateResponse{}, fmt.Errorf("shouldn't try to pull image")
},
}, test.EnableContentTrust)
cli.SetNotaryClient(tc.notaryFunc)

View File

@ -4,10 +4,10 @@ import (
"context"
"fmt"
"strings"
"time"
"github.com/docker/cli/cli"
"github.com/docker/cli/cli/command"
"github.com/docker/docker/api/types/container"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
@ -40,25 +40,23 @@ func NewStopCommand(dockerCli command.Cli) *cobra.Command {
}
func runStop(dockerCli command.Cli, opts *stopOptions) error {
ctx := context.Background()
var timeout *time.Duration
var timeout *int
if opts.timeChanged {
timeoutValue := time.Duration(opts.time) * time.Second
timeout = &timeoutValue
timeout = &opts.time
}
var errs []string
errChan := parallelOperation(ctx, opts.containers, func(ctx context.Context, id string) error {
return dockerCli.Client().ContainerStop(ctx, id, timeout)
errChan := parallelOperation(context.Background(), opts.containers, func(ctx context.Context, id string) error {
return dockerCli.Client().ContainerStop(ctx, id, container.StopOptions{
Timeout: timeout,
})
})
for _, container := range opts.containers {
var errs []string
for _, ctr := range opts.containers {
if err := <-errChan; err != nil {
errs = append(errs, err.Error())
continue
}
fmt.Fprintln(dockerCli.Out(), container)
_, _ = fmt.Fprintln(dockerCli.Out(), ctr)
}
if len(errs) > 0 {
return errors.New(strings.Join(errs, "\n"))

View File

@ -13,10 +13,10 @@ import (
is "gotest.tools/v3/assert/cmp"
)
func waitFn(cid string) (<-chan container.ContainerWaitOKBody, <-chan error) {
resC := make(chan container.ContainerWaitOKBody)
func waitFn(cid string) (<-chan container.WaitResponse, <-chan error) {
resC := make(chan container.WaitResponse)
errC := make(chan error, 1)
var res container.ContainerWaitOKBody
var res container.WaitResponse
go func() {
switch {
@ -24,10 +24,10 @@ func waitFn(cid string) (<-chan container.ContainerWaitOKBody, <-chan error) {
res.StatusCode = 42
resC <- res
case strings.Contains(cid, "non-existent"):
err := errors.Errorf("No such container: %v", cid)
err := errors.Errorf("no such container: %v", cid)
errC <- err
case strings.Contains(cid, "wait-error"):
res.Error = &container.ContainerWaitOKBodyError{Message: "removal failed"}
res.Error = &container.WaitExitError{Message: "removal failed"}
resC <- res
default:
// normal exit

View File

@ -3,11 +3,13 @@ package formatter
import (
"bytes"
"fmt"
"strconv"
"strings"
"text/template"
"github.com/docker/distribution/reference"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/volume"
units "github.com/docker/go-units"
)
@ -34,7 +36,7 @@ type DiskUsageContext struct {
LayersSize int64
Images []*types.ImageSummary
Containers []*types.Container
Volumes []*types.Volume
Volumes []*volume.Volume
BuildCache []*types.BuildCache
BuilderSize int64
}
@ -271,7 +273,7 @@ func (c *diskUsageImagesContext) Type() string {
}
func (c *diskUsageImagesContext) TotalCount() string {
return fmt.Sprintf("%d", len(c.images))
return strconv.Itoa(len(c.images))
}
func (c *diskUsageImagesContext) Active() string {
@ -282,7 +284,7 @@ func (c *diskUsageImagesContext) Active() string {
}
}
return fmt.Sprintf("%d", used)
return strconv.Itoa(used)
}
func (c *diskUsageImagesContext) Size() string {
@ -323,7 +325,7 @@ func (c *diskUsageContainersContext) Type() string {
}
func (c *diskUsageContainersContext) TotalCount() string {
return fmt.Sprintf("%d", len(c.containers))
return strconv.Itoa(len(c.containers))
}
func (c *diskUsageContainersContext) isActive(container types.Container) bool {
@ -340,7 +342,7 @@ func (c *diskUsageContainersContext) Active() string {
}
}
return fmt.Sprintf("%d", used)
return strconv.Itoa(used)
}
func (c *diskUsageContainersContext) Size() string {
@ -373,7 +375,7 @@ func (c *diskUsageContainersContext) Reclaimable() string {
type diskUsageVolumesContext struct {
HeaderContext
volumes []*types.Volume
volumes []*volume.Volume
}
func (c *diskUsageVolumesContext) MarshalJSON() ([]byte, error) {
@ -385,7 +387,7 @@ func (c *diskUsageVolumesContext) Type() string {
}
func (c *diskUsageVolumesContext) TotalCount() string {
return fmt.Sprintf("%d", len(c.volumes))
return strconv.Itoa(len(c.volumes))
}
func (c *diskUsageVolumesContext) Active() string {
@ -397,7 +399,7 @@ func (c *diskUsageVolumesContext) Active() string {
}
}
return fmt.Sprintf("%d", used)
return strconv.Itoa(used)
}
func (c *diskUsageVolumesContext) Size() string {
@ -447,7 +449,7 @@ func (c *diskUsageBuilderContext) Type() string {
}
func (c *diskUsageBuilderContext) TotalCount() string {
return fmt.Sprintf("%d", len(c.buildCache))
return strconv.Itoa(len(c.buildCache))
}
func (c *diskUsageBuilderContext) Active() string {
@ -457,7 +459,7 @@ func (c *diskUsageBuilderContext) Active() string {
numActive++
}
}
return fmt.Sprintf("%d", numActive)
return strconv.Itoa(numActive)
}
func (c *diskUsageBuilderContext) Size() string {

View File

@ -1,10 +1,10 @@
package formatter
import (
"fmt"
"strconv"
"strings"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/volume"
units "github.com/docker/go-units"
)
@ -36,10 +36,10 @@ func NewVolumeFormat(source string, quiet bool) Format {
}
// VolumeWrite writes formatted volumes using the Context
func VolumeWrite(ctx Context, volumes []*types.Volume) error {
func VolumeWrite(ctx Context, volumes []*volume.Volume) error {
render := func(format func(subContext SubContext) error) error {
for _, volume := range volumes {
if err := format(&volumeContext{v: *volume}); err != nil {
for _, vol := range volumes {
if err := format(&volumeContext{v: *vol}); err != nil {
return err
}
}
@ -50,7 +50,7 @@ func VolumeWrite(ctx Context, volumes []*types.Volume) error {
type volumeContext struct {
HeaderContext
v types.Volume
v volume.Volume
}
func newVolumeContext() *volumeContext {
@ -94,7 +94,7 @@ func (c *volumeContext) Labels() string {
var joinLabels []string
for k, v := range c.v.Labels {
joinLabels = append(joinLabels, fmt.Sprintf("%s=%s", k, v))
joinLabels = append(joinLabels, k+"="+v)
}
return strings.Join(joinLabels, ",")
}
@ -110,7 +110,7 @@ func (c *volumeContext) Links() string {
if c.v.UsageData == nil {
return "N/A"
}
return fmt.Sprintf("%d", c.v.UsageData.RefCount)
return strconv.FormatInt(c.v.UsageData.RefCount, 10)
}
func (c *volumeContext) Size() string {

View File

@ -8,7 +8,7 @@ import (
"testing"
"github.com/docker/cli/internal/test"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/volume"
"github.com/docker/docker/pkg/stringid"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
@ -24,22 +24,22 @@ func TestVolumeContext(t *testing.T) {
call func() string
}{
{volumeContext{
v: types.Volume{Name: volumeName},
v: volume.Volume{Name: volumeName},
}, volumeName, ctx.Name},
{volumeContext{
v: types.Volume{Driver: "driver_name"},
v: volume.Volume{Driver: "driver_name"},
}, "driver_name", ctx.Driver},
{volumeContext{
v: types.Volume{Scope: "local"},
v: volume.Volume{Scope: "local"},
}, "local", ctx.Scope},
{volumeContext{
v: types.Volume{Mountpoint: "mountpoint"},
v: volume.Volume{Mountpoint: "mountpoint"},
}, "mountpoint", ctx.Mountpoint},
{volumeContext{
v: types.Volume{},
v: volume.Volume{},
}, "", ctx.Labels},
{volumeContext{
v: types.Volume{Labels: map[string]string{"label1": "value1", "label2": "value2"}},
v: volume.Volume{Labels: map[string]string{"label1": "value1", "label2": "value2"}},
}, "label1=value1,label2=value2", ctx.Labels},
}
@ -122,7 +122,7 @@ foobar_bar
},
}
volumes := []*types.Volume{
volumes := []*volume.Volume{
{Name: "foobar_baz", Driver: "foo"},
{Name: "foobar_bar", Driver: "bar"},
}
@ -143,7 +143,7 @@ foobar_bar
}
func TestVolumeContextWriteJSON(t *testing.T) {
volumes := []*types.Volume{
volumes := []*volume.Volume{
{Driver: "foo", Name: "foobar_baz"},
{Driver: "bar", Name: "foobar_bar"},
}
@ -166,7 +166,7 @@ func TestVolumeContextWriteJSON(t *testing.T) {
}
func TestVolumeContextWriteJSONField(t *testing.T) {
volumes := []*types.Volume{
volumes := []*volume.Volume{
{Driver: "foo", Name: "foobar_baz"},
{Driver: "bar", Name: "foobar_bar"},
}

View File

@ -22,12 +22,12 @@ import (
"github.com/docker/docker/api"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/builder/remotecontext/urlutil"
"github.com/docker/docker/pkg/archive"
"github.com/docker/docker/pkg/idtools"
"github.com/docker/docker/pkg/jsonmessage"
"github.com/docker/docker/pkg/progress"
"github.com/docker/docker/pkg/streamformatter"
"github.com/docker/docker/pkg/urlutil"
units "github.com/docker/go-units"
"github.com/pkg/errors"
"github.com/spf13/cobra"

View File

@ -5,48 +5,48 @@ import (
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters"
volumetypes "github.com/docker/docker/api/types/volume"
"github.com/docker/docker/api/types/volume"
"github.com/docker/docker/client"
)
type fakeClient struct {
client.Client
volumeCreateFunc func(volumetypes.VolumeCreateBody) (types.Volume, error)
volumeInspectFunc func(volumeID string) (types.Volume, error)
volumeListFunc func(filter filters.Args) (volumetypes.VolumeListOKBody, error)
volumeCreateFunc func(volume.CreateOptions) (volume.Volume, error)
volumeInspectFunc func(volumeID string) (volume.Volume, error)
volumeListFunc func(filter filters.Args) (volume.ListResponse, error)
volumeRemoveFunc func(volumeID string, force bool) error
volumePruneFunc func(filter filters.Args) (types.VolumesPruneReport, error)
}
func (c *fakeClient) VolumeCreate(ctx context.Context, options volumetypes.VolumeCreateBody) (types.Volume, error) {
func (c *fakeClient) VolumeCreate(_ context.Context, options volume.CreateOptions) (volume.Volume, error) {
if c.volumeCreateFunc != nil {
return c.volumeCreateFunc(options)
}
return types.Volume{}, nil
return volume.Volume{}, nil
}
func (c *fakeClient) VolumeInspect(ctx context.Context, volumeID string) (types.Volume, error) {
func (c *fakeClient) VolumeInspect(_ context.Context, volumeID string) (volume.Volume, error) {
if c.volumeInspectFunc != nil {
return c.volumeInspectFunc(volumeID)
}
return types.Volume{}, nil
return volume.Volume{}, nil
}
func (c *fakeClient) VolumeList(ctx context.Context, filter filters.Args) (volumetypes.VolumeListOKBody, error) {
func (c *fakeClient) VolumeList(_ context.Context, filter filters.Args) (volume.ListResponse, error) {
if c.volumeListFunc != nil {
return c.volumeListFunc(filter)
}
return volumetypes.VolumeListOKBody{}, nil
return volume.ListResponse{}, nil
}
func (c *fakeClient) VolumesPrune(ctx context.Context, filter filters.Args) (types.VolumesPruneReport, error) {
func (c *fakeClient) VolumesPrune(_ context.Context, filter filters.Args) (types.VolumesPruneReport, error) {
if c.volumePruneFunc != nil {
return c.volumePruneFunc(filter)
}
return types.VolumesPruneReport{}, nil
}
func (c *fakeClient) VolumeRemove(ctx context.Context, volumeID string, force bool) error {
func (c *fakeClient) VolumeRemove(_ context.Context, volumeID string, force bool) error {
if c.volumeRemoveFunc != nil {
return c.volumeRemoveFunc(volumeID, force)
}

View File

@ -7,7 +7,7 @@ import (
"github.com/docker/cli/cli"
"github.com/docker/cli/cli/command"
"github.com/docker/cli/opts"
volumetypes "github.com/docker/docker/api/types/volume"
"github.com/docker/docker/api/types/volume"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
@ -50,20 +50,16 @@ func newCreateCommand(dockerCli command.Cli) *cobra.Command {
}
func runCreate(dockerCli command.Cli, options createOptions) error {
client := dockerCli.Client()
volReq := volumetypes.VolumeCreateBody{
vol, err := dockerCli.Client().VolumeCreate(context.Background(), volume.CreateOptions{
Driver: options.driver,
DriverOpts: options.driverOpts.GetAll(),
Name: options.name,
Labels: opts.ConvertKVStringsToMap(options.labels.GetAll()),
}
vol, err := client.VolumeCreate(context.Background(), volReq)
})
if err != nil {
return err
}
fmt.Fprintf(dockerCli.Out(), "%s\n", vol.Name)
_, _ = fmt.Fprintln(dockerCli.Out(), vol.Name)
return nil
}

View File

@ -7,8 +7,7 @@ import (
"testing"
"github.com/docker/cli/internal/test"
"github.com/docker/docker/api/types"
volumetypes "github.com/docker/docker/api/types/volume"
"github.com/docker/docker/api/types/volume"
"github.com/pkg/errors"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
@ -18,7 +17,7 @@ func TestVolumeCreateErrors(t *testing.T) {
testCases := []struct {
args []string
flags map[string]string
volumeCreateFunc func(volumetypes.VolumeCreateBody) (types.Volume, error)
volumeCreateFunc func(volume.CreateOptions) (volume.Volume, error)
expectedError string
}{
{
@ -33,8 +32,8 @@ func TestVolumeCreateErrors(t *testing.T) {
expectedError: "requires at most 1 argument",
},
{
volumeCreateFunc: func(createBody volumetypes.VolumeCreateBody) (types.Volume, error) {
return types.Volume{}, errors.Errorf("error creating volume")
volumeCreateFunc: func(createBody volume.CreateOptions) (volume.Volume, error) {
return volume.Volume{}, errors.Errorf("error creating volume")
},
expectedError: "error creating volume",
},
@ -57,11 +56,11 @@ func TestVolumeCreateErrors(t *testing.T) {
func TestVolumeCreateWithName(t *testing.T) {
name := "foo"
cli := test.NewFakeCli(&fakeClient{
volumeCreateFunc: func(body volumetypes.VolumeCreateBody) (types.Volume, error) {
volumeCreateFunc: func(body volume.CreateOptions) (volume.Volume, error) {
if body.Name != name {
return types.Volume{}, errors.Errorf("expected name %q, got %q", name, body.Name)
return volume.Volume{}, errors.Errorf("expected name %q, got %q", name, body.Name)
}
return types.Volume{
return volume.Volume{
Name: body.Name,
}, nil
},
@ -96,20 +95,20 @@ func TestVolumeCreateWithFlags(t *testing.T) {
name := "banana"
cli := test.NewFakeCli(&fakeClient{
volumeCreateFunc: func(body volumetypes.VolumeCreateBody) (types.Volume, error) {
volumeCreateFunc: func(body volume.CreateOptions) (volume.Volume, error) {
if body.Name != "" {
return types.Volume{}, errors.Errorf("expected empty name, got %q", body.Name)
return volume.Volume{}, errors.Errorf("expected empty name, got %q", body.Name)
}
if body.Driver != expectedDriver {
return types.Volume{}, errors.Errorf("expected driver %q, got %q", expectedDriver, body.Driver)
return volume.Volume{}, errors.Errorf("expected driver %q, got %q", expectedDriver, body.Driver)
}
if !reflect.DeepEqual(body.DriverOpts, expectedOpts) {
return types.Volume{}, errors.Errorf("expected drivers opts %v, got %v", expectedOpts, body.DriverOpts)
return volume.Volume{}, errors.Errorf("expected drivers opts %v, got %v", expectedOpts, body.DriverOpts)
}
if !reflect.DeepEqual(body.Labels, expectedLabels) {
return types.Volume{}, errors.Errorf("expected labels %v, got %v", expectedLabels, body.Labels)
return volume.Volume{}, errors.Errorf("expected labels %v, got %v", expectedLabels, body.Labels)
}
return types.Volume{
return volume.Volume{
Name: name,
}, nil
},

View File

@ -7,7 +7,7 @@ import (
"github.com/docker/cli/internal/test"
. "github.com/docker/cli/internal/test/builders" // Import builders to get the builder function as package function
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/volume"
"github.com/pkg/errors"
"gotest.tools/v3/assert"
"gotest.tools/v3/golden"
@ -17,7 +17,7 @@ func TestVolumeInspectErrors(t *testing.T) {
testCases := []struct {
args []string
flags map[string]string
volumeInspectFunc func(volumeID string) (types.Volume, error)
volumeInspectFunc func(volumeID string) (volume.Volume, error)
expectedError string
}{
{
@ -25,8 +25,8 @@ func TestVolumeInspectErrors(t *testing.T) {
},
{
args: []string{"foo"},
volumeInspectFunc: func(volumeID string) (types.Volume, error) {
return types.Volume{}, errors.Errorf("error while inspecting the volume")
volumeInspectFunc: func(volumeID string) (volume.Volume, error) {
return volume.Volume{}, errors.Errorf("error while inspecting the volume")
},
expectedError: "error while inspecting the volume",
},
@ -39,13 +39,13 @@ func TestVolumeInspectErrors(t *testing.T) {
},
{
args: []string{"foo", "bar"},
volumeInspectFunc: func(volumeID string) (types.Volume, error) {
volumeInspectFunc: func(volumeID string) (volume.Volume, error) {
if volumeID == "foo" {
return types.Volume{
return volume.Volume{
Name: "foo",
}, nil
}
return types.Volume{}, errors.Errorf("error while inspecting the volume")
return volume.Volume{}, errors.Errorf("error while inspecting the volume")
},
expectedError: "error while inspecting the volume",
},
@ -69,14 +69,14 @@ func TestVolumeInspectWithoutFormat(t *testing.T) {
testCases := []struct {
name string
args []string
volumeInspectFunc func(volumeID string) (types.Volume, error)
volumeInspectFunc func(volumeID string) (volume.Volume, error)
}{
{
name: "single-volume",
args: []string{"foo"},
volumeInspectFunc: func(volumeID string) (types.Volume, error) {
volumeInspectFunc: func(volumeID string) (volume.Volume, error) {
if volumeID != "foo" {
return types.Volume{}, errors.Errorf("Invalid volumeID, expected %s, got %s", "foo", volumeID)
return volume.Volume{}, errors.Errorf("Invalid volumeID, expected %s, got %s", "foo", volumeID)
}
return *Volume(), nil
},
@ -84,7 +84,7 @@ func TestVolumeInspectWithoutFormat(t *testing.T) {
{
name: "multiple-volume-with-labels",
args: []string{"foo", "bar"},
volumeInspectFunc: func(volumeID string) (types.Volume, error) {
volumeInspectFunc: func(volumeID string) (volume.Volume, error) {
return *Volume(VolumeName(volumeID), VolumeLabels(map[string]string{
"foo": "bar",
})), nil
@ -103,7 +103,7 @@ func TestVolumeInspectWithoutFormat(t *testing.T) {
}
func TestVolumeInspectWithFormat(t *testing.T) {
volumeInspectFunc := func(volumeID string) (types.Volume, error) {
volumeInspectFunc := func(volumeID string) (volume.Volume, error) {
return *Volume(VolumeLabels(map[string]string{
"foo": "bar",
})), nil
@ -112,7 +112,7 @@ func TestVolumeInspectWithFormat(t *testing.T) {
name string
format string
args []string
volumeInspectFunc func(volumeID string) (types.Volume, error)
volumeInspectFunc func(volumeID string) (volume.Volume, error)
}{
{
name: "simple-template",

View File

@ -7,9 +7,8 @@ import (
"github.com/docker/cli/cli/config/configfile"
"github.com/docker/cli/internal/test"
. "github.com/docker/cli/internal/test/builders" // Import builders to get the builder function as package function
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters"
volumetypes "github.com/docker/docker/api/types/volume"
"github.com/docker/docker/api/types/volume"
"github.com/pkg/errors"
"gotest.tools/v3/assert"
"gotest.tools/v3/golden"
@ -19,7 +18,7 @@ func TestVolumeListErrors(t *testing.T) {
testCases := []struct {
args []string
flags map[string]string
volumeListFunc func(filter filters.Args) (volumetypes.VolumeListOKBody, error)
volumeListFunc func(filter filters.Args) (volume.ListResponse, error)
expectedError string
}{
{
@ -27,8 +26,8 @@ func TestVolumeListErrors(t *testing.T) {
expectedError: "accepts no argument",
},
{
volumeListFunc: func(filter filters.Args) (volumetypes.VolumeListOKBody, error) {
return volumetypes.VolumeListOKBody{}, errors.Errorf("error listing volumes")
volumeListFunc: func(filter filters.Args) (volume.ListResponse, error) {
return volume.ListResponse{}, errors.Errorf("error listing volumes")
},
expectedError: "error listing volumes",
},
@ -50,9 +49,9 @@ func TestVolumeListErrors(t *testing.T) {
func TestVolumeListWithoutFormat(t *testing.T) {
cli := test.NewFakeCli(&fakeClient{
volumeListFunc: func(filter filters.Args) (volumetypes.VolumeListOKBody, error) {
return volumetypes.VolumeListOKBody{
Volumes: []*types.Volume{
volumeListFunc: func(filter filters.Args) (volume.ListResponse, error) {
return volume.ListResponse{
Volumes: []*volume.Volume{
Volume(),
Volume(VolumeName("foo"), VolumeDriver("bar")),
Volume(VolumeName("baz"), VolumeLabels(map[string]string{
@ -69,9 +68,9 @@ func TestVolumeListWithoutFormat(t *testing.T) {
func TestVolumeListWithConfigFormat(t *testing.T) {
cli := test.NewFakeCli(&fakeClient{
volumeListFunc: func(filter filters.Args) (volumetypes.VolumeListOKBody, error) {
return volumetypes.VolumeListOKBody{
Volumes: []*types.Volume{
volumeListFunc: func(filter filters.Args) (volume.ListResponse, error) {
return volume.ListResponse{
Volumes: []*volume.Volume{
Volume(),
Volume(VolumeName("foo"), VolumeDriver("bar")),
Volume(VolumeName("baz"), VolumeLabels(map[string]string{
@ -91,9 +90,9 @@ func TestVolumeListWithConfigFormat(t *testing.T) {
func TestVolumeListWithFormat(t *testing.T) {
cli := test.NewFakeCli(&fakeClient{
volumeListFunc: func(filter filters.Args) (volumetypes.VolumeListOKBody, error) {
return volumetypes.VolumeListOKBody{
Volumes: []*types.Volume{
volumeListFunc: func(filter filters.Args) (volume.ListResponse, error) {
return volume.ListResponse{
Volumes: []*volume.Volume{
Volume(),
Volume(VolumeName("foo"), VolumeDriver("bar")),
Volume(VolumeName("baz"), VolumeLabels(map[string]string{
@ -111,9 +110,9 @@ func TestVolumeListWithFormat(t *testing.T) {
func TestVolumeListSortOrder(t *testing.T) {
cli := test.NewFakeCli(&fakeClient{
volumeListFunc: func(filter filters.Args) (volumetypes.VolumeListOKBody, error) {
return volumetypes.VolumeListOKBody{
Volumes: []*types.Volume{
volumeListFunc: func(filter filters.Args) (volume.ListResponse, error) {
return volume.ListResponse{
Volumes: []*volume.Volume{
Volume(VolumeName("volume-2-foo")),
Volume(VolumeName("volume-10-foo")),
Volume(VolumeName("volume-1-foo")),

View File

@ -1,13 +1,11 @@
package builders
import (
"github.com/docker/docker/api/types"
)
import "github.com/docker/docker/api/types/volume"
// Volume creates a volume with default values.
// Any number of volume function builder can be passed to augment it.
func Volume(builders ...func(volume *types.Volume)) *types.Volume {
volume := &types.Volume{
func Volume(builders ...func(volume *volume.Volume)) *volume.Volume {
vol := &volume.Volume{
Name: "volume",
Driver: "local",
Mountpoint: "/data/volume",
@ -15,29 +13,29 @@ func Volume(builders ...func(volume *types.Volume)) *types.Volume {
}
for _, builder := range builders {
builder(volume)
builder(vol)
}
return volume
return vol
}
// VolumeLabels sets the volume labels
func VolumeLabels(labels map[string]string) func(volume *types.Volume) {
return func(volume *types.Volume) {
func VolumeLabels(labels map[string]string) func(volume *volume.Volume) {
return func(volume *volume.Volume) {
volume.Labels = labels
}
}
// VolumeName sets the volume labels
func VolumeName(name string) func(volume *types.Volume) {
return func(volume *types.Volume) {
func VolumeName(name string) func(volume *volume.Volume) {
return func(volume *volume.Volume) {
volume.Name = name
}
}
// VolumeDriver sets the volume driver
func VolumeDriver(name string) func(volume *types.Volume) {
return func(volume *types.Volume) {
func VolumeDriver(name string) func(volume *volume.Volume) {
return func(volume *volume.Volume) {
volume.Driver = name
}
}

View File

@ -76,6 +76,6 @@ require (
)
replace (
github.com/docker/docker => github.com/docker/docker v20.10.3-0.20220326171151-8941dcfcc5db+incompatible // master (v22.04-dev)
github.com/docker/docker => github.com/docker/docker v20.10.3-0.20220429181837-2ed904cad705+incompatible // master (v22.04-dev)
github.com/gogo/googleapis => github.com/gogo/googleapis v1.3.2
)

View File

@ -105,8 +105,8 @@ github.com/denisenkom/go-mssqldb v0.0.0-20191128021309-1d7a30a10f73/go.mod h1:xb
github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/distribution v2.8.1+incompatible h1:Q50tZOPR6T/hjNsyc9g8/syEs6bk8XXApsHjKukMl68=
github.com/docker/distribution v2.8.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/docker v20.10.3-0.20220326171151-8941dcfcc5db+incompatible h1:5DYFLB020CbxyjsxBle60QaEUb4krFjr30O0eLXsNp0=
github.com/docker/docker v20.10.3-0.20220326171151-8941dcfcc5db+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker v20.10.3-0.20220429181837-2ed904cad705+incompatible h1:Bs9PQ1/7QUa5bvhBiQNK2b39Ve3gU1o0Lr4ZfNUk1gc=
github.com/docker/docker v20.10.3-0.20220429181837-2ed904cad705+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker-credential-helpers v0.6.4 h1:axCks+yV+2MR3/kZhAmy07yC56WZ2Pwu/fKWtKuZB0o=
github.com/docker/docker-credential-helpers v0.6.4/go.mod h1:ofX3UI0Gz1TteYBjtgs07O36Pyasyp66D2uKT7H8W1c=
github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c h1:lzqkGL9b3znc+ZUgi7FlLnqjQhcXxkNM/quxIjBVMD0=

View File

@ -7,7 +7,7 @@ Aaron Feng <aaron.feng@gmail.com>
Aaron Hnatiw <aaron@griddio.com>
Aaron Huslage <huslage@gmail.com>
Aaron L. Xu <liker.xu@foxmail.com>
Aaron Lehmann <aaron.lehmann@docker.com>
Aaron Lehmann <alehmann@netflix.com>
Aaron Welch <welch@packet.net>
Aaron.L.Xu <likexu@harmonycloud.cn>
Abel Muiño <amuino@gmail.com>
@ -61,10 +61,11 @@ Alan Scherger <flyinprogrammer@gmail.com>
Alan Thompson <cloojure@gmail.com>
Albert Callarisa <shark234@gmail.com>
Albert Zhang <zhgwenming@gmail.com>
Albin Kerouanton <albin@akerouanton.name>
Albin Kerouanton <albinker@gmail.com>
Alec Benson <albenson@redhat.com>
Alejandro González Hevia <alejandrgh11@gmail.com>
Aleksa Sarai <asarai@suse.de>
Aleksandr Chebotov <v-aleche@microsoft.com>
Aleksandrs Fadins <aleks@s-ko.net>
Alena Prokharchyk <alena@rancher.com>
Alessandro Boch <aboch@tetrationanalytics.com>
@ -76,6 +77,7 @@ Alex Crawford <alex.crawford@coreos.com>
Alex Ellis <alexellis2@gmail.com>
Alex Gaynor <alex.gaynor@gmail.com>
Alex Goodman <wagoodman@gmail.com>
Alex Nordlund <alexander.nordlund@nasdaq.com>
Alex Olshansky <i@creagenics.com>
Alex Samorukov <samm@os2.kiev.ua>
Alex Warhawk <ax.warhawk@gmail.com>
@ -83,7 +85,7 @@ Alexander Artemenko <svetlyak.40wt@gmail.com>
Alexander Boyd <alex@opengroove.org>
Alexander Larsson <alexl@redhat.com>
Alexander Midlash <amidlash@docker.com>
Alexander Morozov <lk4d4@docker.com>
Alexander Morozov <lk4d4math@gmail.com>
Alexander Polakov <plhk@sdf.org>
Alexander Shopov <ash@kambanaria.org>
Alexandre Beslic <alexandre.beslic@gmail.com>
@ -192,13 +194,15 @@ Antony Messerli <amesserl@rackspace.com>
Anuj Bahuguna <anujbahuguna.dev@gmail.com>
Anuj Varma <anujvarma@thumbtack.com>
Anusha Ragunathan <anusha.ragunathan@docker.com>
Anyu Wang <wanganyu@outlook.com>
apocas <petermdias@gmail.com>
Arash Deshmeh <adeshmeh@ca.ibm.com>
ArikaChen <eaglesora@gmail.com>
Arko Dasgupta <arko.dasgupta@docker.com>
Arko Dasgupta <arko@tetrate.io>
Arnaud Lefebvre <a.lefebvre@outlook.fr>
Arnaud Porterie <arnaud.porterie@docker.com>
Arnaud Porterie <icecrime@gmail.com>
Arnaud Rebillout <arnaud.rebillout@collabora.com>
Artem Khramov <akhramov@pm.me>
Arthur Barr <arthur.barr@uk.ibm.com>
Arthur Gautier <baloo@gandi.net>
Artur Meyster <arthurfbi@yahoo.com>
@ -343,6 +347,7 @@ Chen Qiu <cheney-90@hotmail.com>
Cheng-mean Liu <soccerl@microsoft.com>
Chengfei Shang <cfshang@alauda.io>
Chengguang Xu <cgxu519@gmx.com>
Chenyang Yan <memory.yancy@gmail.com>
chenyuzhu <chenyuzhi@oschina.cn>
Chetan Birajdar <birajdar.chetan@gmail.com>
Chewey <prosto-chewey@users.noreply.github.com>
@ -406,20 +411,23 @@ Colin Walters <walters@verbum.org>
Collin Guarino <collin.guarino@gmail.com>
Colm Hally <colmhally@gmail.com>
companycy <companycy@gmail.com>
Conor Evans <coevans@tcd.ie>
Corbin Coleman <corbin.coleman@docker.com>
Corey Farrell <git@cfware.com>
Cory Forsyth <cory.forsyth@gmail.com>
Cory Snider <csnider@mirantis.com>
cressie176 <github@stephen-cresswell.net>
CrimsonGlory <CrimsonGlory@users.noreply.github.com>
Cristian Ariza <dev@cristianrz.com>
Cristian Staretu <cristian.staretu@gmail.com>
cristiano balducci <cristiano.balducci@gmail.com>
Cristina Yenyxe Gonzalez Garcia <cristina.yenyxe@gmail.com>
Cruceru Calin-Cristian <crucerucalincristian@gmail.com>
CUI Wei <ghostplant@qq.com>
cuishuang <imcusg@gmail.com>
Cuong Manh Le <cuong.manhle.vn@gmail.com>
Cyprian Gracz <cyprian.gracz@micro-jumbo.eu>
Cyril F <cyrilf7x@gmail.com>
Da McGrady <dabkb@aol.com>
Daan van Berkel <daan.v.berkel.1980@gmail.com>
Daehyeok Mun <daehyeok@gmail.com>
Dafydd Crosby <dtcrsby@gmail.com>
@ -437,6 +445,7 @@ Dan Hirsch <thequux@upstandinghackers.com>
Dan Keder <dan.keder@gmail.com>
Dan Levy <dan@danlevy.net>
Dan McPherson <dmcphers@redhat.com>
Dan Plamadeala <cornul11@gmail.com>
Dan Stine <sw@stinemail.com>
Dan Williams <me@deedubs.com>
Dani Hodovic <dani.hodovic@gmail.com>
@ -457,6 +466,7 @@ Daniel Mizyrycki <daniel.mizyrycki@dotcloud.com>
Daniel Nephin <dnephin@docker.com>
Daniel Norberg <dano@spotify.com>
Daniel Nordberg <dnordberg@gmail.com>
Daniel P. Berrangé <berrange@redhat.com>
Daniel Robinson <gottagetmac@gmail.com>
Daniel S <dan.streby@gmail.com>
Daniel Sweet <danieljsweet@icloud.com>
@ -465,6 +475,7 @@ Daniel Watkins <daniel@daniel-watkins.co.uk>
Daniel X Moore <yahivin@gmail.com>
Daniel YC Lin <dlin.tw@gmail.com>
Daniel Zhang <jmzwcn@gmail.com>
Daniele Rondina <geaaru@sabayonlinux.org>
Danny Berger <dpb587@gmail.com>
Danny Milosavljevic <dannym@scratchpost.org>
Danny Yates <danny@codeaholics.org>
@ -530,7 +541,7 @@ Dennis Docter <dennis@d23.nl>
Derek <crq@kernel.org>
Derek <crquan@gmail.com>
Derek Ch <denc716@gmail.com>
Derek McGowan <derek@mcgstyle.net>
Derek McGowan <derek@mcg.dev>
Deric Crago <deric.crago@gmail.com>
Deshi Xiao <dxiao@redhat.com>
devmeyster <arthurfbi@yahoo.com>
@ -550,9 +561,11 @@ Dimitris Rozakis <dimrozakis@gmail.com>
Dimitry Andric <d.andric@activevideo.com>
Dinesh Subhraveti <dineshs@altiscale.com>
Ding Fei <dingfei@stars.org.cn>
dingwei <dingwei@cmss.chinamobile.com>
Diogo Monica <diogo@docker.com>
DiuDiugirl <sophia.wang@pku.edu.cn>
Djibril Koné <kone.djibril@gmail.com>
Djordje Lukic <djordje.lukic@docker.com>
dkumor <daniel@dkumor.com>
Dmitri Logvinenko <dmitri.logvinenko@gmail.com>
Dmitri Shuralyov <shurcooL@gmail.com>
@ -601,6 +614,7 @@ Elango Sivanandam <elango.siva@docker.com>
Elena Morozova <lelenanam@gmail.com>
Eli Uriegas <seemethere101@gmail.com>
Elias Faxö <elias.faxo@tre.se>
Elias Koromilas <elias.koromilas@gmail.com>
Elias Probst <mail@eliasprobst.eu>
Elijah Zupancic <elijah@zupancic.name>
eluck <mail@eluck.me>
@ -610,6 +624,7 @@ Emil Hernvall <emil@quench.at>
Emily Maier <emily@emilymaier.net>
Emily Rose <emily@contactvibe.com>
Emir Ozer <emirozer@yandex.com>
Eng Zer Jun <engzerjun@gmail.com>
Enguerran <engcolson@gmail.com>
Eohyung Lee <liquidnuker@gmail.com>
epeterso <epeterson@breakpoint-labs.com>
@ -724,11 +739,14 @@ Frederik Loeffert <frederik@zitrusmedia.de>
Frederik Nordahl Jul Sabroe <frederikns@gmail.com>
Freek Kalter <freek@kalteronline.org>
Frieder Bluemle <frieder.bluemle@gmail.com>
frobnicaty <92033765+frobnicaty@users.noreply.github.com>
Frédéric Dalleau <frederic.dalleau@docker.com>
Fu JinLin <withlin@yeah.net>
Félix Baylac-Jacqué <baylac.felix@gmail.com>
Félix Cantournet <felix.cantournet@cloudwatt.com>
Gabe Rosenhouse <gabe@missionst.com>
Gabor Nagy <mail@aigeruth.hu>
Gabriel Goller <gabrielgoller123@gmail.com>
Gabriel L. Somlo <gsomlo@gmail.com>
Gabriel Linder <linder.gabriel@gmail.com>
Gabriel Monroy <gabriel@opdemand.com>
@ -751,6 +769,7 @@ George Kontridze <george@bugsnag.com>
George MacRorie <gmacr31@gmail.com>
George Xie <georgexsh@gmail.com>
Georgi Hristozov <georgi@forkbomb.nl>
Georgy Yakovlev <gyakovlev@gentoo.org>
Gereon Frey <gereon.frey@dynport.de>
German DZ <germ@ndz.com.ar>
Gert van Valkenhoef <g.h.m.van.valkenhoef@rug.nl>
@ -762,6 +781,7 @@ Gildas Cuisinier <gildas.cuisinier@gcuisinier.net>
Giovan Isa Musthofa <giovanism@outlook.co.id>
gissehel <public-devgit-dantus@gissehel.org>
Giuseppe Mazzotta <gdm85@users.noreply.github.com>
Giuseppe Scrivano <gscrivan@redhat.com>
Gleb Fotengauer-Malinovskiy <glebfm@altlinux.org>
Gleb M Borisov <borisov.gleb@gmail.com>
Glyn Normington <gnormington@gopivotal.com>
@ -785,6 +805,7 @@ Guilherme Salgado <gsalgado@gmail.com>
Guillaume Dufour <gdufour.prestataire@voyages-sncf.com>
Guillaume J. Charmes <guillaume.charmes@docker.com>
Gunadhya S. <6939749+gunadhya@users.noreply.github.com>
Guoqiang QI <guoqiang.qi1@gmail.com>
guoxiuyan <guoxiuyan@huawei.com>
Guri <odg0318@gmail.com>
Gurjeet Singh <gurjeet@singh.im>
@ -794,6 +815,7 @@ gwx296173 <gaojing3@huawei.com>
Günter Zöchbauer <guenter@gzoechbauer.com>
Haichao Yang <yang.haichao@zte.com.cn>
haikuoliu <haikuo@amazon.com>
haining.cao <haining.cao@daocloud.io>
Hakan Özler <hakan.ozler@kodcu.com>
Hamish Hutchings <moredhel@aoeu.me>
Hannes Ljungberg <hannes@5monkeys.se>
@ -889,6 +911,7 @@ Jake Champlin <jake.champlin.27@gmail.com>
Jake Moshenko <jake@devtable.com>
Jake Sanders <jsand@google.com>
Jakub Drahos <jdrahos@pulsepoint.com>
Jakub Guzik <jakubmguzik@gmail.com>
James Allen <jamesallen0108@gmail.com>
James Carey <jecarey@us.ibm.com>
James Carr <james.r.carr@gmail.com>
@ -900,6 +923,7 @@ James Lal <james@lightsofapollo.com>
James Mills <prologic@shortcircuit.net.au>
James Nesbitt <jnesbitt@mirantis.com>
James Nugent <james@jen20.com>
James Sanders <james3sanders@gmail.com>
James Turnbull <james@lovedthanlost.net>
James Watkins-Harvey <jwatkins@progi-media.com>
Jamie Hannaford <jamie@limetree.org>
@ -932,6 +956,7 @@ Jason Shepherd <jason@jasonshepherd.net>
Jason Smith <jasonrichardsmith@gmail.com>
Jason Sommer <jsdirv@gmail.com>
Jason Stangroome <jason@codeassassin.com>
Javier Bassi <javierbassi@gmail.com>
jaxgeller <jacksongeller@gmail.com>
Jay <imjching@hotmail.com>
Jay <teguhwpurwanto@gmail.com>
@ -1100,6 +1125,7 @@ Justas Brazauskas <brazauskasjustas@gmail.com>
Justen Martin <jmart@the-coder.com>
Justin Cormack <justin.cormack@docker.com>
Justin Force <justin.force@gmail.com>
Justin Keller <85903732+jk-vb@users.noreply.github.com>
Justin Menga <justin.menga@gmail.com>
Justin Plock <jplock@users.noreply.github.com>
Justin Simonelis <justin.p.simonelis@gmail.com>
@ -1148,6 +1174,7 @@ Kenjiro Nakayama <nakayamakenjiro@gmail.com>
Kent Johnson <kentoj@gmail.com>
Kenta Tada <Kenta.Tada@sony.com>
Kevin "qwazerty" Houdebert <kevin.houdebert@gmail.com>
Kevin Alvarez <crazy-max@users.noreply.github.com>
Kevin Burke <kev@inburke.com>
Kevin Clark <kevin.clark@gmail.com>
Kevin Feyrer <kevin.feyrer@btinternet.com>
@ -1332,6 +1359,7 @@ Markus Fix <lispmeister@gmail.com>
Markus Kortlang <hyp3rdino@googlemail.com>
Martijn Dwars <ikben@martijndwars.nl>
Martijn van Oosterhout <kleptog@svana.org>
Martin Dojcak <martin.dojcak@lablabs.io>
Martin Honermeyer <maze@strahlungsfrei.de>
Martin Kelly <martin@surround.io>
Martin Mosegaard Amdisen <martin.amdisen@praqma.com>
@ -1348,6 +1376,7 @@ Mathias Monnerville <mathias@monnerville.com>
Mathieu Champlon <mathieu.champlon@docker.com>
Mathieu Le Marec - Pasquet <kiorky@cryptelium.net>
Mathieu Parent <math.parent@gmail.com>
Mathieu Paturel <mathieu.paturel@gmail.com>
Matt Apperson <me@mattapperson.com>
Matt Bachmann <bachmann.matt@gmail.com>
Matt Bajor <matt@notevenremotelydorky.com>
@ -1356,6 +1385,7 @@ Matt Haggard <haggardii@gmail.com>
Matt Hoyle <matt@deployable.co>
Matt McCormick <matt.mccormick@kitware.com>
Matt Moore <mattmoor@google.com>
Matt Morrison <3maven@gmail.com>
Matt Richardson <matt@redgumtech.com.au>
Matt Rickard <mrick@google.com>
Matt Robenolt <matt@ydekproductions.com>
@ -1400,7 +1430,7 @@ Michael Beskin <mrbeskin@gmail.com>
Michael Bridgen <mikeb@squaremobius.net>
Michael Brown <michael@netdirect.ca>
Michael Chiang <mchiang@docker.com>
Michael Crosby <michael@docker.com>
Michael Crosby <crosbymichael@gmail.com>
Michael Currie <mcurrie@bruceforceresearch.com>
Michael Friis <friism@gmail.com>
Michael Gorsuch <gorsuch@github.com>
@ -1409,6 +1439,7 @@ Michael Holzheu <holzheu@linux.vnet.ibm.com>
Michael Hudson-Doyle <michael.hudson@canonical.com>
Michael Huettermann <michael@huettermann.net>
Michael Irwin <mikesir87@gmail.com>
Michael Kuehn <micha@kuehn.io>
Michael Käufl <docker@c.michael-kaeufl.de>
Michael Neale <michael.neale@gmail.com>
Michael Nussbaum <michael.nussbaum@getbraintree.com>
@ -1418,6 +1449,7 @@ Michael Spetsiotis <michael_spets@hotmail.com>
Michael Stapelberg <michael+gh@stapelberg.de>
Michael Steinert <mike.steinert@gmail.com>
Michael Thies <michaelthies78@gmail.com>
Michael Weidmann <michaelweidmann@web.de>
Michael West <mwest@mdsol.com>
Michael Zhao <michael.zhao@arm.com>
Michal Fojtik <mfojtik@redhat.com>
@ -1458,6 +1490,7 @@ Mike Snitzer <snitzer@redhat.com>
mikelinjie <294893458@qq.com>
Mikhail Sobolev <mss@mawhrin.net>
Miklos Szegedi <miklos.szegedi@cloudera.com>
Milas Bowman <milasb@gmail.com>
Milind Chawre <milindchawre@gmail.com>
Miloslav Trmač <mitr@redhat.com>
mingqing <limingqing@cyou-inc.com>
@ -1533,6 +1566,7 @@ Nicolas Kaiser <nikai@nikai.net>
Nicolas Sterchele <sterchele.nicolas@gmail.com>
Nicolas V Castet <nvcastet@us.ibm.com>
Nicolás Hock Isaza <nhocki@gmail.com>
Niel Drummond <niel@drummond.lu>
Nigel Poulton <nigelpoulton@hotmail.com>
Nik Nyby <nikolas@gnu.org>
Nikhil Chawla <chawlanikhil24@gmail.com>
@ -1621,6 +1655,7 @@ Peng Tao <bergwolf@gmail.com>
Penghan Wang <ph.wang@daocloud.io>
Per Weijnitz <per.weijnitz@gmail.com>
perhapszzy@sina.com <perhapszzy@sina.com>
Pete Woods <pete.woods@circleci.com>
Peter Bourgon <peter@bourgon.org>
Peter Braden <peterbraden@peterbraden.co.uk>
Peter Bücker <peter.buecker@pressrelations.de>
@ -1638,7 +1673,7 @@ Peter Waller <p@pwaller.net>
Petr Švihlík <svihlik.petr@gmail.com>
Petros Angelatos <petrosagg@gmail.com>
Phil <underscorephil@gmail.com>
Phil Estes <estesp@linux.vnet.ibm.com>
Phil Estes <estesp@gmail.com>
Phil Spitler <pspitler@gmail.com>
Philip Alexander Etling <paetling@gmail.com>
Philip Monroe <phil@philmonroe.com>
@ -1707,6 +1742,7 @@ Renaud Gaubert <rgaubert@nvidia.com>
Rhys Hiltner <rhys@twitch.tv>
Ri Xu <xuri.me@gmail.com>
Ricardo N Feliciano <FelicianoTech@gmail.com>
Rich Horwood <rjhorwood@apple.com>
Rich Moyse <rich@moyse.us>
Rich Seymour <rseymour@gmail.com>
Richard <richard.scothern@gmail.com>
@ -1731,6 +1767,7 @@ Robert Bachmann <rb@robertbachmann.at>
Robert Bittle <guywithnose@gmail.com>
Robert Obryk <robryk@gmail.com>
Robert Schneider <mail@shakeme.info>
Robert Shade <robert.shade@gmail.com>
Robert Stern <lexandro2000@gmail.com>
Robert Terhaar <rterhaar@atlanticdynamic.com>
Robert Wallis <smilingrob@gmail.com>
@ -1743,6 +1780,7 @@ Robin Speekenbrink <robin@kingsquare.nl>
Robin Thoni <robin@rthoni.com>
robpc <rpcann@gmail.com>
Rodolfo Carvalho <rhcarvalho@gmail.com>
Rodrigo Campos <rodrigo@kinvolk.io>
Rodrigo Vaz <rodrigo.vaz@gmail.com>
Roel Van Nyen <roel.vannyen@gmail.com>
Roger Peppe <rogpeppe@gmail.com>
@ -1757,6 +1795,8 @@ Roma Sokolov <sokolov.r.v@gmail.com>
Roman Dudin <katrmr@gmail.com>
Roman Mazur <roman@balena.io>
Roman Strashkin <roman.strashkin@gmail.com>
Roman Volosatovs <roman.volosatovs@docker.com>
Roman Zabaluev <gpg@haarolean.dev>
Ron Smits <ron.smits@gmail.com>
Ron Williams <ron.a.williams@gmail.com>
Rong Gao <gaoronggood@163.com>
@ -1790,6 +1830,7 @@ Ryan Liu <ryanlyy@me.com>
Ryan McLaughlin <rmclaughlin@insidesales.com>
Ryan O'Donnell <odonnellryanc@gmail.com>
Ryan Seto <ryanseto@yak.net>
Ryan Shea <sheabot03@gmail.com>
Ryan Simmen <ryan.simmen@gmail.com>
Ryan Stelly <ryan.stelly@live.com>
Ryan Thomas <rthomas@atlassian.com>
@ -1822,8 +1863,9 @@ Sambuddha Basu <sambuddhabasu1@gmail.com>
Sami Wagiaalla <swagiaal@redhat.com>
Samuel Andaya <samuel@andaya.net>
Samuel Dion-Girardeau <samuel.diongirardeau@gmail.com>
Samuel Karp <skarp@amazon.com>
Samuel Karp <me@samuelkarp.com>
Samuel PHAN <samuel-phan@users.noreply.github.com>
sanchayanghosh <sanchayanghosh@outlook.com>
Sandeep Bansal <sabansal@microsoft.com>
Sankar சங்கர் <sankar.curiosity@gmail.com>
Sanket Saurav <sanketsaurav@gmail.com>
@ -1881,6 +1923,7 @@ Shengbo Song <thomassong@tencent.com>
Shengjing Zhu <zhsj@debian.org>
Shev Yan <yandong_8212@163.com>
Shih-Yuan Lee <fourdollars@gmail.com>
Shihao Xia <charlesxsh@hotmail.com>
Shijiang Wei <mountkin@gmail.com>
Shijun Qin <qinshijun16@mails.ucas.ac.cn>
Shishir Mahajan <shishir.mahajan@redhat.com>
@ -1933,6 +1976,7 @@ Stefan S. <tronicum@user.github.com>
Stefan Scherer <stefan.scherer@docker.com>
Stefan Staudenmeyer <doerte@instana.com>
Stefan Weil <sw@weilnetz.de>
Steffen Butzer <steffen.butzer@outlook.com>
Stephan Spindler <shutefan@gmail.com>
Stephen Benjamin <stephen@redhat.com>
Stephen Crosby <stevecrozz@gmail.com>
@ -1951,6 +1995,7 @@ Steven Iveson <sjiveson@outlook.com>
Steven Merrill <steven.merrill@gmail.com>
Steven Richards <steven@axiomzen.co>
Steven Taylor <steven.taylor@me.com>
Stéphane Este-Gracias <sestegra@gmail.com>
Stig Larsson <stig@larsson.dev>
Su Wang <su.wang@docker.com>
Subhajit Ghosh <isubuz.g@gmail.com>
@ -1962,12 +2007,13 @@ Sunny Gogoi <indiasuny000@gmail.com>
Suryakumar Sudar <surya.trunks@gmail.com>
Sven Dowideit <SvenDowideit@home.org.au>
Swapnil Daingade <swapnil.daingade@gmail.com>
Sylvain Baubeau <sbaubeau@redhat.com>
Sylvain Baubeau <lebauce@gmail.com>
Sylvain Bellemare <sylvain@ascribe.io>
Sébastien <sebastien@yoozio.com>
Sébastien HOUZÉ <cto@verylastroom.com>
Sébastien Luttringer <seblu@seblu.net>
Sébastien Stormacq <sebsto@users.noreply.github.com>
Sören Tempel <soeren+git@soeren-tempel.net>
Tabakhase <mail@tabakhase.com>
Tadej Janež <tadej.j@nez.si>
TAGOMORI Satoshi <tagomoris@gmail.com>
@ -1996,6 +2042,7 @@ Thomas Gazagnaire <thomas@gazagnaire.org>
Thomas Graf <tgraf@suug.ch>
Thomas Grainger <tagrain@gmail.com>
Thomas Hansen <thomas.hansen@gmail.com>
Thomas Ledos <thomas.ledos92@gmail.com>
Thomas Leonard <thomas.leonard@docker.com>
Thomas Léveil <thomasleveil@gmail.com>
Thomas Orozco <thomas@orozco.fr>
@ -2064,9 +2111,11 @@ Tomas Tomecek <ttomecek@redhat.com>
Tomasz Kopczynski <tomek@kopczynski.net.pl>
Tomasz Lipinski <tlipinski@users.noreply.github.com>
Tomasz Nurkiewicz <nurkiewicz@gmail.com>
Tomek Mańko <tomek.manko@railgun-solutions.com>
Tommaso Visconti <tommaso.visconti@gmail.com>
Tomoya Tabuchi <t@tomoyat1.com>
Tomáš Hrčka <thrcka@redhat.com>
tonic <tonicbupt@gmail.com>
Tonny Xu <tonny.xu@gmail.com>
Tony Abboud <tdabboud@hotmail.com>
Tony Daws <tony@daws.ca>
@ -2196,6 +2245,7 @@ Wolfgang Powisch <powo@powo.priv.at>
Wonjun Kim <wonjun.kim@navercorp.com>
WuLonghui <wlh6666@qq.com>
xamyzhao <x.amy.zhao@gmail.com>
Xia Wu <xwumzn@amazon.com>
Xian Chaobo <xianchaobo@huawei.com>
Xianglin Gao <xlgao@zju.edu.cn>
Xianjie <guxianjie@gmail.com>
@ -2220,6 +2270,7 @@ Xuecong Liao <satorulogic@gmail.com>
xuzhaokui <cynicholas@gmail.com>
Yadnyawalkya Tale <ytale@redhat.com>
Yahya <ya7yaz@gmail.com>
yalpul <yalpul@gmail.com>
YAMADA Tsuyoshi <tyamada@minimum2scp.org>
Yamasaki Masahide <masahide.y@gmail.com>
Yan Feng <yanfeng2@huawei.com>
@ -2254,6 +2305,7 @@ Yu-Ju Hong <yjhong@google.com>
Yuan Sun <sunyuan3@huawei.com>
Yuanhong Peng <pengyuanhong@huawei.com>
Yue Zhang <zy675793960@yeah.net>
Yufei Xiong <yufei.xiong@qq.com>
Yuhao Fang <fangyuhao@gmail.com>
Yuichiro Kaneko <spiketeika@gmail.com>
YujiOshima <yuji.oshima0x3fd@gmail.com>

View File

@ -1154,6 +1154,13 @@ definitions:
ContainerConfig:
description: |
Configuration for a container that is portable between hosts.
When used as `ContainerConfig` field in an image, `ContainerConfig` is an
optional field containing the configuration of the container that was last
committed when creating the image.
Previous versions of Docker builder used this field to store build cache,
and it is not in active use anymore.
type: "object"
properties:
Hostname:
@ -1600,7 +1607,7 @@ definitions:
description: |
ID is the content-addressable ID of an image.
This identified is a content-addressable digest calculated from the
This identifier is a content-addressable digest calculated from the
image's configuration (which includes the digests of layers used by
the image).
@ -1788,41 +1795,119 @@ definitions:
- Containers
properties:
Id:
description: |
ID is the content-addressable ID of an image.
This identifier is a content-addressable digest calculated from the
image's configuration (which includes the digests of layers used by
the image).
Note that this digest differs from the `RepoDigests` below, which
holds digests of image manifests that reference the image.
type: "string"
x-nullable: false
example: "sha256:ec3f0931a6e6b6855d76b2d7b0be30e81860baccd891b2e243280bf1cd8ad710"
ParentId:
description: |
ID of the parent image.
Depending on how the image was created, this field may be empty and
is only set for images that were built/created locally. This field
is empty if the image was pulled from an image registry.
type: "string"
x-nullable: false
example: ""
RepoTags:
description: |
List of image names/tags in the local image cache that reference this
image.
Multiple image tags can refer to the same imagem and this list may be
empty if no tags reference the image, in which case the image is
"untagged", in which case it can still be referenced by its ID.
type: "array"
x-nullable: false
items:
type: "string"
example:
- "example:1.0"
- "example:latest"
- "example:stable"
- "internal.registry.example.com:5000/example:1.0"
RepoDigests:
description: |
List of content-addressable digests of locally available image manifests
that the image is referenced from. Multiple manifests can refer to the
same image.
These digests are usually only available if the image was either pulled
from a registry, or if the image was pushed to a registry, which is when
the manifest is generated and its digest calculated.
type: "array"
x-nullable: false
items:
type: "string"
example:
- "example@sha256:afcc7f1ac1b49db317a7196c902e61c6c3c4607d63599ee1a82d702d249a0ccb"
- "internal.registry.example.com:5000/example@sha256:b69959407d21e8a062e0416bf13405bb2b71ed7a84dde4158ebafacfa06f5578"
Created:
description: |
Date and time at which the image was created as a Unix timestamp
(number of seconds sinds EPOCH).
type: "integer"
x-nullable: false
example: "1644009612"
Size:
description: |
Total size of the image including all layers it is composed of.
type: "integer"
format: "int64"
x-nullable: false
example: 172064416
SharedSize:
description: |
Total size of image layers that are shared between this image and other
images.
This size is not calculated by default. `-1` indicates that the value
has not been set / calculated.
type: "integer"
x-nullable: false
example: 1239828
VirtualSize:
description: |
Total size of the image including all layers it is composed of.
In versions of Docker before v1.10, this field was calculated from
the image itself and all of its parent images. Docker v1.10 and up
store images self-contained, and no longer use a parent-chain, making
this field an equivalent of the Size field.
This field is kept for backward compatibility, but may be removed in
a future version of the API.
type: "integer"
format: "int64"
x-nullable: false
example: 172064416
Labels:
description: "User-defined key/value metadata."
type: "object"
x-nullable: false
additionalProperties:
type: "string"
example:
com.example.some-label: "some-value"
com.example.some-other-label: "some-other-value"
Containers:
description: |
Number of containers using this image. Includes both stopped and running
containers.
This size is not calculated by default, and depends on which API endpoint
is used. `-1` indicates that the value has not been set / calculated.
x-nullable: false
type: "integer"
example: 2
AuthConfig:
type: "object"
@ -1924,6 +2009,7 @@ definitions:
UsageData:
type: "object"
x-nullable: true
x-go-name: "UsageData"
required: [Size, RefCount]
description: |
Usage details about the volume. This information is used by the
@ -1950,7 +2036,7 @@ definitions:
description: "Volume configuration"
type: "object"
title: "VolumeConfig"
x-go-name: "VolumeCreateBody"
x-go-name: "CreateOptions"
properties:
Name:
description: |
@ -1984,6 +2070,25 @@ definitions:
com.example.some-label: "some-value"
com.example.some-other-label: "some-other-value"
VolumeListResponse:
type: "object"
title: "VolumeListResponse"
x-go-name: "ListResponse"
description: "Volume list response"
properties:
Volumes:
type: "array"
description: "List of volumes"
items:
$ref: "#/definitions/Volume"
Warnings:
type: "array"
description: |
Warnings that occurred when fetching the list of volumes.
items:
type: "string"
example: []
Network:
type: "object"
properties:
@ -4512,10 +4617,30 @@ definitions:
Health:
$ref: "#/definitions/Health"
ContainerCreateResponse:
description: "OK response to ContainerCreate operation"
type: "object"
title: "ContainerCreateResponse"
x-go-name: "CreateResponse"
required: [Id, Warnings]
properties:
Id:
description: "The ID of the created container"
type: "string"
x-nullable: false
example: "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743"
Warnings:
description: "Warnings encountered when creating the container"
type: "array"
x-nullable: false
items:
type: "string"
example: []
ContainerWaitResponse:
description: "OK response to ContainerWait operation"
type: "object"
x-go-name: "ContainerWaitOKBody"
x-go-name: "WaitResponse"
title: "ContainerWaitResponse"
required: [StatusCode, Error]
properties:
@ -4529,7 +4654,7 @@ definitions:
ContainerWaitExitError:
description: "container waiting error, if any"
type: "object"
x-go-name: "ContainerWaitOKBodyError"
x-go-name: "WaitExitError"
properties:
Message:
description: "Details of an error"
@ -5976,25 +6101,7 @@ paths:
201:
description: "Container created successfully"
schema:
type: "object"
title: "ContainerCreateResponse"
description: "OK response to ContainerCreate operation"
required: [Id, Warnings]
properties:
Id:
description: "The ID of the created container"
type: "string"
x-nullable: false
Warnings:
description: "Warnings encountered when creating the container"
type: "array"
x-nullable: false
items:
type: "string"
examples:
application/json:
Id: "e90e34656806"
Warnings: []
$ref: "#/definitions/ContainerCreateResponse"
400:
description: "bad parameter"
schema:
@ -6784,6 +6891,11 @@ paths:
required: true
description: "ID or name of the container"
type: "string"
- name: "signal"
in: "query"
description: |
Signal to send to the container as an integer or string (e.g. `SIGINT`).
type: "string"
- name: "t"
in: "query"
description: "Number of seconds to wait before killing the container"
@ -6813,6 +6925,11 @@ paths:
required: true
description: "ID or name of the container"
type: "string"
- name: "signal"
in: "query"
description: |
Signal to send to the container as an integer or string (e.g. `SIGINT`).
type: "string"
- name: "t"
in: "query"
description: "Number of seconds to wait before killing the container"
@ -6854,7 +6971,8 @@ paths:
type: "string"
- name: "signal"
in: "query"
description: "Signal to send to the container as an integer or string (e.g. `SIGINT`)"
description: |
Signal to send to the container as an integer or string (e.g. `SIGINT`).
type: "string"
default: "SIGKILL"
tags: ["Container"]
@ -7542,35 +7660,6 @@ paths:
type: "array"
items:
$ref: "#/definitions/ImageSummary"
examples:
application/json:
- Id: "sha256:e216a057b1cb1efc11f8a268f37ef62083e70b1b38323ba252e25ac88904a7e8"
ParentId: ""
RepoTags:
- "ubuntu:12.04"
- "ubuntu:precise"
RepoDigests:
- "ubuntu@sha256:992069aee4016783df6345315302fa59681aae51a8eeb2f889dea59290f21787"
Created: 1474925151
Size: 103579269
VirtualSize: 103579269
SharedSize: 0
Labels: {}
Containers: 2
- Id: "sha256:3e314f95dcace0f5e4fd37b10862fe8398e3c60ed36600bc0ca5fda78b087175"
ParentId: ""
RepoTags:
- "ubuntu:12.10"
- "ubuntu:quantal"
RepoDigests:
- "ubuntu@sha256:002fba3e3255af10be97ea26e476692a7ebed0bb074a9ab960b2e7a1526b15d7"
- "ubuntu@sha256:68ea0200f0b90df725d99d823905b04cf844f6039ef60c60bf3e019915017bd3"
Created: 1403128455
Size: 172064416
VirtualSize: 172064416
SharedSize: 0
Labels: {}
Containers: 5
500:
description: "server error"
schema:
@ -9078,24 +9167,7 @@ paths:
200:
description: "Summary volume data that matches the query"
schema:
type: "object"
title: "VolumeListResponse"
description: "Volume list response"
required: [Volumes, Warnings]
properties:
Volumes:
type: "array"
x-nullable: false
description: "List of volumes"
items:
$ref: "#/definitions/Volume"
Warnings:
type: "array"
x-nullable: false
description: |
Warnings that occurred when fetching the list of volumes.
items:
type: "string"
$ref: "#/definitions/VolumeListResponse"
500:
description: "Server error"
schema:

View File

@ -13,6 +13,24 @@ import (
// Docker interprets it as 3 nanoseconds.
const MinimumDuration = 1 * time.Millisecond
// StopOptions holds the options to stop or restart a container.
type StopOptions struct {
// Signal (optional) is the signal to send to the container to (gracefully)
// stop it before forcibly terminating the container with SIGKILL after the
// timeout expires. If not value is set, the default (SIGTERM) is used.
Signal string `json:",omitempty"`
// Timeout (optional) is the timeout (in seconds) to wait for the container
// to stop gracefully before forcibly terminating it with SIGKILL.
//
// - Use nil to use the default timeout (10 seconds).
// - Use '-1' to wait indefinitely.
// - Use '0' to not wait for the container to exit gracefully, and
// immediately proceeds to forcibly terminating the container.
// - Other positive values are used as timeout (in seconds).
Timeout *int `json:",omitempty"`
}
// HealthConfig holds configuration settings for the HEALTHCHECK feature.
type HealthConfig struct {
// Test is the test to perform to check that the container is healthy.

View File

@ -1,20 +0,0 @@
package container // import "github.com/docker/docker/api/types/container"
// ----------------------------------------------------------------------------
// Code generated by `swagger generate operation`. DO NOT EDIT.
//
// See hack/generate-swagger-api.sh
// ----------------------------------------------------------------------------
// ContainerCreateCreatedBody OK response to ContainerCreate operation
// swagger:model ContainerCreateCreatedBody
type ContainerCreateCreatedBody struct {
// The ID of the created container
// Required: true
ID string `json:"Id"`
// Warnings encountered when creating the container
// Required: true
Warnings []string `json:"Warnings"`
}

View File

@ -0,0 +1,19 @@
package container
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
// CreateResponse ContainerCreateResponse
//
// OK response to ContainerCreate operation
// swagger:model CreateResponse
type CreateResponse struct {
// The ID of the created container
// Required: true
ID string `json:"Id"`
// Warnings encountered when creating the container
// Required: true
Warnings []string `json:"Warnings"`
}

View File

@ -0,0 +1,16 @@
package container // import "github.com/docker/docker/api/types/container"
// ContainerCreateCreatedBody OK response to ContainerCreate operation
//
// Deprecated: use CreateResponse
type ContainerCreateCreatedBody = CreateResponse
// ContainerWaitOKBody OK response to ContainerWait operation
//
// Deprecated: use WaitResponse
type ContainerWaitOKBody = WaitResponse
// ContainerWaitOKBodyError container waiting error, if any
//
// Deprecated: use WaitExitError
type ContainerWaitOKBodyError = WaitExitError

View File

@ -3,9 +3,9 @@ package container
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
// ContainerWaitOKBodyError container waiting error, if any
// swagger:model ContainerWaitOKBodyError
type ContainerWaitOKBodyError struct {
// WaitExitError container waiting error, if any
// swagger:model WaitExitError
type WaitExitError struct {
// Details of an error
Message string `json:"Message,omitempty"`

View File

@ -3,15 +3,15 @@ package container
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
// ContainerWaitOKBody ContainerWaitResponse
// WaitResponse ContainerWaitResponse
//
// OK response to ContainerWait operation
// swagger:model ContainerWaitOKBody
type ContainerWaitOKBody struct {
// swagger:model WaitResponse
type WaitResponse struct {
// error
// Required: true
Error *ContainerWaitOKBodyError `json:"Error"`
Error *WaitExitError `json:"Error"`
// Exit code of the container
// Required: true

View File

@ -0,0 +1,14 @@
package types // import "github.com/docker/docker/api/types"
import "github.com/docker/docker/api/types/volume"
// Volume volume
//
// Deprecated: use github.com/docker/docker/api/types/volume.Volume
type Volume = volume.Volume
// VolumeUsageData Usage details about the volume. This information is used by the
// `GET /system/df` endpoint, and omitted in other endpoints.
//
// Deprecated: use github.com/docker/docker/api/types/volume.UsageData
type VolumeUsageData = volume.UsageData

View File

@ -7,43 +7,91 @@ package types
// swagger:model ImageSummary
type ImageSummary struct {
// containers
// Number of containers using this image. Includes both stopped and running
// containers.
//
// This size is not calculated by default, and depends on which API endpoint
// is used. `-1` indicates that the value has not been set / calculated.
//
// Required: true
Containers int64 `json:"Containers"`
// created
// Date and time at which the image was created as a Unix timestamp
// (number of seconds sinds EPOCH).
//
// Required: true
Created int64 `json:"Created"`
// Id
// ID is the content-addressable ID of an image.
//
// This identifier is a content-addressable digest calculated from the
// image's configuration (which includes the digests of layers used by
// the image).
//
// Note that this digest differs from the `RepoDigests` below, which
// holds digests of image manifests that reference the image.
//
// Required: true
ID string `json:"Id"`
// labels
// User-defined key/value metadata.
// Required: true
Labels map[string]string `json:"Labels"`
// parent Id
// ID of the parent image.
//
// Depending on how the image was created, this field may be empty and
// is only set for images that were built/created locally. This field
// is empty if the image was pulled from an image registry.
//
// Required: true
ParentID string `json:"ParentId"`
// repo digests
// List of content-addressable digests of locally available image manifests
// that the image is referenced from. Multiple manifests can refer to the
// same image.
//
// These digests are usually only available if the image was either pulled
// from a registry, or if the image was pushed to a registry, which is when
// the manifest is generated and its digest calculated.
//
// Required: true
RepoDigests []string `json:"RepoDigests"`
// repo tags
// List of image names/tags in the local image cache that reference this
// image.
//
// Multiple image tags can refer to the same imagem and this list may be
// empty if no tags reference the image, in which case the image is
// "untagged", in which case it can still be referenced by its ID.
//
// Required: true
RepoTags []string `json:"RepoTags"`
// shared size
// Total size of image layers that are shared between this image and other
// images.
//
// This size is not calculated by default. `-1` indicates that the value
// has not been set / calculated.
//
// Required: true
SharedSize int64 `json:"SharedSize"`
// size
// Total size of the image including all layers it is composed of.
//
// Required: true
Size int64 `json:"Size"`
// virtual size
// Total size of the image including all layers it is composed of.
//
// In versions of Docker before v1.10, this field was calculated from
// the image itself and all of its parent images. Docker v1.10 and up
// store images self-contained, and no longer use a parent-chain, making
// this field an equivalent of the Size field.
//
// This field is kept for backward compatibility, but may be removed in
// a future version of the API.
//
// Required: true
VirtualSize int64 `json:"VirtualSize"`
}

View File

@ -1,12 +0,0 @@
package time // import "github.com/docker/docker/api/types/time"
import (
"strconv"
"time"
)
// DurationToSecondsString converts the specified duration to the number
// seconds it represents, formatted as a string.
func DurationToSecondsString(duration time.Duration) string {
return strconv.FormatFloat(duration.Seconds(), 'f', 0, 64)
}

View File

@ -14,6 +14,7 @@ import (
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/api/types/registry"
"github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/api/types/volume"
"github.com/docker/go-connections/nat"
)
@ -28,7 +29,7 @@ type RootFS struct {
type ImageInspect struct {
// ID is the content-addressable ID of an image.
//
// This identified is a content-addressable digest calculated from the
// This identifier is a content-addressable digest calculated from the
// image's configuration (which includes the digests of layers used by
// the image).
//
@ -73,8 +74,11 @@ type ImageInspect struct {
// Depending on how the image was created, this field may be empty.
Container string
// ContainerConfig is the configuration of the container that was committed
// into the image.
// ContainerConfig is an optional field containing the configuration of the
// container that was last committed when creating the image.
//
// Previous versions of Docker builder used this field to store build cache,
// and it is not in active use anymore.
ContainerConfig *container.Config
// DockerVersion is the version of Docker that was used to build the image.
@ -683,7 +687,7 @@ type DiskUsage struct {
LayersSize int64
Images []*ImageSummary
Containers []*Container
Volumes []*Volume
Volumes []*volume.Volume
BuildCache []*BuildCache
BuilderSize int64 `json:",omitempty"` // Deprecated: deprecated in API 1.38, and no longer used since API 1.40.
}

View File

@ -3,11 +3,11 @@ package volume
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
// VolumeCreateBody VolumeConfig
// CreateOptions VolumeConfig
//
// Volume configuration
// swagger:model VolumeCreateBody
type VolumeCreateBody struct {
// swagger:model CreateOptions
type CreateOptions struct {
// Name of the volume driver to use.
Driver string `json:"Driver,omitempty"`

View File

@ -0,0 +1,11 @@
package volume // import "github.com/docker/docker/api/types/volume"
// VolumeCreateBody Volume configuration
//
// Deprecated: use CreateOptions
type VolumeCreateBody = CreateOptions
// VolumeListOKBody Volume list response
//
// Deprecated: use ListResponse
type VolumeListOKBody = ListResponse

View File

@ -0,0 +1,18 @@
package volume
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
// ListResponse VolumeListResponse
//
// Volume list response
// swagger:model ListResponse
type ListResponse struct {
// List of volumes
Volumes []*Volume `json:"Volumes"`
// Warnings that occurred when fetching the list of volumes.
//
Warnings []string `json:"Warnings"`
}

View File

@ -1,4 +1,4 @@
package types
package volume
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
@ -47,14 +47,14 @@ type Volume struct {
Status map[string]interface{} `json:"Status,omitempty"`
// usage data
UsageData *VolumeUsageData `json:"UsageData,omitempty"`
UsageData *UsageData `json:"UsageData,omitempty"`
}
// VolumeUsageData Usage details about the volume. This information is used by the
// UsageData Usage details about the volume. This information is used by the
// `GET /system/df` endpoint, and omitted in other endpoints.
//
// swagger:model VolumeUsageData
type VolumeUsageData struct {
// swagger:model UsageData
type UsageData struct {
// The number of containers referencing this volume. This field
// is set to `-1` if the reference-count is not available.

View File

@ -1,23 +0,0 @@
package volume // import "github.com/docker/docker/api/types/volume"
// ----------------------------------------------------------------------------
// Code generated by `swagger generate operation`. DO NOT EDIT.
//
// See hack/generate-swagger-api.sh
// ----------------------------------------------------------------------------
import "github.com/docker/docker/api/types"
// VolumeListOKBody Volume list response
// swagger:model VolumeListOKBody
type VolumeListOKBody struct {
// List of volumes
// Required: true
Volumes []*types.Volume `json:"Volumes"`
// Warnings that occurred when fetching the list of volumes.
//
// Required: true
Warnings []string `json:"Warnings"`
}

View File

@ -0,0 +1,88 @@
// Package urlutil provides helper function to check if a given build-context
// location should be considered a URL or a remote Git repository.
//
// This package is specifically written for use with docker build contexts, and
// should not be used as a general-purpose utility.
package urlutil // import "github.com/docker/docker/builder/remotecontext/urlutil"
import (
"regexp"
"strings"
)
// urlPathWithFragmentSuffix matches fragments to use as Git reference and build
// context from the Git repository. See IsGitURL for details.
var urlPathWithFragmentSuffix = regexp.MustCompile(".git(?:#.+)?$")
// IsURL returns true if the provided str is an HTTP(S) URL by checking if it
// has a http:// or https:// scheme. No validation is performed to verify if the
// URL is well-formed.
func IsURL(str string) bool {
return strings.HasPrefix(str, "https://") || strings.HasPrefix(str, "http://")
}
// IsGitURL returns true if the provided str is a remote git repository "URL".
//
// This function only performs a rudimentary check (no validation is performed
// to ensure the URL is well-formed), and is written specifically for use with
// docker build, with some logic for backward compatibility with older versions
// of docker: do not use this function as a general-purpose utility.
//
// The following patterns are considered to be a Git URL:
//
// - https://(.*).git(?:#.+)?$ git repository URL with optional fragment, as
// known to be used by GitHub and GitLab.
// - http://(.*).git(?:#.+)?$ same, but non-TLS
// - git://(.*) URLs using git:// scheme
// - git@(.*)
// - github.com/ see description below
//
// The github.com/ prefix is a special case used to treat context-paths
// starting with "github.com/" as a git URL if the given path does not
// exist locally. The "github.com/" prefix is kept for backward compatibility,
// and is a legacy feature.
//
// Going forward, no additional prefixes should be added, and users should
// be encouraged to use explicit URLs (https://github.com/user/repo.git) instead.
//
// Note that IsGitURL does not check if "github.com/" prefixes exist as a local
// path. Code using this function should check if the path exists locally before
// using it as a URL.
//
// Fragments
//
// Git URLs accept context configuration in their fragment section, separated by
// a colon (`:`). The first part represents the reference to check out, and can
// be either a branch, a tag, or a remote reference. The second part represents
// a subdirectory inside the repository to use as the build context.
//
// For example,the following URL uses a directory named "docker" in the branch
// "container" in the https://github.com/myorg/my-repo.git repository:
//
// https://github.com/myorg/my-repo.git#container:docker
//
// The following table represents all the valid suffixes with their build
// contexts:
//
// | Build Syntax Suffix | Git reference used | Build Context Used |
// |--------------------------------|----------------------|--------------------|
// | my-repo.git | refs/heads/master | / |
// | my-repo.git#mytag | refs/tags/my-tag | / |
// | my-repo.git#mybranch | refs/heads/my-branch | / |
// | my-repo.git#pull/42/head | refs/pull/42/head | / |
// | my-repo.git#:directory | refs/heads/master | /directory |
// | my-repo.git#master:directory | refs/heads/master | /directory |
// | my-repo.git#mytag:directory | refs/tags/my-tag | /directory |
// | my-repo.git#mybranch:directory | refs/heads/my-branch | /directory |
//
func IsGitURL(str string) bool {
if IsURL(str) && urlPathWithFragmentSuffix.MatchString(str) {
return true
}
for _, prefix := range []string{"git://", "github.com/", "git@"} {
if strings.HasPrefix(str, prefix) {
return true
}
}
return false
}

View File

@ -50,11 +50,6 @@ func (cli *Client) CopyToContainer(ctx context.Context, containerID, dstPath str
return err
}
// TODO this code converts non-error status-codes (e.g., "204 No Content") into an error; verify if this is the desired behavior
if response.statusCode != http.StatusOK {
return fmt.Errorf("unexpected status code from daemon: %d", response.statusCode)
}
return nil
}
@ -70,11 +65,6 @@ func (cli *Client) CopyFromContainer(ctx context.Context, containerID, srcPath s
return nil, types.ContainerPathStat{}, err
}
// TODO this code converts non-error status-codes (e.g., "204 No Content") into an error; verify if this is the desired behavior
if response.statusCode != http.StatusOK {
return nil, types.ContainerPathStat{}, fmt.Errorf("unexpected status code from daemon: %d", response.statusCode)
}
// In order to get the copy behavior right, we need to know information
// about both the source and the destination. The response headers include
// stat info about the source that we can use in deciding exactly how to

View File

@ -20,8 +20,8 @@ type configWrapper struct {
// ContainerCreate creates a new container based on the given configuration.
// It can be associated with a name, but it's not mandatory.
func (cli *Client) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *specs.Platform, containerName string) (container.ContainerCreateCreatedBody, error) {
var response container.ContainerCreateCreatedBody
func (cli *Client) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *specs.Platform, containerName string) (container.CreateResponse, error) {
var response container.CreateResponse
if err := cli.NewVersionError("1.25", "stop timeout"); config != nil && config.StopTimeout != nil && err != nil {
return response, err

View File

@ -8,7 +8,9 @@ import (
// ContainerKill terminates the container process but does not remove the container from the docker host.
func (cli *Client) ContainerKill(ctx context.Context, containerID, signal string) error {
query := url.Values{}
query.Set("signal", signal)
if signal != "" {
query.Set("signal", signal)
}
resp, err := cli.post(ctx, "/containers/"+containerID+"/kill", query, nil, nil)
ensureReaderClosed(resp)

View File

@ -18,7 +18,7 @@ func (cli *Client) ContainerList(ctx context.Context, options types.ContainerLis
query.Set("all", "1")
}
if options.Limit != -1 {
if options.Limit > 0 {
query.Set("limit", strconv.Itoa(options.Limit))
}

View File

@ -3,18 +3,22 @@ package client // import "github.com/docker/docker/client"
import (
"context"
"net/url"
"time"
"strconv"
timetypes "github.com/docker/docker/api/types/time"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/versions"
)
// ContainerRestart stops and starts a container again.
// It makes the daemon wait for the container to be up again for
// a specific amount of time, given the timeout.
func (cli *Client) ContainerRestart(ctx context.Context, containerID string, timeout *time.Duration) error {
func (cli *Client) ContainerRestart(ctx context.Context, containerID string, options container.StopOptions) error {
query := url.Values{}
if timeout != nil {
query.Set("t", timetypes.DurationToSecondsString(*timeout))
if options.Timeout != nil {
query.Set("t", strconv.Itoa(*options.Timeout))
}
if options.Signal != "" && versions.GreaterThanOrEqualTo(cli.version, "1.42") {
query.Set("signal", options.Signal)
}
resp, err := cli.post(ctx, "/containers/"+containerID+"/restart", query, nil, nil)
ensureReaderClosed(resp)

View File

@ -3,9 +3,10 @@ package client // import "github.com/docker/docker/client"
import (
"context"
"net/url"
"time"
"strconv"
timetypes "github.com/docker/docker/api/types/time"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/versions"
)
// ContainerStop stops a container. In case the container fails to stop
@ -15,10 +16,13 @@ import (
// If the timeout is nil, the container's StopTimeout value is used, if set,
// otherwise the engine default. A negative timeout value can be specified,
// meaning no timeout, i.e. no forceful termination is performed.
func (cli *Client) ContainerStop(ctx context.Context, containerID string, timeout *time.Duration) error {
func (cli *Client) ContainerStop(ctx context.Context, containerID string, options container.StopOptions) error {
query := url.Values{}
if timeout != nil {
query.Set("t", timetypes.DurationToSecondsString(*timeout))
if options.Timeout != nil {
query.Set("t", strconv.Itoa(*options.Timeout))
}
if options.Signal != "" && versions.GreaterThanOrEqualTo(cli.version, "1.42") {
query.Set("signal", options.Signal)
}
resp, err := cli.post(ctx, "/containers/"+containerID+"/stop", query, nil, nil)
ensureReaderClosed(resp)

View File

@ -24,12 +24,12 @@ import (
// wait request or in getting the response. This allows the caller to
// synchronize ContainerWait with other calls, such as specifying a
// "next-exit" condition before issuing a ContainerStart request.
func (cli *Client) ContainerWait(ctx context.Context, containerID string, condition container.WaitCondition) (<-chan container.ContainerWaitOKBody, <-chan error) {
func (cli *Client) ContainerWait(ctx context.Context, containerID string, condition container.WaitCondition) (<-chan container.WaitResponse, <-chan error) {
if versions.LessThan(cli.ClientVersion(), "1.30") {
return cli.legacyContainerWait(ctx, containerID)
}
resultC := make(chan container.ContainerWaitOKBody)
resultC := make(chan container.WaitResponse)
errC := make(chan error, 1)
query := url.Values{}
@ -46,7 +46,7 @@ func (cli *Client) ContainerWait(ctx context.Context, containerID string, condit
go func() {
defer ensureReaderClosed(resp)
var res container.ContainerWaitOKBody
var res container.WaitResponse
if err := json.NewDecoder(resp.body).Decode(&res); err != nil {
errC <- err
return
@ -60,8 +60,8 @@ func (cli *Client) ContainerWait(ctx context.Context, containerID string, condit
// legacyContainerWait returns immediately and doesn't have an option to wait
// until the container is removed.
func (cli *Client) legacyContainerWait(ctx context.Context, containerID string) (<-chan container.ContainerWaitOKBody, <-chan error) {
resultC := make(chan container.ContainerWaitOKBody)
func (cli *Client) legacyContainerWait(ctx context.Context, containerID string) (<-chan container.WaitResponse, <-chan error) {
resultC := make(chan container.WaitResponse)
errC := make(chan error)
go func() {
@ -72,7 +72,7 @@ func (cli *Client) legacyContainerWait(ctx context.Context, containerID string)
}
defer ensureReaderClosed(resp)
var res container.ContainerWaitOKBody
var res container.WaitResponse
if err := json.NewDecoder(resp.body).Decode(&res); err != nil {
errC <- err
return

View File

@ -5,17 +5,16 @@ import (
"io"
"net"
"net/http"
"time"
"github.com/docker/docker/api/types"
containertypes "github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/events"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/image"
networktypes "github.com/docker/docker/api/types/network"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/api/types/registry"
"github.com/docker/docker/api/types/swarm"
volumetypes "github.com/docker/docker/api/types/volume"
"github.com/docker/docker/api/types/volume"
specs "github.com/opencontainers/image-spec/specs-go/v1"
)
@ -48,8 +47,8 @@ type CommonAPIClient interface {
type ContainerAPIClient interface {
ContainerAttach(ctx context.Context, container string, options types.ContainerAttachOptions) (types.HijackedResponse, error)
ContainerCommit(ctx context.Context, container string, options types.ContainerCommitOptions) (types.IDResponse, error)
ContainerCreate(ctx context.Context, config *containertypes.Config, hostConfig *containertypes.HostConfig, networkingConfig *networktypes.NetworkingConfig, platform *specs.Platform, containerName string) (containertypes.ContainerCreateCreatedBody, error)
ContainerDiff(ctx context.Context, container string) ([]containertypes.ContainerChangeResponseItem, error)
ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *specs.Platform, containerName string) (container.CreateResponse, error)
ContainerDiff(ctx context.Context, container string) ([]container.ContainerChangeResponseItem, error)
ContainerExecAttach(ctx context.Context, execID string, config types.ExecStartCheck) (types.HijackedResponse, error)
ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.IDResponse, error)
ContainerExecInspect(ctx context.Context, execID string) (types.ContainerExecInspect, error)
@ -65,16 +64,16 @@ type ContainerAPIClient interface {
ContainerRemove(ctx context.Context, container string, options types.ContainerRemoveOptions) error
ContainerRename(ctx context.Context, container, newContainerName string) error
ContainerResize(ctx context.Context, container string, options types.ResizeOptions) error
ContainerRestart(ctx context.Context, container string, timeout *time.Duration) error
ContainerRestart(ctx context.Context, container string, options container.StopOptions) error
ContainerStatPath(ctx context.Context, container, path string) (types.ContainerPathStat, error)
ContainerStats(ctx context.Context, container string, stream bool) (types.ContainerStats, error)
ContainerStatsOneShot(ctx context.Context, container string) (types.ContainerStats, error)
ContainerStart(ctx context.Context, container string, options types.ContainerStartOptions) error
ContainerStop(ctx context.Context, container string, timeout *time.Duration) error
ContainerTop(ctx context.Context, container string, arguments []string) (containertypes.ContainerTopOKBody, error)
ContainerStop(ctx context.Context, container string, options container.StopOptions) error
ContainerTop(ctx context.Context, container string, arguments []string) (container.ContainerTopOKBody, error)
ContainerUnpause(ctx context.Context, container string) error
ContainerUpdate(ctx context.Context, container string, updateConfig containertypes.UpdateConfig) (containertypes.ContainerUpdateOKBody, error)
ContainerWait(ctx context.Context, container string, condition containertypes.WaitCondition) (<-chan containertypes.ContainerWaitOKBody, <-chan error)
ContainerUpdate(ctx context.Context, container string, updateConfig container.UpdateConfig) (container.ContainerUpdateOKBody, error)
ContainerWait(ctx context.Context, container string, condition container.WaitCondition) (<-chan container.WaitResponse, <-chan error)
CopyFromContainer(ctx context.Context, container, srcPath string) (io.ReadCloser, types.ContainerPathStat, error)
CopyToContainer(ctx context.Context, container, path string, content io.Reader, options types.CopyToContainerOptions) error
ContainersPrune(ctx context.Context, pruneFilters filters.Args) (types.ContainersPruneReport, error)
@ -107,7 +106,7 @@ type ImageAPIClient interface {
// NetworkAPIClient defines API client methods for the networks
type NetworkAPIClient interface {
NetworkConnect(ctx context.Context, network, container string, config *networktypes.EndpointSettings) error
NetworkConnect(ctx context.Context, network, container string, config *network.EndpointSettings) error
NetworkCreate(ctx context.Context, name string, options types.NetworkCreate) (types.NetworkCreateResponse, error)
NetworkDisconnect(ctx context.Context, network, container string, force bool) error
NetworkInspect(ctx context.Context, network string, options types.NetworkInspectOptions) (types.NetworkResource, error)
@ -174,10 +173,10 @@ type SystemAPIClient interface {
// VolumeAPIClient defines API client methods for the volumes
type VolumeAPIClient interface {
VolumeCreate(ctx context.Context, options volumetypes.VolumeCreateBody) (types.Volume, error)
VolumeInspect(ctx context.Context, volumeID string) (types.Volume, error)
VolumeInspectWithRaw(ctx context.Context, volumeID string) (types.Volume, []byte, error)
VolumeList(ctx context.Context, filter filters.Args) (volumetypes.VolumeListOKBody, error)
VolumeCreate(ctx context.Context, options volume.CreateOptions) (volume.Volume, error)
VolumeInspect(ctx context.Context, volumeID string) (volume.Volume, error)
VolumeInspectWithRaw(ctx context.Context, volumeID string) (volume.Volume, []byte, error)
VolumeList(ctx context.Context, filter filters.Args) (volume.ListResponse, error)
VolumeRemove(ctx context.Context, volumeID string, force bool) error
VolumesPrune(ctx context.Context, pruneFilter filters.Args) (types.VolumesPruneReport, error)
}

View File

@ -4,18 +4,17 @@ import (
"context"
"encoding/json"
"github.com/docker/docker/api/types"
volumetypes "github.com/docker/docker/api/types/volume"
"github.com/docker/docker/api/types/volume"
)
// VolumeCreate creates a volume in the docker host.
func (cli *Client) VolumeCreate(ctx context.Context, options volumetypes.VolumeCreateBody) (types.Volume, error) {
var volume types.Volume
func (cli *Client) VolumeCreate(ctx context.Context, options volume.CreateOptions) (volume.Volume, error) {
var vol volume.Volume
resp, err := cli.post(ctx, "/volumes/create", nil, options, nil)
defer ensureReaderClosed(resp)
if err != nil {
return volume, err
return vol, err
}
err = json.NewDecoder(resp.body).Decode(&volume)
return volume, err
err = json.NewDecoder(resp.body).Decode(&vol)
return vol, err
}

View File

@ -6,33 +6,33 @@ import (
"encoding/json"
"io"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/volume"
)
// VolumeInspect returns the information about a specific volume in the docker host.
func (cli *Client) VolumeInspect(ctx context.Context, volumeID string) (types.Volume, error) {
volume, _, err := cli.VolumeInspectWithRaw(ctx, volumeID)
return volume, err
func (cli *Client) VolumeInspect(ctx context.Context, volumeID string) (volume.Volume, error) {
vol, _, err := cli.VolumeInspectWithRaw(ctx, volumeID)
return vol, err
}
// VolumeInspectWithRaw returns the information about a specific volume in the docker host and its raw representation
func (cli *Client) VolumeInspectWithRaw(ctx context.Context, volumeID string) (types.Volume, []byte, error) {
func (cli *Client) VolumeInspectWithRaw(ctx context.Context, volumeID string) (volume.Volume, []byte, error) {
if volumeID == "" {
return types.Volume{}, nil, objectNotFoundError{object: "volume", id: volumeID}
return volume.Volume{}, nil, objectNotFoundError{object: "volume", id: volumeID}
}
var volume types.Volume
var vol volume.Volume
resp, err := cli.get(ctx, "/volumes/"+volumeID, nil, nil)
defer ensureReaderClosed(resp)
if err != nil {
return volume, nil, err
return vol, nil, err
}
body, err := io.ReadAll(resp.body)
if err != nil {
return volume, nil, err
return vol, nil, err
}
rdr := bytes.NewReader(body)
err = json.NewDecoder(rdr).Decode(&volume)
return volume, body, err
err = json.NewDecoder(rdr).Decode(&vol)
return vol, body, err
}

View File

@ -6,12 +6,12 @@ import (
"net/url"
"github.com/docker/docker/api/types/filters"
volumetypes "github.com/docker/docker/api/types/volume"
"github.com/docker/docker/api/types/volume"
)
// VolumeList returns the volumes configured in the docker host.
func (cli *Client) VolumeList(ctx context.Context, filter filters.Args) (volumetypes.VolumeListOKBody, error) {
var volumes volumetypes.VolumeListOKBody
func (cli *Client) VolumeList(ctx context.Context, filter filters.Args) (volume.ListResponse, error) {
var volumes volume.ListResponse
query := url.Values{}
if filter.Len() > 0 {

View File

@ -1,52 +0,0 @@
// Package urlutil provides helper function to check urls kind.
// It supports http urls, git urls and transport url (tcp://, …)
package urlutil // import "github.com/docker/docker/pkg/urlutil"
import (
"regexp"
"strings"
)
var (
validPrefixes = map[string][]string{
"url": {"http://", "https://"},
// The github.com/ prefix is a special case used to treat context-paths
// starting with `github.com` as a git URL if the given path does not
// exist locally. The "github.com/" prefix is kept for backward compatibility,
// and is a legacy feature.
//
// Going forward, no additional prefixes should be added, and users should
// be encouraged to use explicit URLs (https://github.com/user/repo.git) instead.
"git": {"git://", "github.com/", "git@"},
"transport": {"tcp://", "tcp+tls://", "udp://", "unix://", "unixgram://"},
}
urlPathWithFragmentSuffix = regexp.MustCompile(".git(?:#.+)?$")
)
// IsURL returns true if the provided str is an HTTP(S) URL.
func IsURL(str string) bool {
return checkURL(str, "url")
}
// IsGitURL returns true if the provided str is a git repository URL.
func IsGitURL(str string) bool {
if IsURL(str) && urlPathWithFragmentSuffix.MatchString(str) {
return true
}
return checkURL(str, "git")
}
// IsTransportURL returns true if the provided str is a transport (tcp, tcp+tls, udp, unix) URL.
func IsTransportURL(str string) bool {
return checkURL(str, "transport")
}
func checkURL(str, kind string) bool {
for _, prefix := range validPrefixes[kind] {
if strings.HasPrefix(str, prefix) {
return true
}
}
return false
}

6
vendor/modules.txt vendored
View File

@ -39,7 +39,7 @@ github.com/docker/distribution/registry/client/transport
github.com/docker/distribution/registry/storage/cache
github.com/docker/distribution/registry/storage/cache/memory
github.com/docker/distribution/uuid
# github.com/docker/docker v20.10.14+incompatible => github.com/docker/docker v20.10.3-0.20220326171151-8941dcfcc5db+incompatible
# github.com/docker/docker v20.10.14+incompatible => github.com/docker/docker v20.10.3-0.20220429181837-2ed904cad705+incompatible
## explicit
github.com/docker/docker/api
github.com/docker/docker/api/types
@ -58,6 +58,7 @@ github.com/docker/docker/api/types/time
github.com/docker/docker/api/types/versions
github.com/docker/docker/api/types/volume
github.com/docker/docker/builder/remotecontext/git
github.com/docker/docker/builder/remotecontext/urlutil
github.com/docker/docker/client
github.com/docker/docker/errdefs
github.com/docker/docker/pkg/archive
@ -73,7 +74,6 @@ github.com/docker/docker/pkg/stdcopy
github.com/docker/docker/pkg/streamformatter
github.com/docker/docker/pkg/stringid
github.com/docker/docker/pkg/system
github.com/docker/docker/pkg/urlutil
github.com/docker/docker/registry
# github.com/docker/docker-credential-helpers v0.6.4
## explicit; go 1.13
@ -390,5 +390,5 @@ gotest.tools/v3/internal/format
gotest.tools/v3/internal/source
gotest.tools/v3/poll
gotest.tools/v3/skip
# github.com/docker/docker => github.com/docker/docker v20.10.3-0.20220326171151-8941dcfcc5db+incompatible
# github.com/docker/docker => github.com/docker/docker v20.10.3-0.20220429181837-2ed904cad705+incompatible
# github.com/gogo/googleapis => github.com/gogo/googleapis v1.3.2