From 3f4926e49b5f6df00ca09328e990729e00cb1a92 Mon Sep 17 00:00:00 2001 From: Doug Davis Date: Wed, 13 May 2015 17:21:02 -0700 Subject: [PATCH] Fix a regression in `docker import` on error from URL when the daemon can't download the image from a `docker import` the error message was lost due to 'err' being redefined with a block by mistake. This removes the ":" from "... err := " which fixes it. Signed-off-by: Doug Davis --- api/server/server.go | 7 +++++-- integration-cli/docker_cli_import_test.go | 11 +++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/api/server/server.go b/api/server/server.go index dd5c2c89d2..93d9954835 100644 --- a/api/server/server.go +++ b/api/server/server.go @@ -717,14 +717,17 @@ func (s *Server) postImagesCreate(version version.Version, w http.ResponseWriter OutStream: output, } - newConfig, err := builder.BuildFromConfig(s.daemon, &runconfig.Config{}, imageImportConfig.Changes) + // 'err' MUST NOT be defined within this block, we need any error + // generated from the download to be available to the output + // stream processing below + var newConfig *runconfig.Config + newConfig, err = builder.BuildFromConfig(s.daemon, &runconfig.Config{}, imageImportConfig.Changes) if err != nil { return err } imageImportConfig.ContainerConfig = newConfig err = s.daemon.Repositories().Import(src, repo, tag, imageImportConfig) - } if err != nil { if !output.Flushed() { diff --git a/integration-cli/docker_cli_import_test.go b/integration-cli/docker_cli_import_test.go index 201dbaa580..f4bd085214 100644 --- a/integration-cli/docker_cli_import_test.go +++ b/integration-cli/docker_cli_import_test.go @@ -39,3 +39,14 @@ func (s *DockerSuite) TestImportDisplay(c *check.C) { } } + +func (s *DockerSuite) TestImportBadURL(c *check.C) { + runCmd := exec.Command(dockerBinary, "import", "http://nourl/bad") + out, _, err := runCommandWithOutput(runCmd) + if err == nil { + c.Fatal("import was supposed to fail but didn't") + } + if !strings.Contains(out, "dial tcp") { + c.Fatalf("expected an error msg but didn't get one:\n%s", out) + } +}