Selaa lähdekoodia

Correct the message of ErrorCodeNoSuchContainer to "No such container"

Fixes issue #18424

Signed-off-by: Wen Cheng Ma <wenchma@cn.ibm.com>
Wen Cheng Ma 9 vuotta sitten
vanhempi
commit
c424c8c32c

+ 1 - 1
api/server/router/container/container_routes.go

@@ -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
 	}

+ 1 - 1
api/server/router/container/copy.go

@@ -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
 		}

+ 1 - 1
errors/daemon.go

@@ -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,
 	})

+ 2 - 2
integration-cli/docker_api_attach_test.go

@@ -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)
 }
 

+ 1 - 1
integration-cli/docker_api_containers_test.go

@@ -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) {

+ 1 - 1
integration-cli/docker_cli_logs_test.go

@@ -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)
 }

+ 2 - 2
integration-cli/docker_cli_stats_test.go

@@ -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) {