Skip to content

Commit

Permalink
Refine error message when save non-exist image
Browse files Browse the repository at this point in the history
Fixes: moby#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>
  • Loading branch information
Kai Qiang Wu(Kennan) committed Mar 8, 2016
1 parent 5ded3a2 commit ed231d4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions image/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions integration-cli/docker_cli_save_load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit ed231d4

Please sign in to comment.