1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #12260 from HuKeping/rmjob-history

Remove Job from History API
This commit is contained in:
Brian Goff 2015-04-10 09:53:05 -04:00
commit 0693e34d7e
4 changed files with 10 additions and 52 deletions

View file

@ -434,13 +434,13 @@ func getImagesHistory(eng *engine.Engine, version version.Version, w http.Respon
return fmt.Errorf("Missing parameter")
}
var job = eng.Job("history", vars["name"])
streamJSON(job, w, false)
if err := job.Run(); err != nil {
name := vars["name"]
history, err := getDaemon(eng).Repositories().History(name)
if err != nil {
return err
}
return nil
return writeJSON(w, http.StatusOK, history)
}
func getContainersChanges(eng *engine.Engine, version version.Version, w http.ResponseWriter, r *http.Request, vars map[string]string) error {

View file

@ -219,36 +219,6 @@ func TestLogsNoStreams(t *testing.T) {
}
}
func TestGetImagesHistory(t *testing.T) {
eng := engine.New()
imageName := "docker-test-image"
var called bool
eng.Register("history", func(job *engine.Job) error {
called = true
if len(job.Args) == 0 {
t.Fatal("Job arguments is empty")
}
if job.Args[0] != imageName {
t.Fatalf("name != '%s': %#v", imageName, job.Args[0])
}
v := &engine.Env{}
if _, err := v.WriteTo(job.Stdout); err != nil {
return err
}
return nil
})
r := serveRequest("GET", "/images/"+imageName+"/history", nil, eng, t)
if !called {
t.Fatalf("handler was not called")
}
if r.Code != http.StatusOK {
t.Fatalf("Got status %d, expected %d", r.Code, http.StatusOK)
}
if r.HeaderMap.Get("Content-Type") != "application/json" {
t.Fatalf("%#v\n", r)
}
}
func TestGetImagesByName(t *testing.T) {
eng := engine.New()
name := "image_name"

View file

@ -1,24 +1,17 @@
package graph
import (
"encoding/json"
"fmt"
"strings"
"github.com/docker/docker/api/types"
"github.com/docker/docker/engine"
"github.com/docker/docker/image"
"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)
if err != nil {
return err
return nil, err
}
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 {
history = append(history, types.ImageHistory{
history = append(history, &types.ImageHistory{
ID: img.ID,
Created: img.Created.Unix(),
CreatedBy: strings.Join(img.ContainerConfig.Cmd, " "),
@ -46,9 +39,5 @@ func (s *TagStore) CmdHistory(job *engine.Job) error {
return nil
})
if err = json.NewEncoder(job.Stdout).Encode(history); err != nil {
return err
}
return nil
return history, err
}

View file

@ -17,7 +17,6 @@ func (s *TagStore) Install(eng *engine.Engine) error {
"image_inspect": s.CmdLookup,
"image_tarlayer": s.CmdTarLayer,
"image_export": s.CmdImageExport,
"history": s.CmdHistory,
"viz": s.CmdViz,
"load": s.CmdLoad,
"import": s.CmdImport,