mirror of
https://github.com/containers/skopeo.git
synced 2025-07-01 09:02:25 +00:00
oci: fix config conversion from docker v2s2
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
parent
f1849c6a47
commit
02ea29a99d
32
vendor/github.com/containers/image/image/docker_schema2.go
generated
vendored
32
vendor/github.com/containers/image/image/docker_schema2.go
generated
vendored
@ -177,12 +177,27 @@ func (m *manifestSchema2) UpdatedImage(options types.ManifestUpdateOptions) (typ
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *manifestSchema2) convertToManifestOCI1() (types.Image, error) {
|
func (m *manifestSchema2) convertToManifestOCI1() (types.Image, error) {
|
||||||
// Create a copy of the descriptor.
|
configBlob, err := m.ConfigBlob()
|
||||||
config := m.ConfigDescriptor
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
// docker v2s2 and OCI v1 are mostly compatible but v2s2 contains more fields
|
||||||
|
// than OCI v1. This unmarshal, then re-marshal makes sure we drop docker v2s2
|
||||||
|
// fields that aren't needed in OCI v1.
|
||||||
|
configOCI := &imgspecv1.Image{}
|
||||||
|
if err := json.Unmarshal(configBlob, configOCI); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
configOCIBytes, err := json.Marshal(configOCI)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
// The only difference between OCI and DockerSchema2 is the mediatypes. The
|
config := descriptor{
|
||||||
// media type of the manifest is handled by manifestSchema2FromComponents.
|
MediaType: imgspecv1.MediaTypeImageConfig,
|
||||||
config.MediaType = imgspecv1.MediaTypeImageConfig
|
Size: int64(len(configOCIBytes)),
|
||||||
|
Digest: digest.FromBytes(configOCIBytes),
|
||||||
|
}
|
||||||
|
|
||||||
layers := make([]descriptor, len(m.LayersDescriptors))
|
layers := make([]descriptor, len(m.LayersDescriptors))
|
||||||
for idx := range layers {
|
for idx := range layers {
|
||||||
@ -190,14 +205,13 @@ func (m *manifestSchema2) convertToManifestOCI1() (types.Image, error) {
|
|||||||
if m.LayersDescriptors[idx].MediaType == manifest.DockerV2Schema2ForeignLayerMediaType {
|
if m.LayersDescriptors[idx].MediaType == manifest.DockerV2Schema2ForeignLayerMediaType {
|
||||||
layers[idx].MediaType = imgspecv1.MediaTypeImageLayerNonDistributable
|
layers[idx].MediaType = imgspecv1.MediaTypeImageLayerNonDistributable
|
||||||
} else {
|
} else {
|
||||||
|
// we assume layers are gzip'ed because docker v2s2 only deals with
|
||||||
|
// gzip'ed layers. However, OCI has non-gzip'ed layers as well.
|
||||||
layers[idx].MediaType = imgspecv1.MediaTypeImageLayerGzip
|
layers[idx].MediaType = imgspecv1.MediaTypeImageLayerGzip
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rather than copying the ConfigBlob now, we just pass m.src to the
|
m1 := manifestOCI1FromComponents(config, m.src, configOCIBytes, layers)
|
||||||
// translated manifest, since the only difference is the mediatype of
|
|
||||||
// descriptors there is no change to any blob stored in m.src.
|
|
||||||
m1 := manifestOCI1FromComponents(config, m.src, nil, layers)
|
|
||||||
return memoryImageFromManifest(m1), nil
|
return memoryImageFromManifest(m1), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user