rmi remove all not error when no images are present

When running podman rm -a on a storage where no images exist,
the exit code should NOT be non-zero.

Signed-off-by: baude <bbaude@redhat.com>

Closes: #1402
Approved by: rhatdan
This commit is contained in:
baude
2018-09-04 12:33:29 -05:00
committed by Atomic Bot
parent 807f6f8d8f
commit 4ddcbd7941
2 changed files with 17 additions and 0 deletions

View File

@ -111,6 +111,13 @@ func rmiCmd(c *cli.Context) error {
}
}
// If the user calls remove all and there are none, it should not be a
// non-zero exit
if !deleted && removeAll {
return nil
}
// the user tries to remove images that do not exist, that should be a
// non-zero exit
if !deleted {
return errors.Errorf("no valid images to delete")
}

View File

@ -238,4 +238,14 @@ var _ = Describe("Podman rmi", func() {
Expect(session.ExitCode()).To(Equal(0))
Expect(len(session.OutputToString())).To(Equal(0))
})
It("podman rmi -a with no images should be exit 0", func() {
session := podmanTest.Podman([]string{"rmi", "-fa"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
session2 := podmanTest.Podman([]string{"rmi", "-fa"})
session2.WaitWithDefaultTimeout()
Expect(session2.ExitCode()).To(Equal(0))
})
})