1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

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 { if err := s.backend.ContainerRm(name, config); err != nil {
// Force a 404 for the empty string // Force a 404 for the empty string
if strings.Contains(strings.ToLower(err.Error()), "prefix can't be empty") { 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 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) data, err := s.backend.ContainerCopy(vars["name"], cfg.Resource)
if err != nil { 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) w.WriteHeader(http.StatusNotFound)
return nil return nil
} }

View file

@ -14,7 +14,7 @@ var (
// name or ID and we can't find it. // name or ID and we can't find it.
ErrorCodeNoSuchContainer = errcode.Register(errGroup, errcode.ErrorDescriptor{ ErrorCodeNoSuchContainer = errcode.Register(errGroup, errcode.ErrorDescriptor{
Value: "NOSUCHCONTAINER", Value: "NOSUCHCONTAINER",
Message: "no such id: %s", Message: "No such container: %s",
Description: "The specified container can not be found", Description: "The specified container can not be found",
HTTPStatusCode: http.StatusNotFound, 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) status, body, err := sockRequest("POST", "/containers/doesnotexist/attach", nil)
c.Assert(status, checker.Equals, http.StatusNotFound) c.Assert(status, checker.Equals, http.StatusNotFound)
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
expected := "no such id: doesnotexist\n" expected := "No such container: doesnotexist\n"
c.Assert(string(body), checker.Contains, expected) 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) status, body, err := sockRequest("GET", "/containers/doesnotexist/attach/ws", nil)
c.Assert(status, checker.Equals, http.StatusNotFound) c.Assert(status, checker.Equals, http.StatusNotFound)
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
expected := "no such id: doesnotexist\n" expected := "No such container: doesnotexist\n"
c.Assert(string(body), checker.Contains, expected) 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) status, body, err := sockRequest("DELETE", "/containers/doesnotexist", nil)
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
c.Assert(status, checker.Equals, http.StatusNotFound) 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) { 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) { func (s *DockerSuite) TestLogsCLIContainerNotFound(c *check.C) {
name := "testlogsnocontainer" name := "testlogsnocontainer"
out, _, _ := dockerCmdWithError("logs", name) 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) c.Assert(out, checker.Matches, message)
} }

View file

@ -44,11 +44,11 @@ func (s *DockerSuite) TestStatsContainerNotFound(c *check.C) {
out, _, err := dockerCmdWithError("stats", "notfound") out, _, err := dockerCmdWithError("stats", "notfound")
c.Assert(err, checker.NotNil) 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") out, _, err = dockerCmdWithError("stats", "--no-stream", "notfound")
c.Assert(err, checker.NotNil) 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) { func (s *DockerSuite) TestStatsAllRunningNoStream(c *check.C) {