Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
| ... | ... |
@@ -1,12 +1,5 @@ |
| 1 | 1 |
package volume |
| 2 | 2 |
|
| 3 |
-import "github.com/moby/moby/api/types/filters" |
|
| 4 |
- |
|
| 5 |
-// ListOptions holds parameters to list volumes. |
|
| 6 |
-type ListOptions struct {
|
|
| 7 |
- Filters filters.Args |
|
| 8 |
-} |
|
| 9 |
- |
|
| 10 | 3 |
// PruneReport contains the response for Engine API: |
| 11 | 4 |
// POST "/volumes/prune" |
| 12 | 5 |
type PruneReport struct {
|
| ... | ... |
@@ -198,7 +198,7 @@ type VolumeAPIClient interface {
|
| 198 | 198 |
VolumeCreate(ctx context.Context, options volume.CreateOptions) (volume.Volume, error) |
| 199 | 199 |
VolumeInspect(ctx context.Context, volumeID string) (volume.Volume, error) |
| 200 | 200 |
VolumeInspectWithRaw(ctx context.Context, volumeID string) (volume.Volume, []byte, error) |
| 201 |
- VolumeList(ctx context.Context, options volume.ListOptions) (volume.ListResponse, error) |
|
| 201 |
+ VolumeList(ctx context.Context, options ListOptions) (volume.ListResponse, error) |
|
| 202 | 202 |
VolumeRemove(ctx context.Context, volumeID string, force bool) error |
| 203 | 203 |
VolumesPrune(ctx context.Context, pruneFilter filters.Args) (volume.PruneReport, error) |
| 204 | 204 |
VolumeUpdate(ctx context.Context, volumeID string, version swarm.Version, options volume.UpdateOptions) error |
| ... | ... |
@@ -11,7 +11,7 @@ import ( |
| 11 | 11 |
) |
| 12 | 12 |
|
| 13 | 13 |
// VolumeList returns the volumes configured in the docker host. |
| 14 |
-func (cli *Client) VolumeList(ctx context.Context, options volume.ListOptions) (volume.ListResponse, error) {
|
|
| 14 |
+func (cli *Client) VolumeList(ctx context.Context, options ListOptions) (volume.ListResponse, error) {
|
|
| 15 | 15 |
query := url.Values{}
|
| 16 | 16 |
|
| 17 | 17 |
if options.Filters.Len() > 0 {
|
| ... | ... |
@@ -22,7 +22,7 @@ func TestVolumeListError(t *testing.T) {
|
| 22 | 22 |
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), |
| 23 | 23 |
} |
| 24 | 24 |
|
| 25 |
- _, err := client.VolumeList(context.Background(), volume.ListOptions{})
|
|
| 25 |
+ _, err := client.VolumeList(context.Background(), ListOptions{})
|
|
| 26 | 26 |
assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal)) |
| 27 | 27 |
} |
| 28 | 28 |
|
| ... | ... |
@@ -80,7 +80,7 @@ func TestVolumeList(t *testing.T) {
|
| 80 | 80 |
}), |
| 81 | 81 |
} |
| 82 | 82 |
|
| 83 |
- volumeResponse, err := client.VolumeList(context.Background(), volume.ListOptions{Filters: listCase.filters})
|
|
| 83 |
+ volumeResponse, err := client.VolumeList(context.Background(), ListOptions{Filters: listCase.filters})
|
|
| 84 | 84 |
assert.NilError(t, err) |
| 85 | 85 |
assert.Check(t, is.Len(volumeResponse.Volumes, 1)) |
| 86 | 86 |
} |
| ... | ... |
@@ -6,6 +6,7 @@ import ( |
| 6 | 6 |
|
| 7 | 7 |
cerrdefs "github.com/containerd/errdefs" |
| 8 | 8 |
volumetypes "github.com/moby/moby/api/types/volume" |
| 9 |
+ "github.com/moby/moby/client" |
|
| 9 | 10 |
"github.com/moby/moby/v2/daemon/cluster/convert" |
| 10 | 11 |
"github.com/moby/moby/v2/errdefs" |
| 11 | 12 |
swarmapi "github.com/moby/swarmkit/v2/api" |
| ... | ... |
@@ -30,7 +31,7 @@ func (c *Cluster) GetVolume(nameOrID string) (volumetypes.Volume, error) {
|
| 30 | 30 |
} |
| 31 | 31 |
|
| 32 | 32 |
// GetVolumes returns all of the volumes matching the given options from a swarm cluster. |
| 33 |
-func (c *Cluster) GetVolumes(options volumetypes.ListOptions) ([]*volumetypes.Volume, error) {
|
|
| 33 |
+func (c *Cluster) GetVolumes(options client.ListOptions) ([]*volumetypes.Volume, error) {
|
|
| 34 | 34 |
var volumes []*volumetypes.Volume |
| 35 | 35 |
if err := c.lockedManagerAction(func(ctx context.Context, state nodeState) error {
|
| 36 | 36 |
r, err := state.controlClient.ListVolumes( |
| ... | ... |
@@ -5,6 +5,7 @@ import ( |
| 5 | 5 |
|
| 6 | 6 |
"github.com/moby/moby/api/types/filters" |
| 7 | 7 |
"github.com/moby/moby/api/types/volume" |
| 8 |
+ "github.com/moby/moby/client" |
|
| 8 | 9 |
"github.com/moby/moby/v2/daemon/volume/service/opts" |
| 9 | 10 |
) |
| 10 | 11 |
|
| ... | ... |
@@ -24,7 +25,7 @@ type Backend interface {
|
| 24 | 24 |
// backends here. |
| 25 | 25 |
type ClusterBackend interface {
|
| 26 | 26 |
GetVolume(nameOrID string) (volume.Volume, error) |
| 27 |
- GetVolumes(options volume.ListOptions) ([]*volume.Volume, error) |
|
| 27 |
+ GetVolumes(options client.ListOptions) ([]*volume.Volume, error) |
|
| 28 | 28 |
CreateVolume(volume volume.CreateOptions) (*volume.Volume, error) |
| 29 | 29 |
RemoveVolume(nameOrID string, force bool) error |
| 30 | 30 |
UpdateVolume(nameOrID string, version uint64, volume volume.UpdateOptions) error |
| ... | ... |
@@ -11,6 +11,7 @@ import ( |
| 11 | 11 |
"github.com/moby/moby/api/types/filters" |
| 12 | 12 |
"github.com/moby/moby/api/types/versions" |
| 13 | 13 |
"github.com/moby/moby/api/types/volume" |
| 14 |
+ "github.com/moby/moby/client" |
|
| 14 | 15 |
"github.com/moby/moby/v2/daemon/server/httputils" |
| 15 | 16 |
"github.com/moby/moby/v2/daemon/volume/service/opts" |
| 16 | 17 |
"github.com/moby/moby/v2/errdefs" |
| ... | ... |
@@ -39,7 +40,7 @@ func (v *volumeRouter) getVolumesList(ctx context.Context, w http.ResponseWriter |
| 39 | 39 |
|
| 40 | 40 |
version := httputils.VersionFromContext(ctx) |
| 41 | 41 |
if versions.GreaterThanOrEqualTo(version, clusterVolumesVersion) && v.cluster.IsManager() {
|
| 42 |
- clusterVolumes, swarmErr := v.cluster.GetVolumes(volume.ListOptions{Filters: f})
|
|
| 42 |
+ clusterVolumes, swarmErr := v.cluster.GetVolumes(client.ListOptions{Filters: f})
|
|
| 43 | 43 |
if swarmErr != nil {
|
| 44 | 44 |
// if there is a swarm error, we may not want to error out right |
| 45 | 45 |
// away. the local list probably worked. instead, let's do what we |
| ... | ... |
@@ -15,6 +15,7 @@ import ( |
| 15 | 15 |
cerrdefs "github.com/containerd/errdefs" |
| 16 | 16 |
"github.com/moby/moby/api/types/filters" |
| 17 | 17 |
"github.com/moby/moby/api/types/volume" |
| 18 |
+ "github.com/moby/moby/client" |
|
| 18 | 19 |
"github.com/moby/moby/v2/daemon/server/httputils" |
| 19 | 20 |
"github.com/moby/moby/v2/daemon/volume/service/opts" |
| 20 | 21 |
"github.com/moby/moby/v2/errdefs" |
| ... | ... |
@@ -679,7 +680,7 @@ func (c *fakeClusterBackend) GetVolume(nameOrID string) (volume.Volume, error) {
|
| 679 | 679 |
return volume.Volume{}, errdefs.NotFound(fmt.Errorf("volume %s not found", nameOrID))
|
| 680 | 680 |
} |
| 681 | 681 |
|
| 682 |
-func (c *fakeClusterBackend) GetVolumes(_ volume.ListOptions) ([]*volume.Volume, error) {
|
|
| 682 |
+func (c *fakeClusterBackend) GetVolumes(_ client.ListOptions) ([]*volume.Volume, error) {
|
|
| 683 | 683 |
if err := c.checkSwarm(); err != nil {
|
| 684 | 684 |
return nil, err |
| 685 | 685 |
} |
| ... | ... |
@@ -98,7 +98,7 @@ func TestAuthZPluginV2RejectVolumeRequests(t *testing.T) {
|
| 98 | 98 |
assert.Assert(t, err != nil) |
| 99 | 99 |
assert.ErrorContains(t, err, fmt.Sprintf("Error response from daemon: plugin %s failed with error:", authzPluginNameWithTag))
|
| 100 | 100 |
|
| 101 |
- _, err = c.VolumeList(ctx, volume.ListOptions{})
|
|
| 101 |
+ _, err = c.VolumeList(ctx, client.ListOptions{})
|
|
| 102 | 102 |
assert.Assert(t, err != nil) |
| 103 | 103 |
assert.ErrorContains(t, err, fmt.Sprintf("Error response from daemon: plugin %s failed with error:", authzPluginNameWithTag))
|
| 104 | 104 |
|
| ... | ... |
@@ -49,7 +49,7 @@ func TestVolumesCreateAndList(t *testing.T) {
|
| 49 | 49 |
} |
| 50 | 50 |
assert.Check(t, is.DeepEqual(vol, expected, cmpopts.EquateEmpty())) |
| 51 | 51 |
|
| 52 |
- volList, err := apiClient.VolumeList(ctx, volume.ListOptions{})
|
|
| 52 |
+ volList, err := apiClient.VolumeList(ctx, client.ListOptions{})
|
|
| 53 | 53 |
assert.NilError(t, err) |
| 54 | 54 |
assert.Assert(t, len(volList.Volumes) > 0) |
| 55 | 55 |
|
| ... | ... |
@@ -10,7 +10,6 @@ import ( |
| 10 | 10 |
"github.com/moby/moby/api/types/filters" |
| 11 | 11 |
"github.com/moby/moby/api/types/image" |
| 12 | 12 |
"github.com/moby/moby/api/types/network" |
| 13 |
- "github.com/moby/moby/api/types/volume" |
|
| 14 | 13 |
"github.com/moby/moby/client" |
| 15 | 14 |
"go.opentelemetry.io/otel" |
| 16 | 15 |
"gotest.tools/v3/assert" |
| ... | ... |
@@ -130,7 +129,7 @@ func removeImage(ctx context.Context, t testing.TB, apiclient client.ImageAPICli |
| 130 | 130 |
|
| 131 | 131 |
func deleteAllVolumes(ctx context.Context, t testing.TB, c client.VolumeAPIClient, protectedVolumes map[string]struct{}) {
|
| 132 | 132 |
t.Helper() |
| 133 |
- volumes, err := c.VolumeList(ctx, volume.ListOptions{})
|
|
| 133 |
+ volumes, err := c.VolumeList(ctx, client.ListOptions{})
|
|
| 134 | 134 |
assert.Check(t, err, "failed to list volumes") |
| 135 | 135 |
|
| 136 | 136 |
for _, v := range volumes.Volumes {
|
| ... | ... |
@@ -9,7 +9,7 @@ import ( |
| 9 | 9 |
"github.com/moby/moby/api/types/filters" |
| 10 | 10 |
"github.com/moby/moby/api/types/image" |
| 11 | 11 |
"github.com/moby/moby/api/types/network" |
| 12 |
- "github.com/moby/moby/api/types/volume" |
|
| 12 |
+ "github.com/moby/moby/client" |
|
| 13 | 13 |
"github.com/moby/moby/v2/testutil" |
| 14 | 14 |
"go.opentelemetry.io/otel" |
| 15 | 15 |
"gotest.tools/v3/assert" |
| ... | ... |
@@ -230,8 +230,8 @@ func ProtectVolumes(ctx context.Context, t testing.TB, testEnv *Execution) {
|
| 230 | 230 |
|
| 231 | 231 |
func getExistingVolumes(ctx context.Context, t testing.TB, testEnv *Execution) []string {
|
| 232 | 232 |
t.Helper() |
| 233 |
- client := testEnv.APIClient() |
|
| 234 |
- volumeList, err := client.VolumeList(ctx, volume.ListOptions{})
|
|
| 233 |
+ apiClient := testEnv.APIClient() |
|
| 234 |
+ volumeList, err := apiClient.VolumeList(ctx, client.ListOptions{})
|
|
| 235 | 235 |
assert.NilError(t, err, "failed to list volumes") |
| 236 | 236 |
|
| 237 | 237 |
var volumes []string |
| ... | ... |
@@ -1,12 +1,5 @@ |
| 1 | 1 |
package volume |
| 2 | 2 |
|
| 3 |
-import "github.com/moby/moby/api/types/filters" |
|
| 4 |
- |
|
| 5 |
-// ListOptions holds parameters to list volumes. |
|
| 6 |
-type ListOptions struct {
|
|
| 7 |
- Filters filters.Args |
|
| 8 |
-} |
|
| 9 |
- |
|
| 10 | 3 |
// PruneReport contains the response for Engine API: |
| 11 | 4 |
// POST "/volumes/prune" |
| 12 | 5 |
type PruneReport struct {
|
| ... | ... |
@@ -198,7 +198,7 @@ type VolumeAPIClient interface {
|
| 198 | 198 |
VolumeCreate(ctx context.Context, options volume.CreateOptions) (volume.Volume, error) |
| 199 | 199 |
VolumeInspect(ctx context.Context, volumeID string) (volume.Volume, error) |
| 200 | 200 |
VolumeInspectWithRaw(ctx context.Context, volumeID string) (volume.Volume, []byte, error) |
| 201 |
- VolumeList(ctx context.Context, options volume.ListOptions) (volume.ListResponse, error) |
|
| 201 |
+ VolumeList(ctx context.Context, options ListOptions) (volume.ListResponse, error) |
|
| 202 | 202 |
VolumeRemove(ctx context.Context, volumeID string, force bool) error |
| 203 | 203 |
VolumesPrune(ctx context.Context, pruneFilter filters.Args) (volume.PruneReport, error) |
| 204 | 204 |
VolumeUpdate(ctx context.Context, volumeID string, version swarm.Version, options volume.UpdateOptions) error |
| ... | ... |
@@ -11,7 +11,7 @@ import ( |
| 11 | 11 |
) |
| 12 | 12 |
|
| 13 | 13 |
// VolumeList returns the volumes configured in the docker host. |
| 14 |
-func (cli *Client) VolumeList(ctx context.Context, options volume.ListOptions) (volume.ListResponse, error) {
|
|
| 14 |
+func (cli *Client) VolumeList(ctx context.Context, options ListOptions) (volume.ListResponse, error) {
|
|
| 15 | 15 |
query := url.Values{}
|
| 16 | 16 |
|
| 17 | 17 |
if options.Filters.Len() > 0 {
|