Quellcode durchsuchen

api: deprecate BuildCache.Parent in API >= v1.42

This field has been deprecated in BuildKit, so this follows the deprecation
in the Engine API.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn vor 3 Jahren
Ursprung
Commit
ebf339628a

+ 7 - 0
api/server/router/system/system_routes.go

@@ -176,6 +176,13 @@ func (s *systemRouter) getDiskUsage(ctx context.Context, w http.ResponseWriter,
 			builderSize += b.Size
 			builderSize += b.Size
 		}
 		}
 	}
 	}
+	if versions.GreaterThanOrEqualTo(version, "1.42") {
+		for _, b := range buildCache {
+			// Parent field is deprecated in API v1.42 and up, as it is deprecated
+			// in BuildKit. Empty the field to omit it in the API response.
+			b.Parent = "" //nolint:staticcheck // ignore SA1019 (Parent field is deprecated)
+		}
+	}
 
 
 	du := types.DiskUsage{
 	du := types.DiskUsage{
 		BuildCache:  buildCache,
 		BuildCache:  buildCache,

+ 4 - 3
api/swagger.yaml

@@ -2258,8 +2258,11 @@ definitions:
       Parent:
       Parent:
         description: |
         description: |
           ID of the parent build cache record.
           ID of the parent build cache record.
+
+          > **Deprecated**: This field is deprecated, and omitted if empty.
         type: "string"
         type: "string"
-        example: "hw53o5aio51xtltp5xjp8v7fx"
+        x-nullable: true
+        example: ""
       Type:
       Type:
         type: "string"
         type: "string"
         description: |
         description: |
@@ -9065,7 +9068,6 @@ paths:
               BuildCache:
               BuildCache:
                 -
                 -
                   ID: "hw53o5aio51xtltp5xjp8v7fx"
                   ID: "hw53o5aio51xtltp5xjp8v7fx"
-                  Parent: ""
                   Type: "regular"
                   Type: "regular"
                   Description: "pulled from docker.io/library/debian@sha256:234cb88d3020898631af0ccbbcca9a66ae7306ecd30c9720690858c1b007d2a0"
                   Description: "pulled from docker.io/library/debian@sha256:234cb88d3020898631af0ccbbcca9a66ae7306ecd30c9720690858c1b007d2a0"
                   InUse: false
                   InUse: false
@@ -9076,7 +9078,6 @@ paths:
                   UsageCount: 26
                   UsageCount: 26
                 -
                 -
                   ID: "ndlpt0hhvkqcdfkputsk4cq9c"
                   ID: "ndlpt0hhvkqcdfkputsk4cq9c"
-                  Parent: "hw53o5aio51xtltp5xjp8v7fx"
                   Type: "regular"
                   Type: "regular"
                   Description: "mount / from exec /bin/sh -c echo 'Binary::apt::APT::Keep-Downloaded-Packages \"true\";' > /etc/apt/apt.conf.d/keep-cache"
                   Description: "mount / from exec /bin/sh -c echo 'Binary::apt::APT::Keep-Downloaded-Packages \"true\";' > /etc/apt/apt.conf.d/keep-cache"
                   InUse: false
                   InUse: false

+ 3 - 1
api/types/types.go

@@ -777,7 +777,9 @@ type BuildCache struct {
 	// ID is the unique ID of the build cache record.
 	// ID is the unique ID of the build cache record.
 	ID string
 	ID string
 	// Parent is the ID of the parent build cache record.
 	// Parent is the ID of the parent build cache record.
-	Parent string
+	//
+	// Deprecated: deprecated in API v1.42 and up, as it was deprecated in BuildKit.
+	Parent string `json:"Parent,omitempty"`
 	// Type is the cache record type.
 	// Type is the cache record type.
 	Type string
 	Type string
 	// Description is a description of the build-step that produced the build cache.
 	// Description is a description of the build-step that produced the build cache.

+ 1 - 1
builder/builder-next/builder.go

@@ -129,7 +129,7 @@ func (b *Builder) DiskUsage(ctx context.Context) ([]*types.BuildCache, error) {
 	for _, r := range duResp.Record {
 	for _, r := range duResp.Record {
 		items = append(items, &types.BuildCache{
 		items = append(items, &types.BuildCache{
 			ID:          r.ID,
 			ID:          r.ID,
-			Parent:      r.Parent,
+			Parent:      r.Parent, //nolint:staticcheck // ignore SA1019 (Parent field is deprecated)
 			Type:        r.RecordType,
 			Type:        r.RecordType,
 			Description: r.Description,
 			Description: r.Description,
 			InUse:       r.InUse,
 			InUse:       r.InUse,

+ 2 - 0
docs/api/version-history.md

@@ -87,6 +87,8 @@ keywords: "API, Docker, rcli, REST, documentation"
   volume (CNI). This option can only be used if the daemon is a Swarm manager.
   volume (CNI). This option can only be used if the daemon is a Swarm manager.
   The Volume response on creation now also can contain a `ClusterVolume` field
   The Volume response on creation now also can contain a `ClusterVolume` field
   with information about the created volume.
   with information about the created volume.
+* The `BuildCache.Parent` field, as returned by `GET /system/df` is deprecated
+  and is now omitted. API versions before v1.42 continue to include this field.
 * Volume information returned by `GET /volumes/{name}`, `GET /volumes` and
 * Volume information returned by `GET /volumes/{name}`, `GET /volumes` and
   `GET /system/df` can now contain a `ClusterVolume` if the volume is a cluster
   `GET /system/df` can now contain a `ClusterVolume` if the volume is a cluster
   volume (requires the daemon to be a Swarm manager).
   volume (requires the daemon to be a Swarm manager).