From 4979605212b20edcd617c1ba0fb300736df86686 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Gronowski?= Date: Mon, 22 Jan 2024 13:43:54 +0100 Subject: [PATCH] image/save: Change layers type to DiffID MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Paweł Gronowski --- image/tarexport/save.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/image/tarexport/save.go b/image/tarexport/save.go index bd676d432a..b69b849884 100644 --- a/image/tarexport/save.go +++ b/image/tarexport/save.go @@ -29,7 +29,7 @@ import ( type imageDescriptor struct { refs []reference.NamedTagged - layers []digest.Digest + layers []layer.DiffID image *image.Image layerRef layer.Layer } @@ -263,7 +263,7 @@ func (s *saveSession) save(outStream io.Writer) error { if _, ok := reposLegacy[familiarName]; !ok { reposLegacy[familiarName] = make(map[string]string) } - reposLegacy[familiarName][ref.Tag()] = imageDescr.layers[len(imageDescr.layers)-1].Encoded() + reposLegacy[familiarName][ref.Tag()] = digest.Digest(imageDescr.layers[len(imageDescr.layers)-1]).Encoded() repoTags = append(repoTags, reference.FamiliarString(ref)) manifestDescriptors = append(manifestDescriptors, ocispec.Descriptor{ @@ -281,7 +281,8 @@ func (s *saveSession) save(outStream io.Writer) error { for _, l := range imageDescr.layers { // IMPORTANT: We use path, not filepath here to ensure the layers // in the manifest use Unix-style forward-slashes. - layers = append(layers, path.Join(ocispec.ImageBlobsDir, l.Algorithm().String(), l.Encoded())) + lDgst := digest.Digest(l) + layers = append(layers, path.Join(ocispec.ImageBlobsDir, lDgst.Algorithm().String(), lDgst.Encoded())) } manifest = append(manifest, manifestItem{ @@ -380,7 +381,7 @@ func (s *saveSession) saveImage(id image.ID) (map[layer.DiffID]distribution.Desc } var parent digest.Digest - var layers []digest.Digest + var layers []layer.DiffID var foreignSrcs map[layer.DiffID]distribution.Descriptor for i, diffID := range img.RootFS.DiffIDs { v1ImgCreated := time.Unix(0, 0) @@ -410,7 +411,7 @@ func (s *saveSession) saveImage(id image.ID) (map[layer.DiffID]distribution.Desc return nil, err } - layers = append(layers, digest.Digest(diffID)) + layers = append(layers, diffID) parent = v1ID if src.Digest != "" { if foreignSrcs == nil {