Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -5,7 +5,6 @@ import ( |
| 5 | 5 |
"io" |
| 6 | 6 |
|
| 7 | 7 |
"github.com/distribution/reference" |
| 8 |
- "github.com/docker/docker/api/types" |
|
| 9 | 8 |
"github.com/docker/docker/api/types/backend" |
| 10 | 9 |
"github.com/docker/docker/api/types/filters" |
| 11 | 10 |
"github.com/docker/docker/api/types/image" |
| ... | ... |
@@ -28,7 +27,7 @@ type imageBackend interface {
|
| 28 | 28 |
Images(ctx context.Context, opts image.ListOptions) ([]*image.Summary, error) |
| 29 | 29 |
GetImage(ctx context.Context, refOrID string, options backend.GetImageOpts) (*dockerimage.Image, error) |
| 30 | 30 |
TagImage(ctx context.Context, id dockerimage.ID, newRef reference.Named) error |
| 31 |
- ImagesPrune(ctx context.Context, pruneFilters filters.Args) (*types.ImagesPruneReport, error) |
|
| 31 |
+ ImagesPrune(ctx context.Context, pruneFilters filters.Args) (*image.PruneReport, error) |
|
| 32 | 32 |
} |
| 33 | 33 |
|
| 34 | 34 |
type importExportBackend interface {
|
| ... | ... |
@@ -7,3 +7,10 @@ type Metadata struct {
|
| 7 | 7 |
// LastTagTime is the date and time at which the image was last tagged. |
| 8 | 8 |
LastTagTime time.Time `json:",omitempty"` |
| 9 | 9 |
} |
| 10 |
+ |
|
| 11 |
+// PruneReport contains the response for Engine API: |
|
| 12 |
+// POST "/images/prune" |
|
| 13 |
+type PruneReport struct {
|
|
| 14 |
+ ImagesDeleted []DeleteResponse |
|
| 15 |
+ SpaceReclaimed uint64 |
|
| 16 |
+} |
| ... | ... |
@@ -419,13 +419,6 @@ type DiskUsage struct {
|
| 419 | 419 |
BuilderSize int64 `json:",omitempty"` // Deprecated: deprecated in API 1.38, and no longer used since API 1.40. |
| 420 | 420 |
} |
| 421 | 421 |
|
| 422 |
-// ImagesPruneReport contains the response for Engine API: |
|
| 423 |
-// POST "/images/prune" |
|
| 424 |
-type ImagesPruneReport struct {
|
|
| 425 |
- ImagesDeleted []image.DeleteResponse |
|
| 426 |
- SpaceReclaimed uint64 |
|
| 427 |
-} |
|
| 428 |
- |
|
| 429 | 422 |
// BuildCachePruneReport contains the response for Engine API: |
| 430 | 423 |
// POST "/build/prune" |
| 431 | 424 |
type BuildCachePruneReport struct {
|
| ... | ... |
@@ -2,10 +2,17 @@ package types |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 | 4 |
"github.com/docker/docker/api/types/container" |
| 5 |
+ "github.com/docker/docker/api/types/image" |
|
| 5 | 6 |
"github.com/docker/docker/api/types/network" |
| 6 | 7 |
"github.com/docker/docker/api/types/volume" |
| 7 | 8 |
) |
| 8 | 9 |
|
| 10 |
+// ImagesPruneReport contains the response for Engine API: |
|
| 11 |
+// POST "/images/prune" |
|
| 12 |
+// |
|
| 13 |
+// Deprecated: use [image.PruneReport]. |
|
| 14 |
+type ImagesPruneReport = image.PruneReport |
|
| 15 |
+ |
|
| 9 | 16 |
// VolumesPruneReport contains the response for Engine API: |
| 10 | 17 |
// POST "/volumes/prune". |
| 11 | 18 |
// |
| ... | ... |
@@ -5,13 +5,13 @@ import ( |
| 5 | 5 |
"encoding/json" |
| 6 | 6 |
"fmt" |
| 7 | 7 |
|
| 8 |
- "github.com/docker/docker/api/types" |
|
| 9 | 8 |
"github.com/docker/docker/api/types/filters" |
| 9 |
+ "github.com/docker/docker/api/types/image" |
|
| 10 | 10 |
) |
| 11 | 11 |
|
| 12 | 12 |
// ImagesPrune requests the daemon to delete unused data |
| 13 |
-func (cli *Client) ImagesPrune(ctx context.Context, pruneFilters filters.Args) (types.ImagesPruneReport, error) {
|
|
| 14 |
- var report types.ImagesPruneReport |
|
| 13 |
+func (cli *Client) ImagesPrune(ctx context.Context, pruneFilters filters.Args) (image.PruneReport, error) {
|
|
| 14 |
+ var report image.PruneReport |
|
| 15 | 15 |
|
| 16 | 16 |
if err := cli.NewVersionError(ctx, "1.25", "image prune"); err != nil {
|
| 17 | 17 |
return report, err |
| ... | ... |
@@ -13,7 +13,6 @@ import ( |
| 13 | 13 |
"github.com/docker/docker/api/types/image" |
| 14 | 14 |
"github.com/docker/docker/errdefs" |
| 15 | 15 |
|
| 16 |
- "github.com/docker/docker/api/types" |
|
| 17 | 16 |
"github.com/docker/docker/api/types/filters" |
| 18 | 17 |
"gotest.tools/v3/assert" |
| 19 | 18 |
is "gotest.tools/v3/assert/cmp" |
| ... | ... |
@@ -84,7 +83,7 @@ func TestImagesPrune(t *testing.T) {
|
| 84 | 84 |
actual := query.Get(key) |
| 85 | 85 |
assert.Check(t, is.Equal(expected, actual)) |
| 86 | 86 |
} |
| 87 |
- content, err := json.Marshal(types.ImagesPruneReport{
|
|
| 87 |
+ content, err := json.Marshal(image.PruneReport{
|
|
| 88 | 88 |
ImagesDeleted: []image.DeleteResponse{
|
| 89 | 89 |
{
|
| 90 | 90 |
Deleted: "image_id1", |
| ... | ... |
@@ -102,7 +102,7 @@ type ImageAPIClient interface {
|
| 102 | 102 |
ImageSearch(ctx context.Context, term string, options types.ImageSearchOptions) ([]registry.SearchResult, error) |
| 103 | 103 |
ImageSave(ctx context.Context, images []string) (io.ReadCloser, error) |
| 104 | 104 |
ImageTag(ctx context.Context, image, ref string) error |
| 105 |
- ImagesPrune(ctx context.Context, pruneFilter filters.Args) (types.ImagesPruneReport, error) |
|
| 105 |
+ ImagesPrune(ctx context.Context, pruneFilter filters.Args) (image.PruneReport, error) |
|
| 106 | 106 |
} |
| 107 | 107 |
|
| 108 | 108 |
// NetworkAPIClient defines API client methods for the networks |
| ... | ... |
@@ -8,7 +8,6 @@ import ( |
| 8 | 8 |
cerrdefs "github.com/containerd/errdefs" |
| 9 | 9 |
"github.com/containerd/log" |
| 10 | 10 |
"github.com/distribution/reference" |
| 11 |
- "github.com/docker/docker/api/types" |
|
| 12 | 11 |
"github.com/docker/docker/api/types/filters" |
| 13 | 12 |
"github.com/docker/docker/api/types/image" |
| 14 | 13 |
"github.com/docker/docker/errdefs" |
| ... | ... |
@@ -31,7 +30,7 @@ var imagesAcceptedFilters = map[string]bool{
|
| 31 | 31 |
var errPruneRunning = errdefs.Conflict(errors.New("a prune operation is already running"))
|
| 32 | 32 |
|
| 33 | 33 |
// ImagesPrune removes unused images |
| 34 |
-func (i *ImageService) ImagesPrune(ctx context.Context, fltrs filters.Args) (*types.ImagesPruneReport, error) {
|
|
| 34 |
+func (i *ImageService) ImagesPrune(ctx context.Context, fltrs filters.Args) (*image.PruneReport, error) {
|
|
| 35 | 35 |
if !i.pruneRunning.CompareAndSwap(false, true) {
|
| 36 | 36 |
return nil, errPruneRunning |
| 37 | 37 |
} |
| ... | ... |
@@ -62,8 +61,8 @@ func (i *ImageService) ImagesPrune(ctx context.Context, fltrs filters.Args) (*ty |
| 62 | 62 |
return i.pruneUnused(ctx, filterFunc, danglingOnly) |
| 63 | 63 |
} |
| 64 | 64 |
|
| 65 |
-func (i *ImageService) pruneUnused(ctx context.Context, filterFunc imageFilterFunc, danglingOnly bool) (*types.ImagesPruneReport, error) {
|
|
| 66 |
- report := types.ImagesPruneReport{}
|
|
| 65 |
+func (i *ImageService) pruneUnused(ctx context.Context, filterFunc imageFilterFunc, danglingOnly bool) (*image.PruneReport, error) {
|
|
| 66 |
+ report := image.PruneReport{}
|
|
| 67 | 67 |
|
| 68 | 68 |
allImages, err := i.images.List(ctx) |
| 69 | 69 |
if err != nil {
|
| ... | ... |
@@ -5,7 +5,6 @@ import ( |
| 5 | 5 |
"io" |
| 6 | 6 |
|
| 7 | 7 |
"github.com/distribution/reference" |
| 8 |
- "github.com/docker/docker/api/types" |
|
| 9 | 8 |
"github.com/docker/docker/api/types/backend" |
| 10 | 9 |
"github.com/docker/docker/api/types/events" |
| 11 | 10 |
"github.com/docker/docker/api/types/filters" |
| ... | ... |
@@ -37,7 +36,7 @@ type ImageService interface {
|
| 37 | 37 |
Images(ctx context.Context, opts imagetype.ListOptions) ([]*imagetype.Summary, error) |
| 38 | 38 |
LogImageEvent(imageID, refName string, action events.Action) |
| 39 | 39 |
CountImages(ctx context.Context) int |
| 40 |
- ImagesPrune(ctx context.Context, pruneFilters filters.Args) (*types.ImagesPruneReport, error) |
|
| 40 |
+ ImagesPrune(ctx context.Context, pruneFilters filters.Args) (*imagetype.PruneReport, error) |
|
| 41 | 41 |
ImportImage(ctx context.Context, ref reference.Named, platform *ocispec.Platform, msg string, layerReader io.Reader, changes []string) (image.ID, error) |
| 42 | 42 |
TagImage(ctx context.Context, imageID image.ID, newTag reference.Named) error |
| 43 | 43 |
GetImage(ctx context.Context, refOrID string, options backend.GetImageOpts) (*image.Image, error) |
| ... | ... |
@@ -9,7 +9,6 @@ import ( |
| 9 | 9 |
|
| 10 | 10 |
"github.com/containerd/log" |
| 11 | 11 |
"github.com/distribution/reference" |
| 12 |
- "github.com/docker/docker/api/types" |
|
| 13 | 12 |
"github.com/docker/docker/api/types/events" |
| 14 | 13 |
"github.com/docker/docker/api/types/filters" |
| 15 | 14 |
imagetypes "github.com/docker/docker/api/types/image" |
| ... | ... |
@@ -33,7 +32,7 @@ var imagesAcceptedFilters = map[string]bool{
|
| 33 | 33 |
var errPruneRunning = errdefs.Conflict(errors.New("a prune operation is already running"))
|
| 34 | 34 |
|
| 35 | 35 |
// ImagesPrune removes unused images |
| 36 |
-func (i *ImageService) ImagesPrune(ctx context.Context, pruneFilters filters.Args) (*types.ImagesPruneReport, error) {
|
|
| 36 |
+func (i *ImageService) ImagesPrune(ctx context.Context, pruneFilters filters.Args) (*imagetypes.PruneReport, error) {
|
|
| 37 | 37 |
if !atomic.CompareAndSwapInt32(&i.pruneRunning, 0, 1) {
|
| 38 | 38 |
return nil, errPruneRunning |
| 39 | 39 |
} |
| ... | ... |
@@ -45,7 +44,7 @@ func (i *ImageService) ImagesPrune(ctx context.Context, pruneFilters filters.Arg |
| 45 | 45 |
return nil, err |
| 46 | 46 |
} |
| 47 | 47 |
|
| 48 |
- rep := &types.ImagesPruneReport{}
|
|
| 48 |
+ rep := &imagetypes.PruneReport{}
|
|
| 49 | 49 |
|
| 50 | 50 |
danglingOnly, err := pruneFilters.GetBoolOrDefault("dangling", true)
|
| 51 | 51 |
if err != nil {
|