remove buffer
Docker-DCO-1.1-Signed-off-by: Victor Vieux <victor.vieux@docker.com> (github: vieux)
This commit is contained in:
parent
564e6bc780
commit
177f658882
26
api.go
26
api.go
|
@ -668,31 +668,11 @@ func deleteImages(srv *Server, version float64, w http.ResponseWriter, r *http.R
|
||||||
if vars == nil {
|
if vars == nil {
|
||||||
return fmt.Errorf("Missing parameter")
|
return fmt.Errorf("Missing parameter")
|
||||||
}
|
}
|
||||||
var (
|
var job = srv.Eng.Job("image_delete", vars["name"])
|
||||||
buffer = bytes.NewBuffer(nil)
|
job.Stdout.Add(w)
|
||||||
job = srv.Eng.Job("image_delete", vars["name"])
|
|
||||||
)
|
|
||||||
job.Stdout.Add(buffer)
|
|
||||||
job.SetenvBool("autoPrune", version > 1.1)
|
job.SetenvBool("autoPrune", version > 1.1)
|
||||||
if err := job.Run(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
outs := engine.NewTable("", 0)
|
return job.Run()
|
||||||
if _, err := outs.ReadFrom(buffer); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(outs.Data) != 0 {
|
|
||||||
var err error
|
|
||||||
if version < 1.9 {
|
|
||||||
_, err = outs.WriteTo(w)
|
|
||||||
} else {
|
|
||||||
_, err = outs.WriteListTo(w)
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return fmt.Errorf("Conflict, %s wasn't deleted", vars["name"])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func postContainersStart(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
func postContainersStart(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
||||||
|
|
|
@ -823,13 +823,13 @@ func (cli *DockerCli) CmdRmi(args ...string) error {
|
||||||
|
|
||||||
var encounteredError error
|
var encounteredError error
|
||||||
for _, name := range cmd.Args() {
|
for _, name := range cmd.Args() {
|
||||||
body, _, err := readBody(cli.call("DELETE", "/images/"+name, nil, false))
|
stream, _, err := cli.call("DELETE", "/images/"+name, nil, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(cli.err, "%s\n", err)
|
fmt.Fprintf(cli.err, "%s\n", err)
|
||||||
encounteredError = fmt.Errorf("Error: failed to remove one or more images")
|
encounteredError = fmt.Errorf("Error: failed to remove one or more images")
|
||||||
} else {
|
} else {
|
||||||
outs := engine.NewTable("Created", 0)
|
outs := engine.NewTable("Created", 0)
|
||||||
if _, err := outs.ReadFrom(bytes.NewReader(body)); err != nil {
|
if _, err := outs.ReadListFrom(stream); err != nil {
|
||||||
fmt.Fprintf(cli.err, "%s\n", err)
|
fmt.Fprintf(cli.err, "%s\n", err)
|
||||||
encounteredError = fmt.Errorf("Error: failed to remove one or more images")
|
encounteredError = fmt.Errorf("Error: failed to remove one or more images")
|
||||||
continue
|
continue
|
||||||
|
|
11
server.go
11
server.go
|
@ -99,6 +99,7 @@ func jobInitApi(job *engine.Job) engine.Status {
|
||||||
"build": srv.Build,
|
"build": srv.Build,
|
||||||
"pull": srv.ImagePull,
|
"pull": srv.ImagePull,
|
||||||
"import": srv.ImageImport,
|
"import": srv.ImageImport,
|
||||||
|
"image_delete": srv.ImageDelete,
|
||||||
} {
|
} {
|
||||||
if err := job.Eng.Register(name, handler); err != nil {
|
if err := job.Eng.Register(name, handler); err != nil {
|
||||||
job.Error(err)
|
job.Error(err)
|
||||||
|
@ -336,10 +337,6 @@ func (srv *Server) ImageExport(job *engine.Job) engine.Status {
|
||||||
job.Error(err)
|
job.Error(err)
|
||||||
return engine.StatusErr
|
return engine.StatusErr
|
||||||
}
|
}
|
||||||
if err := job.Eng.Register("image_delete", srv.ImageDelete); err != nil {
|
|
||||||
job.Error(err)
|
|
||||||
return engine.StatusErr
|
|
||||||
}
|
|
||||||
return engine.StatusOK
|
return engine.StatusOK
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1971,7 +1968,11 @@ func (srv *Server) ImageDelete(job *engine.Job) engine.Status {
|
||||||
job.Error(err)
|
job.Error(err)
|
||||||
return engine.StatusErr
|
return engine.StatusErr
|
||||||
}
|
}
|
||||||
if _, err := imgs.WriteTo(job.Stdout); err != nil {
|
if len(imgs.Data) == 0 {
|
||||||
|
job.Errorf("Conflict, %s wasn't deleted", job.Args[0])
|
||||||
|
return engine.StatusErr
|
||||||
|
}
|
||||||
|
if _, err := imgs.WriteListTo(job.Stdout); err != nil {
|
||||||
job.Error(err)
|
job.Error(err)
|
||||||
return engine.StatusErr
|
return engine.StatusErr
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue