add timestamp and change untagged -> untag

This commit is contained in:
Victor Vieux 2013-07-12 15:09:20 +00:00
parent b5da816487
commit b8d52ec266
2 changed files with 7 additions and 2 deletions

View file

@ -19,6 +19,7 @@ import (
"runtime"
"strings"
"sync"
"time"
)
func (srv *Server) DockerVersion() APIVersion {
@ -953,7 +954,7 @@ func (srv *Server) deleteImage(img *Image, repoName, tag string) ([]APIRmi, erro
}
if tagDeleted {
imgs = append(imgs, APIRmi{Untagged: img.ShortID()})
srv.SendEvent("untagged", img.ShortID())
srv.SendEvent("untag", img.ShortID())
}
if len(srv.runtime.repositories.ByID()[img.ID]) == 0 {
if err := srv.deleteImageAndChildren(img.ID, &imgs); err != nil {
@ -1180,7 +1181,7 @@ func NewServer(flGraphPath string, autoRestart, enableCors bool, dns ListOpts) (
func (srv *Server) SendEvent(action, id string) {
for _, c := range srv.events {
c <- utils.JSONMessage{Status: action, ID: id}
c <- utils.JSONMessage{Status: action, ID: id, Time: time.Now().Unix()}
}
}

View file

@ -612,9 +612,13 @@ type JSONMessage struct {
Progress string `json:"progress,omitempty"`
Error string `json:"error,omitempty"`
ID string `json:"id,omitempty"`
Time int64 `json:"time,omitempty"`
}
func (jm *JSONMessage) Display(out io.Writer) (error) {
if jm.Time != 0 {
fmt.Fprintf(out, "[%s] ", time.Unix(jm.Time, 0))
}
if jm.Progress != "" {
fmt.Fprintf(out, "%s %s\r", jm.Status, jm.Progress)
} else if jm.Error != "" {