summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-04-28 23:10:20 +0200
committerGitHub <noreply@github.com>2020-04-28 23:10:20 +0200
commitdcac908bbe879a8b0b453531252dddccf8690077 (patch)
treefce9086e389c49d1542126bc696cb2230fc4d494 /libpod
parent30b27819d0fc2e4e61df155758179a387bc9506d (diff)
parent38eb9f4a3dda2b9b678672e99c05572f34c6a84c (diff)
downloadpodman-dcac908bbe879a8b0b453531252dddccf8690077.tar.gz
podman-dcac908bbe879a8b0b453531252dddccf8690077.tar.bz2
podman-dcac908bbe879a8b0b453531252dddccf8690077.zip
Merge pull request #6011 from sujil02/podman-save-issue-5234
Fixes podman save fails when specifying an image using a digest fixes-5234
Diffstat (limited to 'libpod')
-rw-r--r--libpod/image/image.go27
1 files changed, 22 insertions, 5 deletions
diff --git a/libpod/image/image.go b/libpod/image/image.go
index bbf803056..60787b826 100644
--- a/libpod/image/image.go
+++ b/libpod/image/image.go
@@ -1487,14 +1487,14 @@ func (i *Image) Save(ctx context.Context, source, format, output string, moreTag
}
manifestType = manifest.DockerV2Schema2MediaType
case "docker-archive", "":
- dst := output
destImageName := imageNameForSaveDestination(i, source)
- if destImageName != "" {
- dst = fmt.Sprintf("%s:%s", dst, destImageName)
+ ref, err := dockerArchiveDstReference(destImageName)
+ if err != nil {
+ return err
}
- destRef, err = dockerarchive.ParseReference(dst) // FIXME? Add dockerarchive.NewReference
+ destRef, err = dockerarchive.NewReference(output, ref)
if err != nil {
- return errors.Wrapf(err, "error getting Docker archive ImageReference for %q", dst)
+ return errors.Wrapf(err, "error getting Docker archive ImageReference for %s:%v", output, ref)
}
default:
return errors.Errorf("unknown format option %q", format)
@@ -1514,6 +1514,23 @@ func (i *Image) Save(ctx context.Context, source, format, output string, moreTag
return nil
}
+// dockerArchiveDestReference returns a NamedTagged reference for a tagged image and nil for untagged image.
+func dockerArchiveDstReference(normalizedInput string) (reference.NamedTagged, error) {
+ if normalizedInput == "" {
+ return nil, nil
+ }
+ ref, err := reference.ParseNormalizedNamed(normalizedInput)
+ if err != nil {
+ return nil, errors.Wrapf(err, "docker-archive parsing reference %s", normalizedInput)
+ }
+ ref = reference.TagNameOnly(ref)
+ namedTagged, isTagged := ref.(reference.NamedTagged)
+ if !isTagged {
+ namedTagged = nil
+ }
+ return namedTagged, nil
+}
+
// GetConfigBlob returns a schema2image. If the image is not a schema2, then
// it will return an error
func (i *Image) GetConfigBlob(ctx context.Context) (*manifest.Schema2Image, error) {