summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorhaircommander <pehunt@redhat.com>2018-07-23 12:56:24 -0400
committerAtomic Bot <atomic-devel@projectatomic.io>2018-08-08 21:04:11 +0000
commit879453eaf16675f732dd87fd250ccaaac72f4285 (patch)
tree297b6a1fef1491353a1478ae278386583545fcaa /cmd
parent9bd991f477ab2bb4428df6286452516c3deb970e (diff)
downloadpodman-879453eaf16675f732dd87fd250ccaaac72f4285.tar.gz
podman-879453eaf16675f732dd87fd250ccaaac72f4285.tar.bz2
podman-879453eaf16675f732dd87fd250ccaaac72f4285.zip
Fix ambiguity in adding localhost to podman save
...and some naming decisions. This change ensures podman save doesn't incorrectly prepend localhost when saving an image. Signed-off-by: haircommander <pehunt@redhat.com> Closes: #1140 Approved by: rhatdan
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/save.go12
1 files changed, 7 insertions, 5 deletions
diff --git a/cmd/podman/save.go b/cmd/podman/save.go
index 6a0d12885..f5fd421a4 100644
--- a/cmd/podman/save.go
+++ b/cmd/podman/save.go
@@ -145,7 +145,6 @@ func saveCmd(c *cli.Context) error {
return err
}
}
-
if err := newImage.PushImageToReference(getContext(), destRef, 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)
@@ -165,12 +164,15 @@ func imageNameForSaveDestination(img *libpodImage.Image, imgUserInput string) st
}
prepend := ""
- if !strings.Contains(imgUserInput, libpodImage.DefaultLocalRepo) {
+ localRegistryPrefix := fmt.Sprintf("%s/", libpodImage.DefaultLocalRegistry)
+ if !strings.HasPrefix(imgUserInput, localRegistryPrefix) {
// we need to check if localhost was added to the image name in NewFromLocal
for _, name := range img.Names() {
- // if the user searched for the image whose tag was prepended with localhost, we'll need to prepend localhost to successfully search
- if strings.Contains(name, libpodImage.DefaultLocalRepo) && strings.Contains(name, imgUserInput) {
- prepend = fmt.Sprintf("%s/", libpodImage.DefaultLocalRepo)
+ // If the user is saving an image in the localhost registry, getLocalImage need
+ // a name that matches the format localhost/<tag1>:<tag2> or localhost/<tag>:latest to correctly
+ // set up the manifest and save.
+ if strings.HasPrefix(name, localRegistryPrefix) && (strings.HasSuffix(name, imgUserInput) || strings.HasSuffix(name, fmt.Sprintf("%s:latest", imgUserInput))) {
+ prepend = localRegistryPrefix
break
}
}