summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2018-07-28 03:50:30 +0200
committerAtomic Bot <atomic-devel@projectatomic.io>2018-08-01 18:22:59 +0000
commit754fc8e8ecf98ebd34140ee1414f96665d84b883 (patch)
treeae760e514882b3a70f4b1fd6d7673e1d2d8561c6
parent18c4e2c83574ff1b99f9bf1d2d60d62770378ee3 (diff)
downloadpodman-754fc8e8ecf98ebd34140ee1414f96665d84b883.tar.gz
podman-754fc8e8ecf98ebd34140ee1414f96665d84b883.tar.bz2
podman-754fc8e8ecf98ebd34140ee1414f96665d84b883.zip
Call imageNameForSaveDestination while creating the references
Instead of creating a reference string and then checking it again to see which kind of archive it is, just call imageNameForSaveDestination at the place where we already know what kind of archive it is because we are making that decision. This also notably fixes the use of strings.CONTAINS to see whether the just constructed strings start with one of the transport names; that would match anywhere in the path. Signed-off-by: Miloslav Trmač <mitr@redhat.com> Closes: #1176 Approved by: rhatdan
-rw-r--r--cmd/podman/save.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/cmd/podman/save.go b/cmd/podman/save.go
index 15a7f85c8..bc5f816e8 100644
--- a/cmd/podman/save.go
+++ b/cmd/podman/save.go
@@ -103,6 +103,10 @@ func saveCmd(c *cli.Context) error {
switch c.String("format") {
case libpod.OCIArchive:
dst = libpod.OCIArchive + ":" + output
+ destImageName := imageNameForSaveDestination(newImage, source)
+ if destImageName != "" {
+ dst = fmt.Sprintf("%s:%s", dst, destImageName)
+ }
case "oci-dir":
dst = libpod.DirTransport + ":" + output
manifestType = imgspecv1.MediaTypeImageManifest
@@ -113,6 +117,10 @@ func saveCmd(c *cli.Context) error {
fallthrough
case "":
dst = libpod.DockerArchive + ":" + output
+ destImageName := imageNameForSaveDestination(newImage, source)
+ if destImageName != "" {
+ dst = fmt.Sprintf("%s:%s", dst, destImageName)
+ }
default:
return errors.Errorf("unknown format option %q", c.String("format"))
}
@@ -126,15 +134,7 @@ func saveCmd(c *cli.Context) error {
}
}
- dest := dst
- // need dest to be in the format transport:path:reference for the following transports
- if strings.Contains(dst, libpod.OCIArchive) || strings.Contains(dst, libpod.DockerArchive) {
- destImageName := imageNameForSaveDestination(newImage, source)
- if destImageName != "" {
- dest = fmt.Sprintf("%s:%s", dst, destImageName)
- }
- }
- if err := newImage.PushImage(getContext(), dest, manifestType, "", "", writer, c.Bool("compress"), libpodImage.SigningOptions{}, &libpodImage.DockerRegistryOptions{}, false, additionaltags); err != nil {
+ if err := newImage.PushImage(getContext(), dst, manifestType, "", "", writer, c.Bool("compress"), libpodImage.SigningOptions{}, &libpodImage.DockerRegistryOptions{}, false, additionaltags); err != nil {
if err2 := os.Remove(output); err2 != nil {
logrus.Errorf("error deleting %q: %v", output, err)
}