mirror of
https://github.com/docker/cli.git
synced 2026-01-23 15:21:32 +03:00
refacto
Upstream-commit: 94f0d478de6e50e8b26e9779da22dbd74cc5952f Component: engine
This commit is contained in:
@@ -739,19 +739,15 @@ func (srv *Server) ImageDelete(name string) error {
|
||||
}
|
||||
}
|
||||
// check is the image to delete isn't parent of another image
|
||||
images, _ := srv.runtime.graph.All()
|
||||
for _, image := range images {
|
||||
if imgParent, err := image.GetParent(); err == nil && imgParent != nil {
|
||||
if imgParent.Id == img.Id {
|
||||
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
|
||||
}
|
||||
byParent, _ := srv.runtime.graph.ByParent()
|
||||
if childs, exists := byParent[img.Id]; exists {
|
||||
if strings.Contains(img.Id, name) {
|
||||
return fmt.Errorf("Conflict with %s, %s was not removed", childs[0].ShortId(), name)
|
||||
}
|
||||
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 {
|
||||
return fmt.Errorf("Error deleting image %s: %s", name, err.Error())
|
||||
|
||||
Reference in New Issue
Block a user