Browse code

Merge pull request #51862 from thaJeztah/identity_version_gate

inspect: add API-version gate for image identity

Paweł Gronowski authored on 2026/01/27 02:08:02
Showing 3 changed files
... ...
@@ -92,9 +92,13 @@ func (i *ImageService) ImageInspect(ctx context.Context, refOrID string, opts im
92 92
 		target = multi.Best.Target()
93 93
 	}
94 94
 
95
-	identity, err := i.imageIdentity(ctx, c8dImg.Target, multi)
96
-	if err != nil {
97
-		log.G(ctx).WithError(err).Warn("failed to determine Identity property")
95
+	var identity *imagetypes.Identity
96
+	if opts.Identity {
97
+		var err error
98
+		identity, err = i.imageIdentity(ctx, c8dImg.Target, multi)
99
+		if err != nil {
100
+			log.G(ctx).WithError(err).Warn("failed to determine Identity property")
101
+		}
98 102
 	}
99 103
 
100 104
 	resp := &imagebackend.InspectData{
... ...
@@ -56,6 +56,7 @@ type GetImageOpts struct {
56 56
 // ImageInspectOpts holds parameters to inspect an image.
57 57
 type ImageInspectOpts struct {
58 58
 	Manifests bool
59
+	Identity  bool
59 60
 	Platform  *ocispec.Platform
60 61
 }
61 62
 
... ...
@@ -381,6 +381,7 @@ func (ir *imageRouter) getImagesByName(ctx context.Context, w http.ResponseWrite
381 381
 
382 382
 	inspectData, err := ir.backend.ImageInspect(ctx, vars["name"], imagebackend.ImageInspectOpts{
383 383
 		Manifests: manifests,
384
+		Identity:  versions.GreaterThanOrEqualTo(httputils.VersionFromContext(ctx), "1.53"),
384 385
 		Platform:  platform,
385 386
 	})
386 387
 	if err != nil {