Merge pull request #18425 from wenchma/18424-ErrorCodeNoSuchContainer

Correct the message of ErrorCodeNoSuchContainer to "No such container"
This commit is contained in:
Doug Davis 2015-12-07 07:48:04 -05:00
commit 0bb4f82d2d
7 changed files with 9 additions and 9 deletions

View file

@ -367,7 +367,7 @@ func (s *containerRouter) deleteContainers(ctx context.Context, w http.ResponseW
if err := s.backend.ContainerRm(name, config); err != nil {
// Force a 404 for the empty string
if strings.Contains(strings.ToLower(err.Error()), "prefix can't be empty") {
return fmt.Errorf("no such id: \"\"")
return fmt.Errorf("no such container: \"\"")
}
return err
}

View file

@ -31,7 +31,7 @@ func (s *containerRouter) postContainersCopy(ctx context.Context, w http.Respons
data, err := s.backend.ContainerCopy(vars["name"], cfg.Resource)
if err != nil {
if strings.Contains(strings.ToLower(err.Error()), "no such id") {
if strings.Contains(strings.ToLower(err.Error()), "no such container") {
w.WriteHeader(http.StatusNotFound)
return nil
}

View file

@ -14,7 +14,7 @@ var (
// name or ID and we can't find it.
ErrorCodeNoSuchContainer = errcode.Register(errGroup, errcode.ErrorDescriptor{
Value: "NOSUCHCONTAINER",
Message: "no such id: %s",
Message: "No such container: %s",
Description: "The specified container can not be found",
HTTPStatusCode: http.StatusNotFound,
})

View file

@ -70,7 +70,7 @@ func (s *DockerSuite) TestPostContainersAttachContainerNotFound(c *check.C) {
status, body, err := sockRequest("POST", "/containers/doesnotexist/attach", nil)
c.Assert(status, checker.Equals, http.StatusNotFound)
c.Assert(err, checker.IsNil)
expected := "no such id: doesnotexist\n"
expected := "No such container: doesnotexist\n"
c.Assert(string(body), checker.Contains, expected)
}
@ -78,7 +78,7 @@ func (s *DockerSuite) TestGetContainersWsAttachContainerNotFound(c *check.C) {
status, body, err := sockRequest("GET", "/containers/doesnotexist/attach/ws", nil)
c.Assert(status, checker.Equals, http.StatusNotFound)
c.Assert(err, checker.IsNil)
expected := "no such id: doesnotexist\n"
expected := "No such container: doesnotexist\n"
c.Assert(string(body), checker.Contains, expected)
}

View file

@ -1051,7 +1051,7 @@ func (s *DockerSuite) TestContainerApiDeleteNotExist(c *check.C) {
status, body, err := sockRequest("DELETE", "/containers/doesnotexist", nil)
c.Assert(err, checker.IsNil)
c.Assert(status, checker.Equals, http.StatusNotFound)
c.Assert(string(body), checker.Matches, "no such id: doesnotexist\n")
c.Assert(string(body), checker.Matches, "No such container: doesnotexist\n")
}
func (s *DockerSuite) TestContainerApiDeleteForce(c *check.C) {

View file

@ -348,6 +348,6 @@ func (s *DockerSuite) TestLogsFollowGoroutinesNoOutput(c *check.C) {
func (s *DockerSuite) TestLogsCLIContainerNotFound(c *check.C) {
name := "testlogsnocontainer"
out, _, _ := dockerCmdWithError("logs", name)
message := fmt.Sprintf(".*no such id: %s.*\n", name)
message := fmt.Sprintf(".*No such container: %s.*\n", name)
c.Assert(out, checker.Matches, message)
}

View file

@ -44,11 +44,11 @@ func (s *DockerSuite) TestStatsContainerNotFound(c *check.C) {
out, _, err := dockerCmdWithError("stats", "notfound")
c.Assert(err, checker.NotNil)
c.Assert(out, checker.Contains, "no such id: notfound", check.Commentf("Expected to fail on not found container stats, got %q instead", out))
c.Assert(out, checker.Contains, "No such container: notfound", check.Commentf("Expected to fail on not found container stats, got %q instead", out))
out, _, err = dockerCmdWithError("stats", "--no-stream", "notfound")
c.Assert(err, checker.NotNil)
c.Assert(out, checker.Contains, "no such id: notfound", check.Commentf("Expected to fail on not found container stats with --no-stream, got %q instead", out))
c.Assert(out, checker.Contains, "No such container: notfound", check.Commentf("Expected to fail on not found container stats with --no-stream, got %q instead", out))
}
func (s *DockerSuite) TestStatsAllRunningNoStream(c *check.C) {