vendor: github.com/moby/moby/api, client 0769fe708773 (master)
full diff: 4ca8aedf92...0769fe7087
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@ -3,7 +3,6 @@ package volume
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/moby/moby/api/types/filters"
|
||||
"github.com/moby/moby/api/types/volume"
|
||||
"github.com/moby/moby/client"
|
||||
)
|
||||
@ -12,9 +11,9 @@ type fakeClient struct {
|
||||
client.Client
|
||||
volumeCreateFunc func(volume.CreateOptions) (volume.Volume, error)
|
||||
volumeInspectFunc func(volumeID string) (volume.Volume, error)
|
||||
volumeListFunc func(filter filters.Args) (volume.ListResponse, error)
|
||||
volumeListFunc func(filter client.Filters) (volume.ListResponse, error)
|
||||
volumeRemoveFunc func(volumeID string, force bool) error
|
||||
volumePruneFunc func(filter filters.Args) (volume.PruneReport, error)
|
||||
volumePruneFunc func(filter client.Filters) (volume.PruneReport, error)
|
||||
}
|
||||
|
||||
func (c *fakeClient) VolumeCreate(_ context.Context, options volume.CreateOptions) (volume.Volume, error) {
|
||||
@ -38,7 +37,7 @@ func (c *fakeClient) VolumeList(_ context.Context, options client.VolumeListOpti
|
||||
return volume.ListResponse{}, nil
|
||||
}
|
||||
|
||||
func (c *fakeClient) VolumesPrune(_ context.Context, filter filters.Args) (volume.PruneReport, error) {
|
||||
func (c *fakeClient) VolumesPrune(_ context.Context, filter client.Filters) (volume.PruneReport, error) {
|
||||
if c.volumePruneFunc != nil {
|
||||
return c.volumePruneFunc(filter)
|
||||
}
|
||||
|
||||
@ -8,8 +8,8 @@ import (
|
||||
"github.com/docker/cli/cli/config/configfile"
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/docker/cli/internal/test/builders"
|
||||
"github.com/moby/moby/api/types/filters"
|
||||
"github.com/moby/moby/api/types/volume"
|
||||
"github.com/moby/moby/client"
|
||||
"gotest.tools/v3/assert"
|
||||
"gotest.tools/v3/golden"
|
||||
)
|
||||
@ -18,7 +18,7 @@ func TestVolumeListErrors(t *testing.T) {
|
||||
testCases := []struct {
|
||||
args []string
|
||||
flags map[string]string
|
||||
volumeListFunc func(filter filters.Args) (volume.ListResponse, error)
|
||||
volumeListFunc func(filter client.Filters) (volume.ListResponse, error)
|
||||
expectedError string
|
||||
}{
|
||||
{
|
||||
@ -26,7 +26,7 @@ func TestVolumeListErrors(t *testing.T) {
|
||||
expectedError: "accepts no argument",
|
||||
},
|
||||
{
|
||||
volumeListFunc: func(filter filters.Args) (volume.ListResponse, error) {
|
||||
volumeListFunc: func(filter client.Filters) (volume.ListResponse, error) {
|
||||
return volume.ListResponse{}, errors.New("error listing volumes")
|
||||
},
|
||||
expectedError: "error listing volumes",
|
||||
@ -50,7 +50,7 @@ func TestVolumeListErrors(t *testing.T) {
|
||||
|
||||
func TestVolumeListWithoutFormat(t *testing.T) {
|
||||
cli := test.NewFakeCli(&fakeClient{
|
||||
volumeListFunc: func(filter filters.Args) (volume.ListResponse, error) {
|
||||
volumeListFunc: func(filter client.Filters) (volume.ListResponse, error) {
|
||||
return volume.ListResponse{
|
||||
Volumes: []*volume.Volume{
|
||||
builders.Volume(),
|
||||
@ -69,7 +69,7 @@ func TestVolumeListWithoutFormat(t *testing.T) {
|
||||
|
||||
func TestVolumeListWithConfigFormat(t *testing.T) {
|
||||
cli := test.NewFakeCli(&fakeClient{
|
||||
volumeListFunc: func(filter filters.Args) (volume.ListResponse, error) {
|
||||
volumeListFunc: func(filter client.Filters) (volume.ListResponse, error) {
|
||||
return volume.ListResponse{
|
||||
Volumes: []*volume.Volume{
|
||||
builders.Volume(),
|
||||
@ -91,7 +91,7 @@ func TestVolumeListWithConfigFormat(t *testing.T) {
|
||||
|
||||
func TestVolumeListWithFormat(t *testing.T) {
|
||||
cli := test.NewFakeCli(&fakeClient{
|
||||
volumeListFunc: func(filter filters.Args) (volume.ListResponse, error) {
|
||||
volumeListFunc: func(filter client.Filters) (volume.ListResponse, error) {
|
||||
return volume.ListResponse{
|
||||
Volumes: []*volume.Volume{
|
||||
builders.Volume(),
|
||||
@ -111,7 +111,7 @@ func TestVolumeListWithFormat(t *testing.T) {
|
||||
|
||||
func TestVolumeListSortOrder(t *testing.T) {
|
||||
cli := test.NewFakeCli(&fakeClient{
|
||||
volumeListFunc: func(filter filters.Args) (volume.ListResponse, error) {
|
||||
volumeListFunc: func(filter client.Filters) (volume.ListResponse, error) {
|
||||
return volume.ListResponse{
|
||||
Volumes: []*volume.Volume{
|
||||
builders.Volume(builders.VolumeName("volume-2-foo")),
|
||||
@ -129,7 +129,7 @@ func TestVolumeListSortOrder(t *testing.T) {
|
||||
|
||||
func TestClusterVolumeList(t *testing.T) {
|
||||
cli := test.NewFakeCli(&fakeClient{
|
||||
volumeListFunc: func(filter filters.Args) (volume.ListResponse, error) {
|
||||
volumeListFunc: func(filter client.Filters) (volume.ListResponse, error) {
|
||||
return volume.ListResponse{
|
||||
Volumes: []*volume.Volume{
|
||||
{
|
||||
|
||||
@ -74,7 +74,7 @@ func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions)
|
||||
warning := unusedVolumesWarning
|
||||
if versions.GreaterThanOrEqualTo(dockerCli.CurrentVersion(), "1.42") {
|
||||
if options.all {
|
||||
if pruneFilters.Contains("all") {
|
||||
if _, ok := pruneFilters["all"]; ok {
|
||||
return 0, "", invalidParamErr{errors.New("conflicting options: cannot specify both --all and --filter all=1")}
|
||||
}
|
||||
pruneFilters.Add("all", "true")
|
||||
@ -124,7 +124,7 @@ func pruneFn(ctx context.Context, dockerCli command.Cli, options pruner.PruneOpt
|
||||
// TODO version this once "until" filter is supported for volumes
|
||||
// Ideally, this check wasn't done on the CLI because the list of
|
||||
// filters that is supported by the daemon may evolve over time.
|
||||
if options.Filter.Value().Contains("until") {
|
||||
if _, ok := options.Filter.Value()["until"]; ok {
|
||||
return 0, "", errors.New(`ERROR: The "until" filter is not supported with "--volumes"`)
|
||||
}
|
||||
if !options.Confirmed {
|
||||
|
||||
@ -11,8 +11,8 @@ import (
|
||||
|
||||
"github.com/docker/cli/cli/streams"
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/moby/moby/api/types/filters"
|
||||
"github.com/moby/moby/api/types/volume"
|
||||
"github.com/moby/moby/client"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
"gotest.tools/v3/golden"
|
||||
@ -24,7 +24,7 @@ func TestVolumePruneErrors(t *testing.T) {
|
||||
name string
|
||||
args []string
|
||||
flags map[string]string
|
||||
volumePruneFunc func(args filters.Args) (volume.PruneReport, error)
|
||||
volumePruneFunc func(args client.Filters) (volume.PruneReport, error)
|
||||
expectedError string
|
||||
}{
|
||||
{
|
||||
@ -37,7 +37,7 @@ func TestVolumePruneErrors(t *testing.T) {
|
||||
flags: map[string]string{
|
||||
"force": "true",
|
||||
},
|
||||
volumePruneFunc: func(args filters.Args) (volume.PruneReport, error) {
|
||||
volumePruneFunc: func(args client.Filters) (volume.PruneReport, error) {
|
||||
return volume.PruneReport{}, errors.New("error pruning volumes")
|
||||
},
|
||||
expectedError: "error pruning volumes",
|
||||
@ -74,21 +74,21 @@ func TestVolumePruneSuccess(t *testing.T) {
|
||||
name string
|
||||
args []string
|
||||
input string
|
||||
volumePruneFunc func(args filters.Args) (volume.PruneReport, error)
|
||||
volumePruneFunc func(args client.Filters) (volume.PruneReport, error)
|
||||
}{
|
||||
{
|
||||
name: "all",
|
||||
args: []string{"--all"},
|
||||
input: "y",
|
||||
volumePruneFunc: func(pruneFilter filters.Args) (volume.PruneReport, error) {
|
||||
assert.Check(t, is.DeepEqual([]string{"true"}, pruneFilter.Get("all")))
|
||||
volumePruneFunc: func(pruneFilter client.Filters) (volume.PruneReport, error) {
|
||||
assert.Check(t, is.DeepEqual(pruneFilter["all"], map[string]bool{"true": true}))
|
||||
return volume.PruneReport{}, nil
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "all-forced",
|
||||
args: []string{"--all", "--force"},
|
||||
volumePruneFunc: func(pruneFilter filters.Args) (volume.PruneReport, error) {
|
||||
volumePruneFunc: func(pruneFilter client.Filters) (volume.PruneReport, error) {
|
||||
return volume.PruneReport{}, nil
|
||||
},
|
||||
},
|
||||
@ -96,8 +96,8 @@ func TestVolumePruneSuccess(t *testing.T) {
|
||||
name: "label-filter",
|
||||
args: []string{"--filter", "label=foobar"},
|
||||
input: "y",
|
||||
volumePruneFunc: func(pruneFilter filters.Args) (volume.PruneReport, error) {
|
||||
assert.Check(t, is.DeepEqual([]string{"foobar"}, pruneFilter.Get("label")))
|
||||
volumePruneFunc: func(pruneFilter client.Filters) (volume.PruneReport, error) {
|
||||
assert.Check(t, is.DeepEqual(pruneFilter["label"], map[string]bool{"foobar": true}))
|
||||
return volume.PruneReport{}, nil
|
||||
},
|
||||
},
|
||||
@ -121,7 +121,7 @@ func TestVolumePruneSuccess(t *testing.T) {
|
||||
func TestVolumePruneForce(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
volumePruneFunc func(args filters.Args) (volume.PruneReport, error)
|
||||
volumePruneFunc func(args client.Filters) (volume.PruneReport, error)
|
||||
}{
|
||||
{
|
||||
name: "empty",
|
||||
@ -180,7 +180,7 @@ func TestVolumePrunePromptNo(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func simplePruneFunc(filters.Args) (volume.PruneReport, error) {
|
||||
func simplePruneFunc(client.Filters) (volume.PruneReport, error) {
|
||||
return volume.PruneReport{
|
||||
VolumesDeleted: []string{
|
||||
"foo", "bar", "baz",
|
||||
@ -194,7 +194,7 @@ func TestVolumePrunePromptTerminate(t *testing.T) {
|
||||
t.Cleanup(cancel)
|
||||
|
||||
cli := test.NewFakeCli(&fakeClient{
|
||||
volumePruneFunc: func(filter filters.Args) (volume.PruneReport, error) {
|
||||
volumePruneFunc: func(filter client.Filters) (volume.PruneReport, error) {
|
||||
return volume.PruneReport{}, errors.New("fakeClient volumePruneFunc should not be called")
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user