mirror of https://github.com/docker/docs.git
Bumped API version in api.go ; added <1.5 behavior to getContainersJSON
This commit is contained in:
parent
98edd0e751
commit
9ae5054c34
14
api.go
14
api.go
|
@ -21,7 +21,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
const APIVERSION = 1.4
|
const APIVERSION = 1.5
|
||||||
const DEFAULTHTTPHOST = "127.0.0.1"
|
const DEFAULTHTTPHOST = "127.0.0.1"
|
||||||
const DEFAULTHTTPPORT = 4243
|
const DEFAULTHTTPPORT = 4243
|
||||||
const DEFAULTUNIXSOCKET = "/var/run/docker.sock"
|
const DEFAULTUNIXSOCKET = "/var/run/docker.sock"
|
||||||
|
@ -327,8 +327,18 @@ func getContainersJSON(srv *Server, version float64, w http.ResponseWriter, r *h
|
||||||
n = -1
|
n = -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var b []byte
|
||||||
outs := srv.Containers(all, size, n, since, before)
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,30 @@ type APIContainers struct {
|
||||||
SizeRootFs int64
|
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 {
|
type APISearch struct {
|
||||||
Name string
|
Name string
|
||||||
Description string
|
Description string
|
||||||
|
|
Loading…
Reference in New Issue