mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Remove Job from History API
a part of issue #12151 Signed-off-by: Hu Keping <hukeping@huawei.com>
This commit is contained in:
parent
e690ad9292
commit
5c7c3fea6c
4 changed files with 10 additions and 52 deletions
|
@ -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 {
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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, " "),
|
||||
|
@ -45,9 +38,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
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue