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

Merge pull request #13202 from duglin/ImportFix

Fix a regression in `docker import` on error from URL
This commit is contained in:
Brian Goff 2015-05-14 10:36:50 -04:00
commit ac81cd1fc3
2 changed files with 16 additions and 2 deletions

View file

@ -812,14 +812,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() {

View file

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