mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
* API: Send all tags on History API call
This commit is contained in:
parent
02a002d264
commit
808faa6371
4 changed files with 12 additions and 11 deletions
|
@ -1,8 +1,8 @@
|
||||||
package docker
|
package docker
|
||||||
|
|
||||||
type APIHistory struct {
|
type APIHistory struct {
|
||||||
ID string `json:"Id"`
|
ID string `json:"Id"`
|
||||||
Tag string `json:",omitempty"`
|
Tags []string `json:",omitempty"`
|
||||||
Created int64
|
Created int64
|
||||||
CreatedBy string `json:",omitempty"`
|
CreatedBy string `json:",omitempty"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -627,7 +627,10 @@ func (cli *DockerCli) CmdHistory(args ...string) error {
|
||||||
fmt.Fprintln(w, "ID\tCREATED\tCREATED BY")
|
fmt.Fprintln(w, "ID\tCREATED\tCREATED BY")
|
||||||
|
|
||||||
for _, out := range outs {
|
for _, out := range outs {
|
||||||
fmt.Fprintf(w, "%s (%s)\t%s ago\t%s\n", out.ID, out.Tag, utils.HumanDuration(time.Now().Sub(time.Unix(out.Created, 0))), out.CreatedBy)
|
if out.Tags != nil {
|
||||||
|
out.ID = out.Tags[0]
|
||||||
|
}
|
||||||
|
fmt.Fprintf(w, "%s \t%s ago\t%s\n", out.ID, utils.HumanDuration(time.Now().Sub(time.Unix(out.Created, 0))), out.CreatedBy)
|
||||||
}
|
}
|
||||||
w.Flush()
|
w.Flush()
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -691,7 +691,7 @@ Get the history of an image
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"Id":"b750fe79269d",
|
"Id":"b750fe79269d",
|
||||||
"Tag":"base:latest",
|
"Tag":["base:latest"],
|
||||||
"Created":1364102658,
|
"Created":1364102658,
|
||||||
"CreatedBy":"/bin/bash"
|
"CreatedBy":"/bin/bash"
|
||||||
},
|
},
|
||||||
|
|
12
server.go
12
server.go
|
@ -218,16 +218,14 @@ func (srv *Server) ImageHistory(name string) ([]APIHistory, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
lookupMap := make(map[string]string)
|
lookupMap := make(map[string][]string)
|
||||||
for name, repository := range srv.runtime.repositories.Repositories {
|
for name, repository := range srv.runtime.repositories.Repositories {
|
||||||
for tag, id := range repository {
|
for tag, id := range repository {
|
||||||
// If the ID already has a reverse lookup, do not update it unless for "latest"
|
// If the ID already has a reverse lookup, do not update it unless for "latest"
|
||||||
if _, exists := lookupMap[id]; exists {
|
if _, exists := lookupMap[id]; !exists {
|
||||||
if tag != "latest" {
|
lookupMap[id] = []string{}
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
lookupMap[id] = name + ":" + tag
|
lookupMap[id] = append(lookupMap[id], name+":"+tag)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,7 +235,7 @@ func (srv *Server) ImageHistory(name string) ([]APIHistory, error) {
|
||||||
out.ID = srv.runtime.repositories.ImageName(img.ShortID())
|
out.ID = srv.runtime.repositories.ImageName(img.ShortID())
|
||||||
out.Created = img.Created.Unix()
|
out.Created = img.Created.Unix()
|
||||||
out.CreatedBy = strings.Join(img.ContainerConfig.Cmd, " ")
|
out.CreatedBy = strings.Join(img.ContainerConfig.Cmd, " ")
|
||||||
out.Tag = lookupMap[img.ID]
|
out.Tags = lookupMap[img.ID]
|
||||||
outs = append(outs, out)
|
outs = append(outs, out)
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Reference in a new issue