mirror of
https://github.com/clearlinux/docker.git
synced 2026-09-05 13:11:30 +00:00
[daemon] Refactor image_delete.go
This file was not well documented and had very high cyclomatic complexity. This patch completely rearranges this file and the ImageDelete method to be easier to follow and more maintainable in the future. Docker-DCO-1.1-Signed-off-by: Josh Hawn <josh.hawn@docker.com> (github: jlhawn)
This commit is contained in:
@@ -404,6 +404,11 @@ func (graph *Graph) ByParent() map[string][]*image.Image {
|
||||
return byParent
|
||||
}
|
||||
|
||||
// HasChildren returns whether the given image has any child images.
|
||||
func (graph *Graph) HasChildren(img *image.Image) bool {
|
||||
return len(graph.ByParent()[img.ID]) > 0
|
||||
}
|
||||
|
||||
// Retain keeps the images and layers that are in the pulling chain so that
|
||||
// they are not deleted. If not retained, they may be deleted by rmi.
|
||||
func (graph *Graph) Retain(sessionID string, layerIDs ...string) {
|
||||
|
||||
@@ -188,6 +188,12 @@ func (store *TagStore) ByID() map[string][]string {
|
||||
return byID
|
||||
}
|
||||
|
||||
// HasReferences returns whether or not the given image is referenced in one or
|
||||
// more repositories.
|
||||
func (store *TagStore) HasReferences(img *image.Image) bool {
|
||||
return len(store.ByID()[img.ID]) > 0
|
||||
}
|
||||
|
||||
// ImageName returns name of an image, given the image's ID.
|
||||
func (store *TagStore) ImageName(id string) string {
|
||||
if names, exists := store.ByID()[id]; exists && len(names) > 0 {
|
||||
|
||||
Reference in New Issue
Block a user