mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
removed the -f
This commit is contained in:
parent
ea9095c562
commit
2eb4e2a0b8
5 changed files with 16 additions and 22 deletions
6
api.go
6
api.go
|
@ -450,11 +450,7 @@ func deleteImages(srv *Server, version float64, w http.ResponseWriter, r *http.R
|
|||
return fmt.Errorf("Missing parameter")
|
||||
}
|
||||
name := vars["name"]
|
||||
force, err := getBoolParam(r.Form.Get("force"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := srv.ImageDelete(name, force); err != nil {
|
||||
if err := srv.ImageDelete(name); err != nil {
|
||||
return err
|
||||
}
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
|
|
|
@ -1268,7 +1268,7 @@ func TestDeleteImages(t *testing.T) {
|
|||
}
|
||||
|
||||
r := httptest.NewRecorder()
|
||||
if err := deleteImages(srv, r, req, map[string]string{"name": "test:test"}); err != nil {
|
||||
if err := deleteImages(srv, API_VERSION, r, req, map[string]string{"name": "test:test"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if r.Code != http.StatusNoContent {
|
||||
|
|
|
@ -558,7 +558,6 @@ func (cli *DockerCli) CmdPort(args ...string) error {
|
|||
// 'docker rmi IMAGE' removes all images with the name IMAGE
|
||||
func (cli *DockerCli) CmdRmi(args ...string) error {
|
||||
cmd := Subcmd("rmi", "IMAGE [IMAGE...]", "Remove an image")
|
||||
force := cmd.Bool("f", false, "Force")
|
||||
if err := cmd.Parse(args); err != nil {
|
||||
return nil
|
||||
}
|
||||
|
@ -567,13 +566,8 @@ func (cli *DockerCli) CmdRmi(args ...string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
v := url.Values{}
|
||||
if *force {
|
||||
v.Set("force", "1")
|
||||
}
|
||||
|
||||
for _, name := range cmd.Args() {
|
||||
_, _, err := cli.call("DELETE", "/images/"+name+"?"+v.Encode(), nil)
|
||||
_, _, err := cli.call("DELETE", "/images/"+name, nil)
|
||||
if err != nil {
|
||||
fmt.Printf("%s", err)
|
||||
} else {
|
||||
|
|
10
server.go
10
server.go
|
@ -704,7 +704,7 @@ func (srv *Server) ContainerDestroy(name string, removeVolume bool) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (srv *Server) ImageDelete(name string, force bool) error {
|
||||
func (srv *Server) ImageDelete(name string) error {
|
||||
img, err := srv.runtime.repositories.LookupImage(name)
|
||||
if err != nil {
|
||||
return fmt.Errorf("No such image: %s", name)
|
||||
|
@ -739,13 +739,17 @@ func (srv *Server) ImageDelete(name string, force bool) error {
|
|||
}
|
||||
}
|
||||
// check is the image to delete isn't parent of another image
|
||||
if !force {
|
||||
images, _ := srv.runtime.graph.All()
|
||||
for _, image := range images {
|
||||
if imgParent, err := image.GetParent(); err == nil && imgParent != nil {
|
||||
if imgParent.Id == img.Id {
|
||||
return fmt.Errorf("Conflict: Can't delete %s otherwise %s will be broken", name, image.ShortId())
|
||||
if strings.Contains(img.Id, name) {
|
||||
return fmt.Errorf("Conflict with %s, %s was not removed", image.ShortId(), name)
|
||||
}
|
||||
if err := srv.runtime.repositories.Delete(name, tag, img.Id); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ func TestContainerTagImageDelete(t *testing.T) {
|
|||
t.Errorf("Excepted 3 images, %d found", len(images))
|
||||
}
|
||||
|
||||
if err := srv.ImageDelete("utest/docker:tag2", true); err != nil {
|
||||
if err := srv.ImageDelete("utest/docker:tag2"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ func TestContainerTagImageDelete(t *testing.T) {
|
|||
t.Errorf("Excepted 2 images, %d found", len(images))
|
||||
}
|
||||
|
||||
if err := srv.ImageDelete("utest:tag1", true); err != nil {
|
||||
if err := srv.ImageDelete("utest:tag1"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue