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>
Upstream-commit: ed231d409501d1e496fbe2b2e31a279eb2998cf2
Component: engine
This commit is contained in:
Kai Qiang Wu(Kennan)
2016-03-08 01:45:19 +00:00
parent a41eec344b
commit 5ab9ec7f3a
2 changed files with 13 additions and 0 deletions
+3
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
@@ -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"