Skip to content

Commit e0db820

Browse files
committed
api: add BuildCache.Parents for API >= v1.42
This field was added to replace the deprecated "Parent" field. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent ebf3396 commit e0db820

File tree

5 files changed

+18
-1
lines changed

5 files changed

+18
-1
lines changed

api/server/router/system/system_routes.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ func (s *systemRouter) getDiskUsage(ctx context.Context, w http.ResponseWriter,
174174
if versions.LessThan(version, "1.42") {
175175
for _, b := range buildCache {
176176
builderSize += b.Size
177+
// Parents field was added in API 1.42 to replace the Parent field.
178+
b.Parents = nil
177179
}
178180
}
179181
if versions.GreaterThanOrEqualTo(version, "1.42") {

api/swagger.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2263,6 +2263,14 @@ definitions:
22632263
type: "string"
22642264
x-nullable: true
22652265
example: ""
2266+
Parents:
2267+
description: |
2268+
List of parent build cache record IDs.
2269+
type: "array"
2270+
items:
2271+
type: "string"
2272+
x-nullable: true
2273+
example: ["hw53o5aio51xtltp5xjp8v7fx"]
22662274
Type:
22672275
type: "string"
22682276
description: |
@@ -9068,6 +9076,7 @@ paths:
90689076
BuildCache:
90699077
-
90709078
ID: "hw53o5aio51xtltp5xjp8v7fx"
9079+
Parents: []
90719080
Type: "regular"
90729081
Description: "pulled from docker.io/library/debian@sha256:234cb88d3020898631af0ccbbcca9a66ae7306ecd30c9720690858c1b007d2a0"
90739082
InUse: false
@@ -9078,6 +9087,7 @@ paths:
90789087
UsageCount: 26
90799088
-
90809089
ID: "ndlpt0hhvkqcdfkputsk4cq9c"
9090+
Parents: ["ndlpt0hhvkqcdfkputsk4cq9c"]
90819091
Type: "regular"
90829092
Description: "mount / from exec /bin/sh -c echo 'Binary::apt::APT::Keep-Downloaded-Packages \"true\";' > /etc/apt/apt.conf.d/keep-cache"
90839093
InUse: false

api/types/types.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,8 +778,10 @@ type BuildCache struct {
778778
ID string
779779
// Parent is the ID of the parent build cache record.
780780
//
781-
// Deprecated: deprecated in API v1.42 and up, as it was deprecated in BuildKit.
781+
// Deprecated: deprecated in API v1.42 and up, as it was deprecated in BuildKit; use Parents instead.
782782
Parent string `json:"Parent,omitempty"`
783+
// Parents is the list of parent build cache record IDs.
784+
Parents []string `json:" Parents,omitempty"`
783785
// Type is the cache record type.
784786
Type string
785787
// Description is a description of the build-step that produced the build cache.

builder/builder-next/builder.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ func (b *Builder) DiskUsage(ctx context.Context) ([]*types.BuildCache, error) {
130130
items = append(items, &types.BuildCache{
131131
ID: r.ID,
132132
Parent: r.Parent, //nolint:staticcheck // ignore SA1019 (Parent field is deprecated)
133+
Parents: r.Parents,
133134
Type: r.RecordType,
134135
Description: r.Description,
135136
InUse: r.InUse,

docs/api/version-history.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ keywords: "API, Docker, rcli, REST, documentation"
8989
with information about the created volume.
9090
* The `BuildCache.Parent` field, as returned by `GET /system/df` is deprecated
9191
and is now omitted. API versions before v1.42 continue to include this field.
92+
* `GET /system/df` now includes a new `Parents` field, for "build-cache" records,
93+
which contains a list of parent IDs for the build-cache record.
9294
* Volume information returned by `GET /volumes/{name}`, `GET /volumes` and
9395
`GET /system/df` can now contain a `ClusterVolume` if the volume is a cluster
9496
volume (requires the daemon to be a Swarm manager).

0 commit comments

Comments
 (0)