From c48585f10417bdc849b0a5bf7bea07da3e76a80d Mon Sep 17 00:00:00 2001 From: Austin Vazquez Date: Thu, 21 Aug 2025 21:45:46 -0500 Subject: [PATCH] api/types/volume: move `ListOptions` to client mod Signed-off-by: Austin Vazquez --- api/types/volume/options.go | 7 ------- client/client_interfaces.go | 2 +- client/volume_list.go | 2 +- client/volume_list_opts.go | 8 ++++++++ client/volume_list_test.go | 4 ++-- daemon/cluster/volumes.go | 3 ++- daemon/server/router/volume/backend.go | 3 ++- daemon/server/router/volume/volume_routes.go | 3 ++- daemon/server/router/volume/volume_routes_test.go | 3 ++- integration/plugin/authz/authz_plugin_v2_test.go | 2 +- integration/volume/volume_test.go | 2 +- testutil/environment/clean.go | 3 +-- testutil/environment/protect.go | 6 +++--- vendor/github.com/moby/moby/api/types/volume/options.go | 7 ------- vendor/github.com/moby/moby/client/client_interfaces.go | 2 +- vendor/github.com/moby/moby/client/volume_list.go | 2 +- vendor/github.com/moby/moby/client/volume_list_opts.go | 8 ++++++++ 17 files changed, 36 insertions(+), 31 deletions(-) create mode 100644 client/volume_list_opts.go create mode 100644 vendor/github.com/moby/moby/client/volume_list_opts.go diff --git a/api/types/volume/options.go b/api/types/volume/options.go index 7237f2db8d..7f501d01a7 100644 --- a/api/types/volume/options.go +++ b/api/types/volume/options.go @@ -1,12 +1,5 @@ package volume -import "github.com/moby/moby/api/types/filters" - -// ListOptions holds parameters to list volumes. -type ListOptions struct { - Filters filters.Args -} - // PruneReport contains the response for Engine API: // POST "/volumes/prune" type PruneReport struct { diff --git a/client/client_interfaces.go b/client/client_interfaces.go index b6d3a2a052..50a51d3a79 100644 --- a/client/client_interfaces.go +++ b/client/client_interfaces.go @@ -198,7 +198,7 @@ type VolumeAPIClient interface { 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, options volume.ListOptions) (volume.ListResponse, error) + VolumeList(ctx context.Context, options ListOptions) (volume.ListResponse, error) VolumeRemove(ctx context.Context, volumeID string, force bool) error VolumesPrune(ctx context.Context, pruneFilter filters.Args) (volume.PruneReport, error) VolumeUpdate(ctx context.Context, volumeID string, version swarm.Version, options volume.UpdateOptions) error diff --git a/client/volume_list.go b/client/volume_list.go index 656dfb05de..d87f632139 100644 --- a/client/volume_list.go +++ b/client/volume_list.go @@ -11,7 +11,7 @@ import ( ) // VolumeList returns the volumes configured in the docker host. -func (cli *Client) VolumeList(ctx context.Context, options volume.ListOptions) (volume.ListResponse, error) { +func (cli *Client) VolumeList(ctx context.Context, options ListOptions) (volume.ListResponse, error) { query := url.Values{} if options.Filters.Len() > 0 { diff --git a/client/volume_list_opts.go b/client/volume_list_opts.go new file mode 100644 index 0000000000..b17e11bfb1 --- /dev/null +++ b/client/volume_list_opts.go @@ -0,0 +1,8 @@ +package client + +import "github.com/moby/moby/api/types/filters" + +// ListOptions holds parameters to list volumes. +type ListOptions struct { + Filters filters.Args +} diff --git a/client/volume_list_test.go b/client/volume_list_test.go index 0f1a0d15a2..1962919d1d 100644 --- a/client/volume_list_test.go +++ b/client/volume_list_test.go @@ -22,7 +22,7 @@ func TestVolumeListError(t *testing.T) { client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), } - _, err := client.VolumeList(context.Background(), volume.ListOptions{}) + _, err := client.VolumeList(context.Background(), ListOptions{}) assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal)) } @@ -80,7 +80,7 @@ func TestVolumeList(t *testing.T) { }), } - volumeResponse, err := client.VolumeList(context.Background(), volume.ListOptions{Filters: listCase.filters}) + volumeResponse, err := client.VolumeList(context.Background(), ListOptions{Filters: listCase.filters}) assert.NilError(t, err) assert.Check(t, is.Len(volumeResponse.Volumes, 1)) } diff --git a/daemon/cluster/volumes.go b/daemon/cluster/volumes.go index 72b828ab8d..03b4903e2a 100644 --- a/daemon/cluster/volumes.go +++ b/daemon/cluster/volumes.go @@ -6,6 +6,7 @@ import ( cerrdefs "github.com/containerd/errdefs" volumetypes "github.com/moby/moby/api/types/volume" + "github.com/moby/moby/client" "github.com/moby/moby/v2/daemon/cluster/convert" "github.com/moby/moby/v2/errdefs" swarmapi "github.com/moby/swarmkit/v2/api" @@ -30,7 +31,7 @@ func (c *Cluster) GetVolume(nameOrID string) (volumetypes.Volume, error) { } // GetVolumes returns all of the volumes matching the given options from a swarm cluster. -func (c *Cluster) GetVolumes(options volumetypes.ListOptions) ([]*volumetypes.Volume, error) { +func (c *Cluster) GetVolumes(options client.ListOptions) ([]*volumetypes.Volume, error) { var volumes []*volumetypes.Volume if err := c.lockedManagerAction(func(ctx context.Context, state nodeState) error { r, err := state.controlClient.ListVolumes( diff --git a/daemon/server/router/volume/backend.go b/daemon/server/router/volume/backend.go index 369953d4c7..48f6ee0ac9 100644 --- a/daemon/server/router/volume/backend.go +++ b/daemon/server/router/volume/backend.go @@ -5,6 +5,7 @@ import ( "github.com/moby/moby/api/types/filters" "github.com/moby/moby/api/types/volume" + "github.com/moby/moby/client" "github.com/moby/moby/v2/daemon/volume/service/opts" ) @@ -24,7 +25,7 @@ type Backend interface { // backends here. type ClusterBackend interface { GetVolume(nameOrID string) (volume.Volume, error) - GetVolumes(options volume.ListOptions) ([]*volume.Volume, error) + GetVolumes(options client.ListOptions) ([]*volume.Volume, error) CreateVolume(volume volume.CreateOptions) (*volume.Volume, error) RemoveVolume(nameOrID string, force bool) error UpdateVolume(nameOrID string, version uint64, volume volume.UpdateOptions) error diff --git a/daemon/server/router/volume/volume_routes.go b/daemon/server/router/volume/volume_routes.go index e7d6aa88cd..0a5089b929 100644 --- a/daemon/server/router/volume/volume_routes.go +++ b/daemon/server/router/volume/volume_routes.go @@ -11,6 +11,7 @@ import ( "github.com/moby/moby/api/types/filters" "github.com/moby/moby/api/types/versions" "github.com/moby/moby/api/types/volume" + "github.com/moby/moby/client" "github.com/moby/moby/v2/daemon/server/httputils" "github.com/moby/moby/v2/daemon/volume/service/opts" "github.com/moby/moby/v2/errdefs" @@ -39,7 +40,7 @@ func (v *volumeRouter) getVolumesList(ctx context.Context, w http.ResponseWriter version := httputils.VersionFromContext(ctx) if versions.GreaterThanOrEqualTo(version, clusterVolumesVersion) && v.cluster.IsManager() { - clusterVolumes, swarmErr := v.cluster.GetVolumes(volume.ListOptions{Filters: f}) + clusterVolumes, swarmErr := v.cluster.GetVolumes(client.ListOptions{Filters: f}) if swarmErr != nil { // if there is a swarm error, we may not want to error out right // away. the local list probably worked. instead, let's do what we diff --git a/daemon/server/router/volume/volume_routes_test.go b/daemon/server/router/volume/volume_routes_test.go index f6acde9ad8..766f80ded7 100644 --- a/daemon/server/router/volume/volume_routes_test.go +++ b/daemon/server/router/volume/volume_routes_test.go @@ -15,6 +15,7 @@ import ( cerrdefs "github.com/containerd/errdefs" "github.com/moby/moby/api/types/filters" "github.com/moby/moby/api/types/volume" + "github.com/moby/moby/client" "github.com/moby/moby/v2/daemon/server/httputils" "github.com/moby/moby/v2/daemon/volume/service/opts" "github.com/moby/moby/v2/errdefs" @@ -679,7 +680,7 @@ func (c *fakeClusterBackend) GetVolume(nameOrID string) (volume.Volume, error) { return volume.Volume{}, errdefs.NotFound(fmt.Errorf("volume %s not found", nameOrID)) } -func (c *fakeClusterBackend) GetVolumes(_ volume.ListOptions) ([]*volume.Volume, error) { +func (c *fakeClusterBackend) GetVolumes(_ client.ListOptions) ([]*volume.Volume, error) { if err := c.checkSwarm(); err != nil { return nil, err } diff --git a/integration/plugin/authz/authz_plugin_v2_test.go b/integration/plugin/authz/authz_plugin_v2_test.go index 728d7bc723..a408398711 100644 --- a/integration/plugin/authz/authz_plugin_v2_test.go +++ b/integration/plugin/authz/authz_plugin_v2_test.go @@ -98,7 +98,7 @@ func TestAuthZPluginV2RejectVolumeRequests(t *testing.T) { assert.Assert(t, err != nil) assert.ErrorContains(t, err, fmt.Sprintf("Error response from daemon: plugin %s failed with error:", authzPluginNameWithTag)) - _, err = c.VolumeList(ctx, volume.ListOptions{}) + _, err = c.VolumeList(ctx, client.ListOptions{}) assert.Assert(t, err != nil) assert.ErrorContains(t, err, fmt.Sprintf("Error response from daemon: plugin %s failed with error:", authzPluginNameWithTag)) diff --git a/integration/volume/volume_test.go b/integration/volume/volume_test.go index 6434c9cc0b..a038fb1477 100644 --- a/integration/volume/volume_test.go +++ b/integration/volume/volume_test.go @@ -49,7 +49,7 @@ func TestVolumesCreateAndList(t *testing.T) { } assert.Check(t, is.DeepEqual(vol, expected, cmpopts.EquateEmpty())) - volList, err := apiClient.VolumeList(ctx, volume.ListOptions{}) + volList, err := apiClient.VolumeList(ctx, client.ListOptions{}) assert.NilError(t, err) assert.Assert(t, len(volList.Volumes) > 0) diff --git a/testutil/environment/clean.go b/testutil/environment/clean.go index 8aab58f07c..37b356f126 100644 --- a/testutil/environment/clean.go +++ b/testutil/environment/clean.go @@ -10,7 +10,6 @@ import ( "github.com/moby/moby/api/types/filters" "github.com/moby/moby/api/types/image" "github.com/moby/moby/api/types/network" - "github.com/moby/moby/api/types/volume" "github.com/moby/moby/client" "go.opentelemetry.io/otel" "gotest.tools/v3/assert" @@ -130,7 +129,7 @@ func removeImage(ctx context.Context, t testing.TB, apiclient client.ImageAPICli func deleteAllVolumes(ctx context.Context, t testing.TB, c client.VolumeAPIClient, protectedVolumes map[string]struct{}) { t.Helper() - volumes, err := c.VolumeList(ctx, volume.ListOptions{}) + volumes, err := c.VolumeList(ctx, client.ListOptions{}) assert.Check(t, err, "failed to list volumes") for _, v := range volumes.Volumes { diff --git a/testutil/environment/protect.go b/testutil/environment/protect.go index 5cf0ec6200..32661b2208 100644 --- a/testutil/environment/protect.go +++ b/testutil/environment/protect.go @@ -9,7 +9,7 @@ import ( "github.com/moby/moby/api/types/filters" "github.com/moby/moby/api/types/image" "github.com/moby/moby/api/types/network" - "github.com/moby/moby/api/types/volume" + "github.com/moby/moby/client" "github.com/moby/moby/v2/testutil" "go.opentelemetry.io/otel" "gotest.tools/v3/assert" @@ -230,8 +230,8 @@ func ProtectVolumes(ctx context.Context, t testing.TB, testEnv *Execution) { func getExistingVolumes(ctx context.Context, t testing.TB, testEnv *Execution) []string { t.Helper() - client := testEnv.APIClient() - volumeList, err := client.VolumeList(ctx, volume.ListOptions{}) + apiClient := testEnv.APIClient() + volumeList, err := apiClient.VolumeList(ctx, client.ListOptions{}) assert.NilError(t, err, "failed to list volumes") var volumes []string diff --git a/vendor/github.com/moby/moby/api/types/volume/options.go b/vendor/github.com/moby/moby/api/types/volume/options.go index 7237f2db8d..7f501d01a7 100644 --- a/vendor/github.com/moby/moby/api/types/volume/options.go +++ b/vendor/github.com/moby/moby/api/types/volume/options.go @@ -1,12 +1,5 @@ package volume -import "github.com/moby/moby/api/types/filters" - -// ListOptions holds parameters to list volumes. -type ListOptions struct { - Filters filters.Args -} - // PruneReport contains the response for Engine API: // POST "/volumes/prune" type PruneReport struct { diff --git a/vendor/github.com/moby/moby/client/client_interfaces.go b/vendor/github.com/moby/moby/client/client_interfaces.go index b6d3a2a052..50a51d3a79 100644 --- a/vendor/github.com/moby/moby/client/client_interfaces.go +++ b/vendor/github.com/moby/moby/client/client_interfaces.go @@ -198,7 +198,7 @@ type VolumeAPIClient interface { 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, options volume.ListOptions) (volume.ListResponse, error) + VolumeList(ctx context.Context, options ListOptions) (volume.ListResponse, error) VolumeRemove(ctx context.Context, volumeID string, force bool) error VolumesPrune(ctx context.Context, pruneFilter filters.Args) (volume.PruneReport, error) VolumeUpdate(ctx context.Context, volumeID string, version swarm.Version, options volume.UpdateOptions) error diff --git a/vendor/github.com/moby/moby/client/volume_list.go b/vendor/github.com/moby/moby/client/volume_list.go index 656dfb05de..d87f632139 100644 --- a/vendor/github.com/moby/moby/client/volume_list.go +++ b/vendor/github.com/moby/moby/client/volume_list.go @@ -11,7 +11,7 @@ import ( ) // VolumeList returns the volumes configured in the docker host. -func (cli *Client) VolumeList(ctx context.Context, options volume.ListOptions) (volume.ListResponse, error) { +func (cli *Client) VolumeList(ctx context.Context, options ListOptions) (volume.ListResponse, error) { query := url.Values{} if options.Filters.Len() > 0 { diff --git a/vendor/github.com/moby/moby/client/volume_list_opts.go b/vendor/github.com/moby/moby/client/volume_list_opts.go new file mode 100644 index 0000000000..b17e11bfb1 --- /dev/null +++ b/vendor/github.com/moby/moby/client/volume_list_opts.go @@ -0,0 +1,8 @@ +package client + +import "github.com/moby/moby/api/types/filters" + +// ListOptions holds parameters to list volumes. +type ListOptions struct { + Filters filters.Args +}