Skip to content

Commit 162ef4f

Browse files
committed
api/types: move VolumesPruneReport to api/types/volume
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 17c3269 commit 162ef4f

8 files changed

Lines changed: 23 additions & 20 deletions

File tree

api/server/router/volume/backend.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@ package volume // import "github.com/docker/docker/api/server/router/volume"
33
import (
44
"context"
55

6-
"github.com/docker/docker/volume/service/opts"
7-
// TODO return types need to be refactored into pkg
8-
"github.com/docker/docker/api/types"
96
"github.com/docker/docker/api/types/filters"
107
"github.com/docker/docker/api/types/volume"
8+
"github.com/docker/docker/volume/service/opts"
119
)
1210

1311
// Backend is the methods that need to be implemented to provide
@@ -17,7 +15,7 @@ type Backend interface {
1715
Get(ctx context.Context, name string, opts ...opts.GetOption) (*volume.Volume, error)
1816
Create(ctx context.Context, name, driverName string, opts ...opts.CreateOption) (*volume.Volume, error)
1917
Remove(ctx context.Context, name string, opts ...opts.RemoveOption) error
20-
Prune(ctx context.Context, pruneFilters filters.Args) (*types.VolumesPruneReport, error)
18+
Prune(ctx context.Context, pruneFilters filters.Args) (*volume.PruneReport, error)
2119
}
2220

2321
// ClusterBackend is the backend used for Swarm Cluster Volumes. Regular

api/server/router/volume/volume_routes_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"gotest.tools/v3/assert"
1212

1313
"github.com/docker/docker/api/server/httputils"
14-
"github.com/docker/docker/api/types"
1514
"github.com/docker/docker/api/types/filters"
1615
"github.com/docker/docker/api/types/volume"
1716
"github.com/docker/docker/errdefs"
@@ -636,7 +635,7 @@ func (b *fakeVolumeBackend) Remove(_ context.Context, name string, o ...opts.Rem
636635
return nil
637636
}
638637

639-
func (b *fakeVolumeBackend) Prune(_ context.Context, _ filters.Args) (*types.VolumesPruneReport, error) {
638+
func (b *fakeVolumeBackend) Prune(_ context.Context, _ filters.Args) (*volume.PruneReport, error) {
640639
return nil, nil
641640
}
642641

api/types/types.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -419,13 +419,6 @@ type DiskUsage struct {
419419
BuilderSize int64 `json:",omitempty"` // Deprecated: deprecated in API 1.38, and no longer used since API 1.40.
420420
}
421421

422-
// VolumesPruneReport contains the response for Engine API:
423-
// POST "/volumes/prune"
424-
type VolumesPruneReport struct {
425-
VolumesDeleted []string
426-
SpaceReclaimed uint64
427-
}
428-
429422
// ImagesPruneReport contains the response for Engine API:
430423
// POST "/images/prune"
431424
type ImagesPruneReport struct {

api/types/types_deprecated.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,15 @@ package types
33
import (
44
"github.com/docker/docker/api/types/container"
55
"github.com/docker/docker/api/types/network"
6+
"github.com/docker/docker/api/types/volume"
67
)
78

9+
// VolumesPruneReport contains the response for Engine API:
10+
// POST "/volumes/prune".
11+
//
12+
// Deprecated: use [volume.PruneReport].
13+
type VolumesPruneReport = volume.PruneReport
14+
815
// NetworkCreateRequest is the request message sent to the server for network create call.
916
//
1017
// Deprecated: use [network.CreateRequest].

api/types/volume/options.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,10 @@ import "github.com/docker/docker/api/types/filters"
66
type ListOptions struct {
77
Filters filters.Args
88
}
9+
10+
// PruneReport contains the response for Engine API:
11+
// POST "/volumes/prune"
12+
type PruneReport struct {
13+
VolumesDeleted []string
14+
SpaceReclaimed uint64
15+
}

client/interface.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ type VolumeAPIClient interface {
179179
VolumeInspectWithRaw(ctx context.Context, volumeID string) (volume.Volume, []byte, error)
180180
VolumeList(ctx context.Context, options volume.ListOptions) (volume.ListResponse, error)
181181
VolumeRemove(ctx context.Context, volumeID string, force bool) error
182-
VolumesPrune(ctx context.Context, pruneFilter filters.Args) (types.VolumesPruneReport, error)
182+
VolumesPrune(ctx context.Context, pruneFilter filters.Args) (volume.PruneReport, error)
183183
VolumeUpdate(ctx context.Context, volumeID string, version swarm.Version, options volume.UpdateOptions) error
184184
}
185185

client/volume_prune.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import (
55
"encoding/json"
66
"fmt"
77

8-
"github.com/docker/docker/api/types"
98
"github.com/docker/docker/api/types/filters"
9+
"github.com/docker/docker/api/types/volume"
1010
)
1111

1212
// VolumesPrune requests the daemon to delete unused data
13-
func (cli *Client) VolumesPrune(ctx context.Context, pruneFilters filters.Args) (types.VolumesPruneReport, error) {
14-
var report types.VolumesPruneReport
13+
func (cli *Client) VolumesPrune(ctx context.Context, pruneFilters filters.Args) (volume.PruneReport, error) {
14+
var report volume.PruneReport
1515

1616
if err := cli.NewVersionError(ctx, "1.25", "volume prune"); err != nil {
1717
return report, err

volume/service/service.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"sync/atomic"
77

88
"github.com/containerd/log"
9-
"github.com/docker/docker/api/types"
109
"github.com/docker/docker/api/types/events"
1110
"github.com/docker/docker/api/types/filters"
1211
volumetypes "github.com/docker/docker/api/types/volume"
@@ -204,7 +203,7 @@ func (s *VolumesService) LocalVolumesSize(ctx context.Context) ([]*volumetypes.V
204203
// Prune removes (local) volumes which match the past in filter arguments.
205204
// Note that this intentionally skips volumes with mount options as there would
206205
// be no space reclaimed in this case.
207-
func (s *VolumesService) Prune(ctx context.Context, filter filters.Args) (*types.VolumesPruneReport, error) {
206+
func (s *VolumesService) Prune(ctx context.Context, filter filters.Args) (*volumetypes.PruneReport, error) {
208207
if !atomic.CompareAndSwapInt32(&s.pruneRunning, 0, 1) {
209208
return nil, errdefs.Conflict(errors.New("a prune operation is already running"))
210209
}
@@ -226,7 +225,7 @@ func (s *VolumesService) Prune(ctx context.Context, filter filters.Args) (*types
226225
return nil, err
227226
}
228227

229-
rep := &types.VolumesPruneReport{VolumesDeleted: make([]string, 0, len(ls))}
228+
rep := &volumetypes.PruneReport{VolumesDeleted: make([]string, 0, len(ls))}
230229
for _, v := range ls {
231230
select {
232231
case <-ctx.Done():

0 commit comments

Comments
 (0)