mirror of
https://github.com/containers/podman.git
synced 2025-06-27 21:50:18 +08:00
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:

committed by
Atomic Bot

parent
b142cc6b4e
commit
18c4e2c835
@ -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
|
// which the user referred to as imgUserInput; or an empty string, if there is no appropriate
|
||||||
// reference.
|
// reference.
|
||||||
func imageNameForSaveDestination(img *libpodImage.Image, imgUserInput string) string {
|
func imageNameForSaveDestination(img *libpodImage.Image, imgUserInput string) string {
|
||||||
if !strings.Contains(img.ID(), imgUserInput) {
|
if strings.Contains(img.ID(), imgUserInput) {
|
||||||
prepend := ""
|
return ""
|
||||||
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() {
|
prepend := ""
|
||||||
// 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(imgUserInput, libpodImage.DefaultLocalRepo) {
|
||||||
if strings.Contains(name, libpodImage.DefaultLocalRepo) && strings.Contains(name, imgUserInput) {
|
// we need to check if localhost was added to the image name in NewFromLocal
|
||||||
prepend = fmt.Sprintf("%s/", libpodImage.DefaultLocalRepo)
|
for _, name := range img.Names() {
|
||||||
break
|
// 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)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user