mirror of https://github.com/docker/buildx.git
Merge pull request #1797 from crazy-max/fix-image-create
This commit is contained in:
commit
167cd16acb
|
@ -122,24 +122,29 @@ func (r *Resolver) Combine(ctx context.Context, srcs []*Source) ([]byte, ocispec
|
|||
}
|
||||
}
|
||||
|
||||
mt := images.MediaTypeDockerSchema2ManifestList //ocispec.MediaTypeImageIndex
|
||||
idx := struct {
|
||||
// MediaType is reserved in the OCI spec but
|
||||
// excluded from go types.
|
||||
MediaType string `json:"mediaType,omitempty"`
|
||||
|
||||
ocispec.Index
|
||||
}{
|
||||
MediaType: mt,
|
||||
Index: ocispec.Index{
|
||||
Versioned: specs.Versioned{
|
||||
SchemaVersion: 2,
|
||||
},
|
||||
Manifests: newDescs,
|
||||
},
|
||||
dockerMfsts := 0
|
||||
for _, desc := range newDescs {
|
||||
if strings.HasPrefix(desc.MediaType, "application/vnd.docker.") {
|
||||
dockerMfsts++
|
||||
}
|
||||
}
|
||||
|
||||
idxBytes, err := json.MarshalIndent(idx, "", " ")
|
||||
var mt string
|
||||
if dockerMfsts == len(newDescs) {
|
||||
// all manifests are Docker types, use Docker manifest list
|
||||
mt = images.MediaTypeDockerSchema2ManifestList
|
||||
} else {
|
||||
// otherwise, use OCI index
|
||||
mt = ocispec.MediaTypeImageIndex
|
||||
}
|
||||
|
||||
idxBytes, err := json.MarshalIndent(ocispec.Index{
|
||||
MediaType: mt,
|
||||
Versioned: specs.Versioned{
|
||||
SchemaVersion: 2,
|
||||
},
|
||||
Manifests: newDescs,
|
||||
}, "", " ")
|
||||
if err != nil {
|
||||
return nil, ocispec.Descriptor{}, errors.Wrap(err, "failed to marshal index")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue