diff --git a/api.go b/api.go index 39d242099d..fa6057945f 100644 --- a/api.go +++ b/api.go @@ -21,7 +21,7 @@ import ( "strings" ) -const APIVERSION = 1.4 +const APIVERSION = 1.5 const DEFAULTHTTPHOST = "127.0.0.1" const DEFAULTHTTPPORT = 4243 const DEFAULTUNIXSOCKET = "/var/run/docker.sock" @@ -327,8 +327,18 @@ func getContainersJSON(srv *Server, version float64, w http.ResponseWriter, r *h n = -1 } + var b []byte outs := srv.Containers(all, size, n, since, before) - b, err := json.Marshal(outs) + if version < 1.5 { + outs2 := []APIContainersOld{} + for _, ctnr := range outs { + outs2 = append(outs2, ctnr.ToLegacy()) + } + b, err = json.Marshal(outs2) + } else { + b, err = json.Marshal(outs) + } + if err != nil { return err } diff --git a/api_params.go b/api_params.go index 43a536d601..6403bc6a26 100644 --- a/api_params.go +++ b/api_params.go @@ -54,6 +54,30 @@ type APIContainers struct { SizeRootFs int64 } +func (self *APIContainers) ToLegacy() APIContainersOld { + return APIContainersOld{ + ID: self.ID, + Image: self.Image, + Command: self.Command, + Created: self.Created, + Status: self.Status, + Ports: displayablePorts(self.Ports), + SizeRw: self.SizeRw, + SizeRootFs: self.SizeRootFs, + } +} + +type APIContainersOld struct { + ID string `json:"Id"` + Image string + Command string + Created int64 + Status string + Ports string + SizeRw int64 + SizeRootFs int64 +} + type APISearch struct { Name string Description string