unmarshalConvertedConfig: avoid using the updated image's ref

The image returned by UpdatedImage() doesn't have a reference, so
attempting to include the result's name in an error message causes a
crash.  Assign it to a temporary variable first so that we can use the
name of the un-updated version in an error message.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #1960
Approved by: TomSweeneyRedHat
This commit is contained in:
Nalin Dahyabhai 2019-10-31 15:16:38 -04:00 committed by Atomic Bot
parent 1967973f8c
commit 4e03c80a0b
1 changed files with 3 additions and 2 deletions

View File

@ -26,7 +26,7 @@ func unmarshalConvertedConfig(ctx context.Context, dest interface{}, img types.I
return errors.Wrapf(err, "error getting manifest MIME type for %q", transports.ImageName(img.Reference()))
}
if wantedManifestMIMEType != actualManifestMIMEType {
img, err = img.UpdatedImage(ctx, types.ManifestUpdateOptions{
updatedImg, err := img.UpdatedImage(ctx, types.ManifestUpdateOptions{
ManifestMIMEType: wantedManifestMIMEType,
InformationOnly: types.ManifestUpdateInformation{ // Strictly speaking, every value in here is invalid. But…
Destination: nil, // Destination is technically required, but actually necessary only for conversion _to_ v2s1. Leave it nil, we will crash if that ever changes.
@ -35,8 +35,9 @@ func unmarshalConvertedConfig(ctx context.Context, dest interface{}, img types.I
},
})
if err != nil {
return errors.Wrapf(err, "error converting image %q to %s", transports.ImageName(img.Reference()), wantedManifestMIMEType)
return errors.Wrapf(err, "error converting image %q from %q to %q", transports.ImageName(img.Reference()), actualManifestMIMEType, wantedManifestMIMEType)
}
img = updatedImg
}
config, err := img.ConfigBlob(ctx)
if err != nil {