image/save: Fix layers order in OCI manifest

Order the layers in OCI manifest by their actual apply order. This is
required by the OCI image spec.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
Paweł Gronowski 2024-01-22 13:45:34 +01:00
parent 4979605212
commit 17fd6562bf
No known key found for this signature in database
GPG key ID: B85EFCFE26DEF92A

View file

@ -210,7 +210,9 @@ func (s *saveSession) save(outStream io.Writer) error {
foreign = make([]ocispec.Descriptor, 0, len(foreignSrcs))
)
for _, desc := range foreignSrcs {
// Layers in manifest must follow the actual layer order from config.
for _, l := range imageDescr.layers {
desc := foreignSrcs[l]
foreign = append(foreign, ocispec.Descriptor{
MediaType: desc.MediaType,
Digest: desc.Digest,