Update graph walkhistory to pass by value
Remove unused graph history function Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
This commit is contained in:
parent
2b58b677a5
commit
bb50a4159b
2 changed files with 4 additions and 18 deletions
|
@ -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 {
|
||||
|
|
|
@ -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(),
|
||||
|
|
Loading…
Reference in a new issue