|
@@ -1,24 +1,17 @@
|
|
package graph
|
|
package graph
|
|
|
|
|
|
import (
|
|
import (
|
|
- "encoding/json"
|
|
|
|
- "fmt"
|
|
|
|
"strings"
|
|
"strings"
|
|
|
|
|
|
"github.com/docker/docker/api/types"
|
|
"github.com/docker/docker/api/types"
|
|
- "github.com/docker/docker/engine"
|
|
|
|
"github.com/docker/docker/image"
|
|
"github.com/docker/docker/image"
|
|
"github.com/docker/docker/utils"
|
|
"github.com/docker/docker/utils"
|
|
)
|
|
)
|
|
|
|
|
|
-func (s *TagStore) CmdHistory(job *engine.Job) error {
|
|
|
|
- if n := len(job.Args); n != 1 {
|
|
|
|
- return fmt.Errorf("Usage: %s IMAGE", job.Name)
|
|
|
|
- }
|
|
|
|
- name := job.Args[0]
|
|
|
|
|
|
+func (s *TagStore) History(name string) ([]*types.ImageHistory, error) {
|
|
foundImage, err := s.LookupImage(name)
|
|
foundImage, err := s.LookupImage(name)
|
|
if err != nil {
|
|
if err != nil {
|
|
- return err
|
|
|
|
|
|
+ return nil, err
|
|
}
|
|
}
|
|
|
|
|
|
lookupMap := make(map[string][]string)
|
|
lookupMap := make(map[string][]string)
|
|
@@ -32,10 +25,10 @@ func (s *TagStore) CmdHistory(job *engine.Job) error {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- history := []types.ImageHistory{}
|
|
|
|
|
|
+ history := []*types.ImageHistory{}
|
|
|
|
|
|
err = foundImage.WalkHistory(func(img *image.Image) error {
|
|
err = foundImage.WalkHistory(func(img *image.Image) error {
|
|
- history = append(history, types.ImageHistory{
|
|
|
|
|
|
+ history = append(history, &types.ImageHistory{
|
|
ID: img.ID,
|
|
ID: img.ID,
|
|
Created: img.Created.Unix(),
|
|
Created: img.Created.Unix(),
|
|
CreatedBy: strings.Join(img.ContainerConfig.Cmd, " "),
|
|
CreatedBy: strings.Join(img.ContainerConfig.Cmd, " "),
|
|
@@ -46,9 +39,5 @@ func (s *TagStore) CmdHistory(job *engine.Job) error {
|
|
return nil
|
|
return nil
|
|
})
|
|
})
|
|
|
|
|
|
- if err = json.NewEncoder(job.Stdout).Encode(history); err != nil {
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return nil
|
|
|
|
|
|
+ return history, err
|
|
}
|
|
}
|