Refine error message when save non-exist image

Fixes: #20709
As discussed in the issue, we need refine the message to
help user more understood, what happened for non-exist image.

Signed-off-by: Kai Qiang Wu(Kennan) <wkqwu@cn.ibm.com>
This commit is contained in:
Kai Qiang Wu(Kennan) 2016-03-04 10:05:34 +00:00
parent 5ded3a212b
commit ed231d4095
2 changed files with 13 additions and 0 deletions

View File

@ -170,6 +170,9 @@ func (is *store) Search(term string) (ID, error) {
dgst, err := is.digestSet.Lookup(term)
if err != nil {
if err == digest.ErrDigestNotFound {
err = fmt.Errorf("No such image: %s", term)
}
return "", err
}
return ID(dgst), nil

View File

@ -167,6 +167,16 @@ func (s *DockerSuite) TestSaveAndLoadRepoFlags(c *check.C) {
c.Assert(before, checker.Equals, after, check.Commentf("inspect is not the same after a save / load"))
}
func (s *DockerSuite) TestSaveWithNoExistImage(c *check.C) {
testRequires(c, DaemonIsLinux)
imgName := "foobar-non-existing-image"
out, _, err := dockerCmdWithError("save", "-o", "test-img.tar", imgName)
c.Assert(err, checker.NotNil, check.Commentf("save image should fail for non-existing image"))
c.Assert(out, checker.Contains, fmt.Sprintf("No such image: %s", imgName))
}
func (s *DockerSuite) TestSaveMultipleNames(c *check.C) {
testRequires(c, DaemonIsLinux)
repoName := "foobar-save-multi-name-test"