mirror of https://github.com/docker/docs.git
Correct the message of ErrorCodeNoSuchContainer to "No such container"
Fixes issue #18424 Signed-off-by: Wen Cheng Ma <wenchma@cn.ibm.com>
This commit is contained in:
parent
7c1c96551d
commit
c424c8c32c
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,
|
||||||
})
|
})
|
||||||
|
|
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
Loading…
Reference in New Issue