diff --git a/api.go b/api.go index 0c06b2e6d1..00673de339 100644 --- a/api.go +++ b/api.go @@ -23,7 +23,7 @@ import ( ) const ( - APIVERSION = 1.6 + APIVERSION = 1.7 DEFAULTHTTPHOST = "127.0.0.1" DEFAULTHTTPPORT = 4243 DEFAULTUNIXSOCKET = "/var/run/docker.sock" @@ -191,7 +191,16 @@ func getImagesJSON(srv *Server, version float64, w http.ResponseWriter, r *http. return err } - return writeJSON(w, http.StatusOK, outs) + if version < 1.7 { + outs2 := []APIImagesOld{} + for _, ctnr := range outs { + outs2 = append(outs2, ctnr.ToLegacy()...) + } + + return writeJSON(w, http.StatusOK, outs2) + } else { + return writeJSON(w, http.StatusOK, outs) + } } func getImagesViz(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error { diff --git a/api_params.go b/api_params.go index d796b96542..e4508542ef 100644 --- a/api_params.go +++ b/api_params.go @@ -1,5 +1,7 @@ package docker +import "strings" + type APIHistory struct { ID string `json:"Id"` Tags []string `json:",omitempty"` @@ -17,6 +19,35 @@ type APIImages struct { ParentId string `json:",omitempty"` } +type APIImagesOld struct { + Repository string `json:",omitempty"` + Tag string `json:",omitempty"` + ID string `json:"Id"` + Created int64 + Size int64 + VirtualSize int64 +} + +func (self *APIImages) ToLegacy() []APIImagesOld { + + outs := []APIImagesOld{} + for _, repotag := range self.RepoTags { + + components := strings.SplitN(repotag, ":", 2) + + outs = append(outs, APIImagesOld{ + ID: self.ID, + Repository: components[0], + Tag: components[1], + Created: self.Created, + Size: self.Size, + VirtualSize: self.VirtualSize, + }) + } + + return outs +} + type APIInfo struct { Debug bool Containers int