Browse code

api/types: move ContainersPruneReport to api/types/container

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2024/06/09 03:19:50
Showing 8 changed files
... ...
@@ -62,7 +62,7 @@ type attachBackend interface {
62 62
 
63 63
 // systemBackend includes functions to implement to provide system wide containers functionality
64 64
 type systemBackend interface {
65
-	ContainersPrune(ctx context.Context, pruneFilters filters.Args) (*types.ContainersPruneReport, error)
65
+	ContainersPrune(ctx context.Context, pruneFilters filters.Args) (*container.PruneReport, error)
66 66
 }
67 67
 
68 68
 type commitBackend interface {
69 69
new file mode 100644
... ...
@@ -0,0 +1,8 @@
0
+package container
1
+
2
+// PruneReport contains the response for Engine API:
3
+// POST "/containers/prune"
4
+type PruneReport struct {
5
+	ContainersDeleted []string
6
+	SpaceReclaimed    uint64
7
+}
... ...
@@ -439,13 +439,6 @@ type DiskUsage struct {
439 439
 	BuilderSize int64 `json:",omitempty"` // Deprecated: deprecated in API 1.38, and no longer used since API 1.40.
440 440
 }
441 441
 
442
-// ContainersPruneReport contains the response for Engine API:
443
-// POST "/containers/prune"
444
-type ContainersPruneReport struct {
445
-	ContainersDeleted []string
446
-	SpaceReclaimed    uint64
447
-}
448
-
449 442
 // VolumesPruneReport contains the response for Engine API:
450 443
 // POST "/volumes/prune"
451 444
 type VolumesPruneReport struct {
... ...
@@ -72,3 +72,9 @@ type ExecStartCheck = container.ExecStartOptions
72 72
 //
73 73
 // Deprecated: use [container.ExecInspect].
74 74
 type ContainerExecInspect = container.ExecInspect
75
+
76
+// ContainersPruneReport contains the response for Engine API:
77
+// POST "/containers/prune"
78
+//
79
+// Deprecated: use [container.PruneReport].
80
+type ContainersPruneReport = container.PruneReport
... ...
@@ -5,13 +5,13 @@ import (
5 5
 	"encoding/json"
6 6
 	"fmt"
7 7
 
8
-	"github.com/docker/docker/api/types"
8
+	"github.com/docker/docker/api/types/container"
9 9
 	"github.com/docker/docker/api/types/filters"
10 10
 )
11 11
 
12 12
 // ContainersPrune requests the daemon to delete unused data
13
-func (cli *Client) ContainersPrune(ctx context.Context, pruneFilters filters.Args) (types.ContainersPruneReport, error) {
14
-	var report types.ContainersPruneReport
13
+func (cli *Client) ContainersPrune(ctx context.Context, pruneFilters filters.Args) (container.PruneReport, error) {
14
+	var report container.PruneReport
15 15
 
16 16
 	if err := cli.NewVersionError(ctx, "1.25", "container prune"); err != nil {
17 17
 		return report, err
... ...
@@ -10,7 +10,7 @@ import (
10 10
 	"strings"
11 11
 	"testing"
12 12
 
13
-	"github.com/docker/docker/api/types"
13
+	"github.com/docker/docker/api/types/container"
14 14
 	"github.com/docker/docker/api/types/filters"
15 15
 	"github.com/docker/docker/errdefs"
16 16
 	"gotest.tools/v3/assert"
... ...
@@ -93,7 +93,7 @@ func TestContainersPrune(t *testing.T) {
93 93
 					actual := query.Get(key)
94 94
 					assert.Check(t, is.Equal(expected, actual))
95 95
 				}
96
-				content, err := json.Marshal(types.ContainersPruneReport{
96
+				content, err := json.Marshal(container.PruneReport{
97 97
 					ContainersDeleted: []string{"container_id1", "container_id2"},
98 98
 					SpaceReclaimed:    9999,
99 99
 				})
... ...
@@ -77,7 +77,7 @@ type ContainerAPIClient interface {
77 77
 	ContainerWait(ctx context.Context, container string, condition container.WaitCondition) (<-chan container.WaitResponse, <-chan error)
78 78
 	CopyFromContainer(ctx context.Context, container, srcPath string) (io.ReadCloser, types.ContainerPathStat, error)
79 79
 	CopyToContainer(ctx context.Context, container, path string, content io.Reader, options types.CopyToContainerOptions) error
80
-	ContainersPrune(ctx context.Context, pruneFilters filters.Args) (types.ContainersPruneReport, error)
80
+	ContainersPrune(ctx context.Context, pruneFilters filters.Args) (container.PruneReport, error)
81 81
 }
82 82
 
83 83
 // DistributionAPIClient defines API client methods for the registry
... ...
@@ -8,8 +8,8 @@ import (
8 8
 	"time"
9 9
 
10 10
 	"github.com/containerd/log"
11
-	"github.com/docker/docker/api/types"
12 11
 	"github.com/docker/docker/api/types/backend"
12
+	"github.com/docker/docker/api/types/container"
13 13
 	"github.com/docker/docker/api/types/events"
14 14
 	"github.com/docker/docker/api/types/filters"
15 15
 	"github.com/docker/docker/api/types/network"
... ...
@@ -39,13 +39,13 @@ var (
39 39
 )
40 40
 
41 41
 // ContainersPrune removes unused containers
42
-func (daemon *Daemon) ContainersPrune(ctx context.Context, pruneFilters filters.Args) (*types.ContainersPruneReport, error) {
42
+func (daemon *Daemon) ContainersPrune(ctx context.Context, pruneFilters filters.Args) (*container.PruneReport, error) {
43 43
 	if !atomic.CompareAndSwapInt32(&daemon.pruneRunning, 0, 1) {
44 44
 		return nil, errPruneRunning
45 45
 	}
46 46
 	defer atomic.StoreInt32(&daemon.pruneRunning, 0)
47 47
 
48
-	rep := &types.ContainersPruneReport{}
48
+	rep := &container.PruneReport{}
49 49
 
50 50
 	// make sure that only accepted filters have been received
51 51
 	err := pruneFilters.Validate(containersAcceptedFilters)