Browse code

Update graph walkhistory to pass by value

Remove unused graph history function

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)

Derek McGowan authored on 2015/06/06 07:32:31
Showing 2 changed files
... ...
@@ -160,7 +160,7 @@ func (daemon *Daemon) canDeleteImage(imgID string, force bool) error {
160 160
 			return err
161 161
 		}
162 162
 
163
-		if err := daemon.graph.WalkHistory(parent, func(p *image.Image) error {
163
+		if err := daemon.graph.WalkHistory(parent, func(p image.Image) error {
164 164
 			if imgID == p.ID {
165 165
 				if container.IsRunning() {
166 166
 					if force {
... ...
@@ -9,27 +9,13 @@ import (
9 9
 	"github.com/docker/docker/utils"
10 10
 )
11 11
 
12
-// History returns the list of all images used to create this image.
13
-func (graph *Graph) History(img *image.Image) ([]*image.Image, error) {
14
-	var parents []*image.Image
15
-	if err := graph.WalkHistory(img,
16
-		func(img *image.Image) error {
17
-			parents = append(parents, img)
18
-			return nil
19
-		},
20
-	); err != nil {
21
-		return nil, err
22
-	}
23
-	return parents, nil
24
-}
25
-
26 12
 // WalkHistory calls the handler function for each image in the
27 13
 // provided images lineage starting from immediate parent.
28
-func (graph *Graph) WalkHistory(img *image.Image, handler func(*image.Image) error) (err error) {
14
+func (graph *Graph) WalkHistory(img *image.Image, handler func(image.Image) error) (err error) {
29 15
 	currentImg := img
30 16
 	for currentImg != nil {
31 17
 		if handler != nil {
32
-			if err := handler(currentImg); err != nil {
18
+			if err := handler(*currentImg); err != nil {
33 19
 				return err
34 20
 			}
35 21
 		}
... ...
@@ -100,7 +86,7 @@ func (s *TagStore) History(name string) ([]*types.ImageHistory, error) {
100 100
 
101 101
 	history := []*types.ImageHistory{}
102 102
 
103
-	err = s.graph.WalkHistory(foundImage, func(img *image.Image) error {
103
+	err = s.graph.WalkHistory(foundImage, func(img image.Image) error {
104 104
 		history = append(history, &types.ImageHistory{
105 105
 			ID:        img.ID,
106 106
 			Created:   img.Created.Unix(),