aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2018-07-28 03:38:05 +0200
committerAtomic Bot <atomic-devel@projectatomic.io>2018-08-01 18:22:58 +0000
commita4b15548d1c402266eb93ba74bb60f6daf24ee6e (patch)
tree312b2b15bb84ec79c6763fd5802cff37fb101b02
parent3cebdc68b83d9ec3acd01407f617c4e96f3af9a6 (diff)
downloadpodman-a4b15548d1c402266eb93ba74bb60f6daf24ee6e.tar.gz
podman-a4b15548d1c402266eb93ba74bb60f6daf24ee6e.tar.bz2
podman-a4b15548d1c402266eb93ba74bb60f6daf24ee6e.zip
Split a single if statement into two.
This should not change behavior; it will only make it easier to show that future code move does not change it (but does not add unit tets.) Signed-off-by: Miloslav Trmač <mitr@redhat.com> Closes: #1176 Approved by: rhatdan
-rw-r--r--cmd/podman/save.go22
1 files changed, 12 insertions, 10 deletions
diff --git a/cmd/podman/save.go b/cmd/podman/save.go
index 9f193a8f8..577a22358 100644
--- a/cmd/podman/save.go
+++ b/cmd/podman/save.go
@@ -128,19 +128,21 @@ 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)) && !strings.Contains(newImage.ID(), source) {
- prepend := ""
- if !strings.Contains(source, libpodImage.DefaultLocalRepo) {
- // we need to check if localhost was added to the image name in NewFromLocal
- for _, name := range newImage.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, source) {
- prepend = fmt.Sprintf("%s/", libpodImage.DefaultLocalRepo)
- break
+ if strings.Contains(dst, libpod.OCIArchive) || strings.Contains(dst, libpod.DockerArchive) {
+ if !strings.Contains(newImage.ID(), source) {
+ prepend := ""
+ if !strings.Contains(source, libpodImage.DefaultLocalRepo) {
+ // we need to check if localhost was added to the image name in NewFromLocal
+ for _, name := range newImage.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, source) {
+ prepend = fmt.Sprintf("%s/", libpodImage.DefaultLocalRepo)
+ break
+ }
}
}
+ dest = fmt.Sprintf("%s:%s%s", dst, prepend, source)
}
- dest = fmt.Sprintf("%s:%s%s", dst, prepend, source)
}
if err := newImage.PushImage(getContext(), dest, manifestType, "", "", writer, c.Bool("compress"), libpodImage.SigningOptions{}, &libpodImage.DockerRegistryOptions{}, false, additionaltags); err != nil {
if err2 := os.Remove(output); err2 != nil {