Converter: make sure uncompressed digest annotation is set

Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
master
Kohei Tokunaga 2021-10-05 13:57:19 +09:00
parent 78e88560e1
commit 5c27a53a15
2 changed files with 3 additions and 4 deletions

5
cache/converter.go vendored
View File

@ -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
}
}

View File

@ -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
})
}