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
This commit is contained in:
Miloslav Trmač
2018-07-28 03:47:21 +02:00
committed by Atomic Bot
parent b142cc6b4e
commit 18c4e2c835

View File

@ -148,7 +148,10 @@ 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) {
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
@ -161,6 +164,4 @@ func imageNameForSaveDestination(img *libpodImage.Image, imgUserInput string) st
}
}
return fmt.Sprintf("%s%s", prepend, imgUserInput)
}
return ""
}