summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2018-07-28 03:47:21 +0200
committerAtomic Bot <atomic-devel@projectatomic.io>2018-08-01 18:22:59 +0000
commit18c4e2c83574ff1b99f9bf1d2d60d62770378ee3 (patch)
tree5f91f17090a801230f975ff64f7962676864310d /cmd/podman
parentb142cc6b4e42fbfd1873b38a9371a7b3a2d76d44 (diff)
downloadpodman-18c4e2c83574ff1b99f9bf1d2d60d62770378ee3.tar.gz
podman-18c4e2c83574ff1b99f9bf1d2d60d62770378ee3.tar.bz2
podman-18c4e2c83574ff1b99f9bf1d2d60d62770378ee3.zip
Exit early in the simple case in imageNameForSaveDestination
... to make it a tiny bit easier to read. Should not change behavior (but does not add unit tests). Signed-off-by: Miloslav Trmač <mitr@redhat.com> Closes: #1176 Approved by: rhatdan
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/save.go25
1 files changed, 13 insertions, 12 deletions
diff --git a/cmd/podman/save.go b/cmd/podman/save.go
index 6b26ab832..15a7f85c8 100644
--- a/cmd/podman/save.go
+++ b/cmd/podman/save.go
@@ -148,19 +148,20 @@ func saveCmd(c *cli.Context) error {
// which the user referred to as imgUserInput; or an empty string, if there is no appropriate
// reference.
func imageNameForSaveDestination(img *libpodImage.Image, imgUserInput string) string {
- if !strings.Contains(img.ID(), imgUserInput) {
- prepend := ""
- if !strings.Contains(imgUserInput, libpodImage.DefaultLocalRepo) {
- // 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)
- break
- }
+ if strings.Contains(img.ID(), imgUserInput) {
+ return ""
+ }
+
+ prepend := ""
+ if !strings.Contains(imgUserInput, libpodImage.DefaultLocalRepo) {
+ // 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)
+ break
}
}
- return fmt.Sprintf("%s%s", prepend, imgUserInput)
}
- return ""
+ return fmt.Sprintf("%s%s", prepend, imgUserInput)
}