Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -8,6 +8,7 @@ import ( |
| 8 | 8 |
"github.com/distribution/reference" |
| 9 | 9 |
"github.com/docker/docker/api/types" |
| 10 | 10 |
"github.com/docker/docker/api/types/backend" |
| 11 |
+ "github.com/docker/docker/api/types/build" |
|
| 11 | 12 |
"github.com/docker/docker/api/types/events" |
| 12 | 13 |
"github.com/docker/docker/builder" |
| 13 | 14 |
buildkit "github.com/docker/docker/builder/builder-next" |
| ... | ... |
@@ -97,7 +98,7 @@ func (b *Backend) Build(ctx context.Context, config backend.BuildConfig) (string |
| 97 | 97 |
} |
| 98 | 98 |
|
| 99 | 99 |
// PruneCache removes all cached build sources |
| 100 |
-func (b *Backend) PruneCache(ctx context.Context, opts types.BuildCachePruneOptions) (*types.BuildCachePruneReport, error) {
|
|
| 100 |
+func (b *Backend) PruneCache(ctx context.Context, opts build.CachePruneOptions) (*build.CachePruneReport, error) {
|
|
| 101 | 101 |
buildCacheSize, cacheIDs, err := b.buildkit.Prune(ctx, opts) |
| 102 | 102 |
if err != nil {
|
| 103 | 103 |
return nil, errors.Wrap(err, "failed to prune build cache") |
| ... | ... |
@@ -107,7 +108,7 @@ func (b *Backend) PruneCache(ctx context.Context, opts types.BuildCachePruneOpti |
| 107 | 107 |
"reclaimed": strconv.FormatInt(buildCacheSize, 10), |
| 108 | 108 |
}, |
| 109 | 109 |
}) |
| 110 |
- return &types.BuildCachePruneReport{SpaceReclaimed: uint64(buildCacheSize), CachesDeleted: cacheIDs}, nil
|
|
| 110 |
+ return &build.CachePruneReport{SpaceReclaimed: uint64(buildCacheSize), CachesDeleted: cacheIDs}, nil
|
|
| 111 | 111 |
} |
| 112 | 112 |
|
| 113 | 113 |
// Cancel cancels the build by ID |
| ... | ... |
@@ -3,8 +3,8 @@ package build // import "github.com/docker/docker/api/server/router/build" |
| 3 | 3 |
import ( |
| 4 | 4 |
"context" |
| 5 | 5 |
|
| 6 |
- "github.com/docker/docker/api/types" |
|
| 7 | 6 |
"github.com/docker/docker/api/types/backend" |
| 7 |
+ "github.com/docker/docker/api/types/build" |
|
| 8 | 8 |
) |
| 9 | 9 |
|
| 10 | 10 |
// Backend abstracts an image builder whose only purpose is to build an image referenced by an imageID. |
| ... | ... |
@@ -13,8 +13,8 @@ type Backend interface {
|
| 13 | 13 |
// TODO: make this return a reference instead of string |
| 14 | 14 |
Build(context.Context, backend.BuildConfig) (string, error) |
| 15 | 15 |
|
| 16 |
- // Prune build cache |
|
| 17 |
- PruneCache(context.Context, types.BuildCachePruneOptions) (*types.BuildCachePruneReport, error) |
|
| 16 |
+ // PruneCache prunes the build cache. |
|
| 17 |
+ PruneCache(context.Context, build.CachePruneOptions) (*build.CachePruneReport, error) |
|
| 18 | 18 |
Cancel(context.Context, string) error |
| 19 | 19 |
} |
| 20 | 20 |
|
| ... | ... |
@@ -19,6 +19,7 @@ import ( |
| 19 | 19 |
"github.com/docker/docker/api/server/httputils" |
| 20 | 20 |
"github.com/docker/docker/api/types" |
| 21 | 21 |
"github.com/docker/docker/api/types/backend" |
| 22 |
+ "github.com/docker/docker/api/types/build" |
|
| 22 | 23 |
"github.com/docker/docker/api/types/container" |
| 23 | 24 |
"github.com/docker/docker/api/types/filters" |
| 24 | 25 |
"github.com/docker/docker/api/types/registry" |
| ... | ... |
@@ -179,7 +180,7 @@ func (br *buildRouter) postPrune(ctx context.Context, w http.ResponseWriter, r * |
| 179 | 179 |
return err |
| 180 | 180 |
} |
| 181 | 181 |
|
| 182 |
- opts := types.BuildCachePruneOptions{
|
|
| 182 |
+ opts := build.CachePruneOptions{
|
|
| 183 | 183 |
All: httputils.BoolValue(r, "all"), |
| 184 | 184 |
Filters: fltrs, |
| 185 | 185 |
} |
| ... | ... |
@@ -1,6 +1,10 @@ |
| 1 | 1 |
package build |
| 2 | 2 |
|
| 3 |
-import "time" |
|
| 3 |
+import ( |
|
| 4 |
+ "time" |
|
| 5 |
+ |
|
| 6 |
+ "github.com/docker/docker/api/types/filters" |
|
| 7 |
+) |
|
| 4 | 8 |
|
| 5 | 9 |
// CacheRecord contains information about a build cache record. |
| 6 | 10 |
type CacheRecord struct {
|
| ... | ... |
@@ -28,3 +32,21 @@ type CacheRecord struct {
|
| 28 | 28 |
LastUsedAt *time.Time |
| 29 | 29 |
UsageCount int |
| 30 | 30 |
} |
| 31 |
+ |
|
| 32 |
+// CachePruneOptions hold parameters to prune the build cache. |
|
| 33 |
+type CachePruneOptions struct {
|
|
| 34 |
+ All bool |
|
| 35 |
+ ReservedSpace int64 |
|
| 36 |
+ MaxUsedSpace int64 |
|
| 37 |
+ MinFreeSpace int64 |
|
| 38 |
+ Filters filters.Args |
|
| 39 |
+ |
|
| 40 |
+ KeepStorage int64 // Deprecated: deprecated in API 1.48. |
|
| 41 |
+} |
|
| 42 |
+ |
|
| 43 |
+// CachePruneReport contains the response for Engine API: |
|
| 44 |
+// POST "/build/prune" |
|
| 45 |
+type CachePruneReport struct {
|
|
| 46 |
+ CachesDeleted []string |
|
| 47 |
+ SpaceReclaimed uint64 |
|
| 48 |
+} |
| ... | ... |
@@ -90,17 +90,10 @@ type DiskUsage struct {
|
| 90 | 90 |
Images []*image.Summary |
| 91 | 91 |
Containers []*container.Summary |
| 92 | 92 |
Volumes []*volume.Volume |
| 93 |
- BuildCache []*BuildCache |
|
| 93 |
+ BuildCache []*build.CacheRecord |
|
| 94 | 94 |
BuilderSize int64 `json:",omitempty"` // Deprecated: deprecated in API 1.38, and no longer used since API 1.40. |
| 95 | 95 |
} |
| 96 | 96 |
|
| 97 |
-// BuildCachePruneReport contains the response for Engine API: |
|
| 98 |
-// POST "/build/prune" |
|
| 99 |
-type BuildCachePruneReport struct {
|
|
| 100 |
- CachesDeleted []string |
|
| 101 |
- SpaceReclaimed uint64 |
|
| 102 |
-} |
|
| 103 |
- |
|
| 104 | 97 |
// SecretCreateResponse contains the information returned to a client |
| 105 | 98 |
// on the creation of a new secret. |
| 106 | 99 |
type SecretCreateResponse struct {
|
| ... | ... |
@@ -138,19 +131,3 @@ type PushResult struct {
|
| 138 | 138 |
type BuildResult struct {
|
| 139 | 139 |
ID string |
| 140 | 140 |
} |
| 141 |
- |
|
| 142 |
-// BuildCache contains information about a build cache record. |
|
| 143 |
-// |
|
| 144 |
-// Deprecated: deprecated in API 1.49. Use [build.CacheRecord] instead. |
|
| 145 |
-type BuildCache = build.CacheRecord |
|
| 146 |
- |
|
| 147 |
-// BuildCachePruneOptions hold parameters to prune the build cache |
|
| 148 |
-type BuildCachePruneOptions struct {
|
|
| 149 |
- All bool |
|
| 150 |
- ReservedSpace int64 |
|
| 151 |
- MaxUsedSpace int64 |
|
| 152 |
- MinFreeSpace int64 |
|
| 153 |
- Filters filters.Args |
|
| 154 |
- |
|
| 155 |
- KeepStorage int64 // Deprecated: deprecated in API 1.48. |
|
| 156 |
-} |
| ... | ... |
@@ -3,6 +3,7 @@ package types |
| 3 | 3 |
import ( |
| 4 | 4 |
"context" |
| 5 | 5 |
|
| 6 |
+ "github.com/docker/docker/api/types/build" |
|
| 6 | 7 |
"github.com/docker/docker/api/types/common" |
| 7 | 8 |
"github.com/docker/docker/api/types/container" |
| 8 | 9 |
"github.com/docker/docker/api/types/image" |
| ... | ... |
@@ -113,3 +114,19 @@ type ImageInspect = image.InspectResponse |
| 113 | 113 |
// |
| 114 | 114 |
// Deprecated: moved to [github.com/docker/docker/api/types/registry.RequestAuthConfig]. |
| 115 | 115 |
type RequestPrivilegeFunc func(context.Context) (string, error) |
| 116 |
+ |
|
| 117 |
+// BuildCache contains information about a build cache record. |
|
| 118 |
+// |
|
| 119 |
+// Deprecated: deprecated in API 1.49. Use [build.CacheRecord] instead. |
|
| 120 |
+type BuildCache = build.CacheRecord |
|
| 121 |
+ |
|
| 122 |
+// BuildCachePruneOptions hold parameters to prune the build cache |
|
| 123 |
+// |
|
| 124 |
+// Deprecated: use [build.CachePruneOptions]. |
|
| 125 |
+type BuildCachePruneOptions = build.CachePruneOptions |
|
| 126 |
+ |
|
| 127 |
+// BuildCachePruneReport contains the response for Engine API: |
|
| 128 |
+// POST "/build/prune" |
|
| 129 |
+// |
|
| 130 |
+// Deprecated: use [build.CachePruneReport]. |
|
| 131 |
+type BuildCachePruneReport = build.CachePruneReport |
| ... | ... |
@@ -187,7 +187,7 @@ func (b *Builder) DiskUsage(ctx context.Context) ([]*build.CacheRecord, error) {
|
| 187 | 187 |
} |
| 188 | 188 |
|
| 189 | 189 |
// Prune clears all reclaimable build cache. |
| 190 |
-func (b *Builder) Prune(ctx context.Context, opts types.BuildCachePruneOptions) (int64, []string, error) {
|
|
| 190 |
+func (b *Builder) Prune(ctx context.Context, opts build.CachePruneOptions) (int64, []string, error) {
|
|
| 191 | 191 |
ch := make(chan *controlapi.UsageRecord) |
| 192 | 192 |
|
| 193 | 193 |
eg, ctx := errgroup.WithContext(ctx) |
| ... | ... |
@@ -641,7 +641,7 @@ func toBuildkitUlimits(inp []*container.Ulimit) (string, error) {
|
| 641 | 641 |
return strings.Join(ulimits, ","), nil |
| 642 | 642 |
} |
| 643 | 643 |
|
| 644 |
-func toBuildkitPruneInfo(opts types.BuildCachePruneOptions) (client.PruneInfo, error) {
|
|
| 644 |
+func toBuildkitPruneInfo(opts build.CachePruneOptions) (client.PruneInfo, error) {
|
|
| 645 | 645 |
var until time.Duration |
| 646 | 646 |
untilValues := opts.Filters.Get("until") // canonical
|
| 647 | 647 |
unusedForValues := opts.Filters.Get("unused-for") // deprecated synonym for "until" filter
|
| ... | ... |
@@ -16,7 +16,7 @@ import ( |
| 16 | 16 |
"github.com/containerd/containerd/v2/plugins/content/local" |
| 17 | 17 |
"github.com/containerd/log" |
| 18 | 18 |
"github.com/containerd/platforms" |
| 19 |
- "github.com/docker/docker/api/types" |
|
| 19 |
+ "github.com/docker/docker/api/types/build" |
|
| 20 | 20 |
"github.com/docker/docker/api/types/filters" |
| 21 | 21 |
"github.com/docker/docker/builder/builder-next/adapters/containerimage" |
| 22 | 22 |
"github.com/docker/docker/builder/builder-next/adapters/localinlinecache" |
| ... | ... |
@@ -467,7 +467,7 @@ func getGCPolicy(conf config.BuilderConfig, root string) ([]client.PruneInfo, er |
| 467 | 467 |
return nil, err |
| 468 | 468 |
} |
| 469 | 469 |
|
| 470 |
- gcPolicy[i], err = toBuildkitPruneInfo(types.BuildCachePruneOptions{
|
|
| 470 |
+ gcPolicy[i], err = toBuildkitPruneInfo(build.CachePruneOptions{
|
|
| 471 | 471 |
All: p.All, |
| 472 | 472 |
ReservedSpace: reservedSpace, |
| 473 | 473 |
MaxUsedSpace: maxUsedSpace, |
| ... | ... |
@@ -6,13 +6,13 @@ import ( |
| 6 | 6 |
"net/url" |
| 7 | 7 |
"strconv" |
| 8 | 8 |
|
| 9 |
- "github.com/docker/docker/api/types" |
|
| 9 |
+ "github.com/docker/docker/api/types/build" |
|
| 10 | 10 |
"github.com/docker/docker/api/types/filters" |
| 11 | 11 |
"github.com/pkg/errors" |
| 12 | 12 |
) |
| 13 | 13 |
|
| 14 | 14 |
// BuildCachePrune requests the daemon to delete unused cache data |
| 15 |
-func (cli *Client) BuildCachePrune(ctx context.Context, opts types.BuildCachePruneOptions) (*types.BuildCachePruneReport, error) {
|
|
| 15 |
+func (cli *Client) BuildCachePrune(ctx context.Context, opts build.CachePruneOptions) (*build.CachePruneReport, error) {
|
|
| 16 | 16 |
if err := cli.NewVersionError(ctx, "1.31", "build prune"); err != nil {
|
| 17 | 17 |
return nil, err |
| 18 | 18 |
} |
| ... | ... |
@@ -47,7 +47,7 @@ func (cli *Client) BuildCachePrune(ctx context.Context, opts types.BuildCachePru |
| 47 | 47 |
return nil, err |
| 48 | 48 |
} |
| 49 | 49 |
|
| 50 |
- report := types.BuildCachePruneReport{}
|
|
| 50 |
+ report := build.CachePruneReport{}
|
|
| 51 | 51 |
if err := json.NewDecoder(resp.Body).Decode(&report); err != nil {
|
| 52 | 52 |
return nil, errors.Wrap(err, "error retrieving disk usage") |
| 53 | 53 |
} |
| ... | ... |
@@ -7,6 +7,7 @@ import ( |
| 7 | 7 |
"net/http" |
| 8 | 8 |
|
| 9 | 9 |
"github.com/docker/docker/api/types" |
| 10 |
+ "github.com/docker/docker/api/types/build" |
|
| 10 | 11 |
"github.com/docker/docker/api/types/container" |
| 11 | 12 |
"github.com/docker/docker/api/types/events" |
| 12 | 13 |
"github.com/docker/docker/api/types/filters" |
| ... | ... |
@@ -110,7 +111,7 @@ type DistributionAPIClient interface {
|
| 110 | 110 |
// ImageAPIClient defines API client methods for the images |
| 111 | 111 |
type ImageAPIClient interface {
|
| 112 | 112 |
ImageBuild(ctx context.Context, context io.Reader, options types.ImageBuildOptions) (types.ImageBuildResponse, error) |
| 113 |
- BuildCachePrune(ctx context.Context, opts types.BuildCachePruneOptions) (*types.BuildCachePruneReport, error) |
|
| 113 |
+ BuildCachePrune(ctx context.Context, opts build.CachePruneOptions) (*build.CachePruneReport, error) |
|
| 114 | 114 |
BuildCancel(ctx context.Context, id string) error |
| 115 | 115 |
ImageCreate(ctx context.Context, parentReference string, options image.CreateOptions) (io.ReadCloser, error) |
| 116 | 116 |
ImageImport(ctx context.Context, source image.ImportSource, ref string, options image.ImportOptions) (io.ReadCloser, error) |