mirror of https://github.com/docker/docs.git
refacto
This commit is contained in:
parent
2eb4e2a0b8
commit
94f0d478de
20
server.go
20
server.go
|
@ -739,19 +739,15 @@ func (srv *Server) ImageDelete(name string) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// check is the image to delete isn't parent of another image
|
// check is the image to delete isn't parent of another image
|
||||||
images, _ := srv.runtime.graph.All()
|
byParent, _ := srv.runtime.graph.ByParent()
|
||||||
for _, image := range images {
|
if childs, exists := byParent[img.Id]; exists {
|
||||||
if imgParent, err := image.GetParent(); err == nil && imgParent != nil {
|
if strings.Contains(img.Id, name) {
|
||||||
if imgParent.Id == img.Id {
|
return fmt.Errorf("Conflict with %s, %s was not removed", childs[0].ShortId(), name)
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if err := srv.runtime.repositories.Delete(name, tag, img.Id); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
if err := srv.runtime.graph.Delete(img.Id); err != nil {
|
if err := srv.runtime.graph.Delete(img.Id); err != nil {
|
||||||
return fmt.Errorf("Error deleting image %s: %s", name, err.Error())
|
return fmt.Errorf("Error deleting image %s: %s", name, err.Error())
|
||||||
|
|
Loading…
Reference in New Issue