From 5c27a53a150ec8f57d9e8c16b64260697e15472b Mon Sep 17 00:00:00 2001 From: Kohei Tokunaga Date: Tue, 5 Oct 2021 13:57:19 +0900 Subject: [PATCH] Converter: make sure uncompressed digest annotation is set Signed-off-by: Kohei Tokunaga --- cache/converter.go | 5 +---- cache/manager_test.go | 2 ++ 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/cache/converter.go b/cache/converter.go index d2bfd6ae..4bc2dc65 100644 --- a/cache/converter.go +++ b/cache/converter.go @@ -191,16 +191,13 @@ func (c *conversion) convert(ctx context.Context, cs content.Store, desc ocispec newDesc.MediaType = c.target.DefaultMediaType() newDesc.Digest = info.Digest newDesc.Size = info.Size - newDesc.Annotations = nil + newDesc.Annotations = map[string]string{labels.LabelUncompressed: diffID.Digest().String()} if c.finalize != nil { a, err := c.finalize(ctx, cs) if err != nil { return nil, errors.Wrapf(err, "failed finalize compression") } for k, v := range a { - if newDesc.Annotations == nil { - newDesc.Annotations = make(map[string]string) - } newDesc.Annotations[k] = v } } diff --git a/cache/manager_test.go b/cache/manager_test.go index b14ebd89..89c4142f 100644 --- a/cache/manager_test.go +++ b/cache/manager_test.go @@ -1115,6 +1115,8 @@ func TestConversion(t *testing.T) { require.NoError(t, err, testName) } require.Equal(t, recreatedDesc.Digest, orgDesc.Digest, testName) + require.NotNil(t, recreatedDesc.Annotations) + require.Equal(t, recreatedDesc.Annotations["containerd.io/uncompressed"], orgDesc.Digest.String(), testName) return nil }) }