Update graph walkhistory to pass by value

Remove unused graph history function

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
Upstream-commit: bb50a4159bda8e6f2d47b69ddd476ab32ac6be14
Component: engine
This commit is contained in:
Derek McGowan
2015-06-05 18:06:09 -07:00
parent 6825ac1c62
commit 6c407af390
2 changed files with 4 additions and 18 deletions
+1 -1
View File
@@ -160,7 +160,7 @@ func (daemon *Daemon) canDeleteImage(imgID string, force bool) error {
return err
}
if err := daemon.graph.WalkHistory(parent, func(p *image.Image) error {
if err := daemon.graph.WalkHistory(parent, func(p image.Image) error {
if imgID == p.ID {
if container.IsRunning() {
if force {
+3 -17
View File
@@ -9,27 +9,13 @@ import (
"github.com/docker/docker/utils"
)
// History returns the list of all images used to create this image.
func (graph *Graph) History(img *image.Image) ([]*image.Image, error) {
var parents []*image.Image
if err := graph.WalkHistory(img,
func(img *image.Image) error {
parents = append(parents, img)
return nil
},
); err != nil {
return nil, err
}
return parents, nil
}
// WalkHistory calls the handler function for each image in the
// provided images lineage starting from immediate parent.
func (graph *Graph) WalkHistory(img *image.Image, handler func(*image.Image) error) (err error) {
func (graph *Graph) WalkHistory(img *image.Image, handler func(image.Image) error) (err error) {
currentImg := img
for currentImg != nil {
if handler != nil {
if err := handler(currentImg); err != nil {
if err := handler(*currentImg); err != nil {
return err
}
}
@@ -100,7 +86,7 @@ func (s *TagStore) History(name string) ([]*types.ImageHistory, error) {
history := []*types.ImageHistory{}
err = s.graph.WalkHistory(foundImage, func(img *image.Image) error {
err = s.graph.WalkHistory(foundImage, func(img image.Image) error {
history = append(history, &types.ImageHistory{
ID: img.ID,
Created: img.Created.Unix(),