Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -176,7 +176,7 @@ type VolumeAPIClient interface {
|
| 176 | 176 |
VolumeCreate(ctx context.Context, options volume.CreateOptions) (volume.Volume, error) |
| 177 | 177 |
VolumeInspect(ctx context.Context, volumeID string) (volume.Volume, error) |
| 178 | 178 |
VolumeInspectWithRaw(ctx context.Context, volumeID string) (volume.Volume, []byte, error) |
| 179 |
- VolumeList(ctx context.Context, filter filters.Args) (volume.ListResponse, error) |
|
| 179 |
+ VolumeList(ctx context.Context, options volume.ListOptions) (volume.ListResponse, error) |
|
| 180 | 180 |
VolumeRemove(ctx context.Context, volumeID string, force bool) error |
| 181 | 181 |
VolumesPrune(ctx context.Context, pruneFilter filters.Args) (types.VolumesPruneReport, error) |
| 182 | 182 |
VolumeUpdate(ctx context.Context, volumeID string, version swarm.Version, options volume.UpdateOptions) error |
| ... | ... |
@@ -10,13 +10,13 @@ import ( |
| 10 | 10 |
) |
| 11 | 11 |
|
| 12 | 12 |
// VolumeList returns the volumes configured in the docker host. |
| 13 |
-func (cli *Client) VolumeList(ctx context.Context, filter filters.Args) (volume.ListResponse, error) {
|
|
| 13 |
+func (cli *Client) VolumeList(ctx context.Context, options volume.ListOptions) (volume.ListResponse, error) {
|
|
| 14 | 14 |
var volumes volume.ListResponse |
| 15 | 15 |
query := url.Values{}
|
| 16 | 16 |
|
| 17 |
- if filter.Len() > 0 {
|
|
| 17 |
+ if options.Filters.Len() > 0 {
|
|
| 18 | 18 |
//nolint:staticcheck // ignore SA1019 for old code |
| 19 |
- filterJSON, err := filters.ToParamWithVersion(cli.version, filter) |
|
| 19 |
+ filterJSON, err := filters.ToParamWithVersion(cli.version, options.Filters) |
|
| 20 | 20 |
if err != nil {
|
| 21 | 21 |
return volumes, err |
| 22 | 22 |
} |
| ... | ... |
@@ -20,7 +20,7 @@ func TestVolumeListError(t *testing.T) {
|
| 20 | 20 |
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), |
| 21 | 21 |
} |
| 22 | 22 |
|
| 23 |
- _, err := client.VolumeList(context.Background(), filters.NewArgs()) |
|
| 23 |
+ _, err := client.VolumeList(context.Background(), volume.ListOptions{})
|
|
| 24 | 24 |
if !errdefs.IsSystem(err) {
|
| 25 | 25 |
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
| 26 | 26 |
} |
| ... | ... |
@@ -87,7 +87,7 @@ func TestVolumeList(t *testing.T) {
|
| 87 | 87 |
}), |
| 88 | 88 |
} |
| 89 | 89 |
|
| 90 |
- volumeResponse, err := client.VolumeList(context.Background(), listCase.filters) |
|
| 90 |
+ volumeResponse, err := client.VolumeList(context.Background(), volume.ListOptions{Filters: listCase.filters})
|
|
| 91 | 91 |
if err != nil {
|
| 92 | 92 |
t.Fatal(err) |
| 93 | 93 |
} |
| ... | ... |
@@ -8,6 +8,7 @@ import ( |
| 8 | 8 |
|
| 9 | 9 |
"github.com/docker/docker/api/types" |
| 10 | 10 |
"github.com/docker/docker/api/types/filters" |
| 11 |
+ "github.com/docker/docker/api/types/volume" |
|
| 11 | 12 |
"github.com/docker/docker/integration/internal/container" |
| 12 | 13 |
"gotest.tools/v3/assert" |
| 13 | 14 |
is "gotest.tools/v3/assert/cmp" |
| ... | ... |
@@ -72,7 +73,9 @@ func TestRemoveContainerWithVolume(t *testing.T) {
|
| 72 | 72 |
}) |
| 73 | 73 |
assert.NilError(t, err) |
| 74 | 74 |
|
| 75 |
- volumes, err := client.VolumeList(ctx, filters.NewArgs(filters.Arg("name", volName)))
|
|
| 75 |
+ volumes, err := client.VolumeList(ctx, volume.ListOptions{
|
|
| 76 |
+ Filters: filters.NewArgs(filters.Arg("name", volName)),
|
|
| 77 |
+ }) |
|
| 76 | 78 |
assert.NilError(t, err) |
| 77 | 79 |
assert.Check(t, is.Equal(0, len(volumes.Volumes))) |
| 78 | 80 |
} |
| ... | ... |
@@ -105,7 +105,7 @@ func TestAuthZPluginV2RejectVolumeRequests(t *testing.T) {
|
| 105 | 105 |
assert.Assert(t, err != nil) |
| 106 | 106 |
assert.Assert(t, strings.Contains(err.Error(), fmt.Sprintf("Error response from daemon: plugin %s failed with error:", authzPluginNameWithTag)))
|
| 107 | 107 |
|
| 108 |
- _, err = c.VolumeList(context.Background(), filters.Args{})
|
|
| 108 |
+ _, err = c.VolumeList(context.Background(), volume.ListOptions{})
|
|
| 109 | 109 |
assert.Assert(t, err != nil) |
| 110 | 110 |
assert.Assert(t, strings.Contains(err.Error(), fmt.Sprintf("Error response from daemon: plugin %s failed with error:", authzPluginNameWithTag)))
|
| 111 | 111 |
|
| ... | ... |
@@ -9,7 +9,6 @@ import ( |
| 9 | 9 |
"time" |
| 10 | 10 |
|
| 11 | 11 |
"github.com/docker/docker/api/types" |
| 12 |
- "github.com/docker/docker/api/types/filters" |
|
| 13 | 12 |
"github.com/docker/docker/api/types/volume" |
| 14 | 13 |
"github.com/docker/docker/integration/internal/container" |
| 15 | 14 |
"github.com/docker/docker/testutil/request" |
| ... | ... |
@@ -43,7 +42,7 @@ func TestVolumesCreateAndList(t *testing.T) {
|
| 43 | 43 |
} |
| 44 | 44 |
assert.Check(t, is.DeepEqual(vol, expected, cmpopts.EquateEmpty())) |
| 45 | 45 |
|
| 46 |
- volList, err := client.VolumeList(ctx, filters.Args{})
|
|
| 46 |
+ volList, err := client.VolumeList(ctx, volume.ListOptions{})
|
|
| 47 | 47 |
assert.NilError(t, err) |
| 48 | 48 |
assert.Assert(t, len(volList.Volumes) > 0) |
| 49 | 49 |
|
| ... | ... |
@@ -8,6 +8,7 @@ import ( |
| 8 | 8 |
|
| 9 | 9 |
"github.com/docker/docker/api/types" |
| 10 | 10 |
"github.com/docker/docker/api/types/filters" |
| 11 |
+ "github.com/docker/docker/api/types/volume" |
|
| 11 | 12 |
"github.com/docker/docker/client" |
| 12 | 13 |
"github.com/docker/docker/errdefs" |
| 13 | 14 |
"gotest.tools/v3/assert" |
| ... | ... |
@@ -124,7 +125,7 @@ func removeImage(ctx context.Context, t testing.TB, apiclient client.ImageAPICli |
| 124 | 124 |
|
| 125 | 125 |
func deleteAllVolumes(t testing.TB, c client.VolumeAPIClient, protectedVolumes map[string]struct{}) {
|
| 126 | 126 |
t.Helper() |
| 127 |
- volumes, err := c.VolumeList(context.Background(), filters.Args{})
|
|
| 127 |
+ volumes, err := c.VolumeList(context.Background(), volume.ListOptions{})
|
|
| 128 | 128 |
assert.Check(t, err, "failed to list volumes") |
| 129 | 129 |
|
| 130 | 130 |
for _, v := range volumes.Volumes {
|
| ... | ... |
@@ -6,6 +6,7 @@ import ( |
| 6 | 6 |
|
| 7 | 7 |
"github.com/docker/docker/api/types" |
| 8 | 8 |
"github.com/docker/docker/api/types/filters" |
| 9 |
+ "github.com/docker/docker/api/types/volume" |
|
| 9 | 10 |
"github.com/docker/docker/errdefs" |
| 10 | 11 |
"gotest.tools/v3/assert" |
| 11 | 12 |
) |
| ... | ... |
@@ -195,8 +196,8 @@ func getExistingPlugins(t testing.TB, testEnv *Execution) []string {
|
| 195 | 195 |
// ProtectVolume adds the specified volume(s) to be protected in case of clean |
| 196 | 196 |
func (e *Execution) ProtectVolume(t testing.TB, volumes ...string) {
|
| 197 | 197 |
t.Helper() |
| 198 |
- for _, volume := range volumes {
|
|
| 199 |
- e.protectedElements.volumes[volume] = struct{}{}
|
|
| 198 |
+ for _, vol := range volumes {
|
|
| 199 |
+ e.protectedElements.volumes[vol] = struct{}{}
|
|
| 200 | 200 |
} |
| 201 | 201 |
} |
| 202 | 202 |
|
| ... | ... |
@@ -211,12 +212,12 @@ func ProtectVolumes(t testing.TB, testEnv *Execution) {
|
| 211 | 211 |
func getExistingVolumes(t testing.TB, testEnv *Execution) []string {
|
| 212 | 212 |
t.Helper() |
| 213 | 213 |
client := testEnv.APIClient() |
| 214 |
- volumeList, err := client.VolumeList(context.Background(), filters.Args{})
|
|
| 214 |
+ volumeList, err := client.VolumeList(context.Background(), volume.ListOptions{})
|
|
| 215 | 215 |
assert.NilError(t, err, "failed to list volumes") |
| 216 | 216 |
|
| 217 | 217 |
var volumes []string |
| 218 |
- for _, volume := range volumeList.Volumes {
|
|
| 219 |
- volumes = append(volumes, volume.Name) |
|
| 218 |
+ for _, vol := range volumeList.Volumes {
|
|
| 219 |
+ volumes = append(volumes, vol.Name) |
|
| 220 | 220 |
} |
| 221 | 221 |
return volumes |
| 222 | 222 |
} |