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

Merge pull request #12234 from runcom/remove-job-rmi

Remove job from rmi
This commit is contained in:
Alexander Morozov 2015-04-09 11:24:20 -07:00
commit 92a775bd7a
4 changed files with 21 additions and 26 deletions

View file

@ -155,7 +155,7 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
// And canonicalize dockerfile name to a platform-independent one
*dockerfileName, err = archive.CanonicalTarNameForPath(*dockerfileName)
if err != nil {
return fmt.Errorf("Cannot canonicalize dockerfile path %s: %v", dockerfileName, err)
return fmt.Errorf("Cannot canonicalize dockerfile path %s: %v", *dockerfileName, err)
}
if _, err = os.Lstat(filename); os.IsNotExist(err) {

View file

@ -887,12 +887,18 @@ func deleteImages(eng *engine.Engine, version version.Version, w http.ResponseWr
if vars == nil {
return fmt.Errorf("Missing parameter")
}
var job = eng.Job("image_delete", vars["name"])
streamJSON(job, w, false)
job.Setenv("force", r.Form.Get("force"))
job.Setenv("noprune", r.Form.Get("noprune"))
return job.Run()
d := getDaemon(eng)
name := vars["name"]
force := toBool(r.Form.Get("force"))
noprune := toBool(r.Form.Get("noprune"))
list, err := d.ImageDelete(name, force, noprune)
if err != nil {
return err
}
return writeJSON(w, http.StatusOK, list)
}
func postContainersStart(eng *engine.Engine, version version.Version, w http.ResponseWriter, r *http.Request, vars map[string]string) error {

View file

@ -115,7 +115,6 @@ type Daemon struct {
// Install installs daemon capabilities to eng.
func (daemon *Daemon) Install(eng *engine.Engine) error {
// FIXME: remove ImageDelete's dependency on Daemon, then move to graph/
for name, method := range map[string]engine.Handler{
"commit": daemon.ContainerCommit,
"container_copy": daemon.ContainerCopy,
@ -134,7 +133,6 @@ func (daemon *Daemon) Install(eng *engine.Engine) error {
"top": daemon.ContainerTop,
"unpause": daemon.ContainerUnpause,
"wait": daemon.ContainerWait,
"image_delete": daemon.ImageDelete, // FIXME: see above
"execCreate": daemon.ContainerExecCreate,
"execStart": daemon.ContainerExecStart,
"execResize": daemon.ContainerExecResize,

View file

@ -1,12 +1,10 @@
package daemon
import (
"encoding/json"
"fmt"
"strings"
"github.com/docker/docker/api/types"
"github.com/docker/docker/engine"
"github.com/docker/docker/graph"
"github.com/docker/docker/image"
"github.com/docker/docker/pkg/parsers"
@ -14,26 +12,20 @@ import (
"github.com/docker/docker/utils"
)
func (daemon *Daemon) ImageDelete(job *engine.Job) error {
if n := len(job.Args); n != 1 {
return fmt.Errorf("Usage: %s IMAGE", job.Name)
}
// FIXME: remove ImageDelete's dependency on Daemon, then move to graph/
func (daemon *Daemon) ImageDelete(name string, force, noprune bool) ([]types.ImageDelete, error) {
list := []types.ImageDelete{}
if err := daemon.DeleteImage(job.Eng, job.Args[0], &list, true, job.GetenvBool("force"), job.GetenvBool("noprune")); err != nil {
return err
if err := daemon.imgDeleteHelper(name, &list, true, force, noprune); err != nil {
return nil, err
}
if len(list) == 0 {
return fmt.Errorf("Conflict, %s wasn't deleted", job.Args[0])
return nil, fmt.Errorf("Conflict, %s wasn't deleted", name)
}
if err := json.NewEncoder(job.Stdout).Encode(list); err != nil {
return err
}
return nil
return list, nil
}
// FIXME: make this private and use the job instead
func (daemon *Daemon) DeleteImage(eng *engine.Engine, name string, list *[]types.ImageDelete, first, force, noprune bool) error {
func (daemon *Daemon) imgDeleteHelper(name string, list *[]types.ImageDelete, first, force, noprune bool) error {
var (
repoName, tag string
tags = []string{}
@ -124,9 +116,8 @@ func (daemon *Daemon) DeleteImage(eng *engine.Engine, name string, list *[]types
Deleted: img.ID,
})
daemon.EventsService.Log("delete", img.ID, "")
eng.Job("log", "delete", img.ID, "").Run()
if img.Parent != "" && !noprune {
err := daemon.DeleteImage(eng, img.Parent, list, false, force, noprune)
err := daemon.imgDeleteHelper(img.Parent, list, false, force, noprune)
if first {
return err
}