Don't throw away the manifest MIME type and guess again
When loading the manifest using a types.Image.Manifest, we also get a manifest MIME type; don't just throw it away and then guess as if the data was never available, just use it directly (now that the loading is close enough for the throwing away to be noticeable). [Ultimately, this loads the manifest from a c/image/storage backend, which calls manifest.GuessMIMEType anyway, so this does not change behavior right now, but if the c/image/storage backend ever changed to record MIME types, it would make a difference. At the very least, we now run the heuristic once instead of twice.] Signed-off-by: Miloslav Trmač <mitr@redhat.com> Closes: #776 Approved by: rhatdan
This commit is contained in:
parent
6cb7048d90
commit
3e5102046e
|
@ -180,7 +180,7 @@ func makeDockerV2S1Image(manifest docker.V2S1Manifest) (docker.V2Image, error) {
|
|||
|
||||
func (b *Builder) initConfig(ctx context.Context, img types.Image) error {
|
||||
if img != nil { // A pre-existing image, as opposed to a "FROM scratch" new one.
|
||||
rawManifest, _, err := img.Manifest(ctx)
|
||||
rawManifest, manifestMIMEType, err := img.Manifest(ctx)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "error reading image manifest for %q", transports.ImageName(img.Reference()))
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ func (b *Builder) initConfig(ctx context.Context, img types.Image) error {
|
|||
b.Manifest = rawManifest
|
||||
b.Config = rawConfig
|
||||
|
||||
switch mt := manifest.GuessMIMEType(b.Manifest); mt {
|
||||
switch manifestMIMEType {
|
||||
case manifest.DockerV2Schema2MediaType:
|
||||
dimage := docker.V2Image{}
|
||||
if err := json.Unmarshal(b.Config, &dimage); err != nil {
|
||||
|
@ -231,7 +231,7 @@ func (b *Builder) initConfig(ctx context.Context, img types.Image) error {
|
|||
case "":
|
||||
return errors.Errorf("can't work with an unrecognized manifest type")
|
||||
default:
|
||||
return errors.Errorf("unsupported manifest type %#v", mt)
|
||||
return errors.Errorf("unsupported manifest type %#v", manifestMIMEType)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue