mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge branch 'master' of ssh://github.com/dotcloud/docker
This commit is contained in:
commit
83db1f36e3
4 changed files with 15 additions and 10 deletions
9
api.go
9
api.go
|
@ -206,7 +206,7 @@ func getContainersChanges(srv *Server, version float64, w http.ResponseWriter, r
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getContainersPs(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
func getContainersJson(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
||||||
if err := parseForm(r); err != nil {
|
if err := parseForm(r); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -541,6 +541,10 @@ func postContainersAttach(srv *Server, version float64, w http.ResponseWriter, r
|
||||||
}
|
}
|
||||||
name := vars["name"]
|
name := vars["name"]
|
||||||
|
|
||||||
|
if _, err := srv.ContainerInspect(name); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
in, out, err := hijackServer(w)
|
in, out, err := hijackServer(w)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -627,7 +631,8 @@ func ListenAndServe(addr string, srv *Server, logging bool) error {
|
||||||
"/images/search": getImagesSearch,
|
"/images/search": getImagesSearch,
|
||||||
"/images/{name:.*}/history": getImagesHistory,
|
"/images/{name:.*}/history": getImagesHistory,
|
||||||
"/images/{name:.*}/json": getImagesByName,
|
"/images/{name:.*}/json": getImagesByName,
|
||||||
"/containers/ps": getContainersPs,
|
"/containers/ps": getContainersJson,
|
||||||
|
"/containers/json": getContainersJson,
|
||||||
"/containers/{name:.*}/export": getContainersExport,
|
"/containers/{name:.*}/export": getContainersExport,
|
||||||
"/containers/{name:.*}/changes": getContainersChanges,
|
"/containers/{name:.*}/changes": getContainersChanges,
|
||||||
"/containers/{name:.*}/json": getContainersByName,
|
"/containers/{name:.*}/json": getContainersByName,
|
||||||
|
|
|
@ -318,7 +318,7 @@ func TestGetImagesByName(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetContainersPs(t *testing.T) {
|
func TestGetContainersJson(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
runtime, err := newTestRuntime()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
@ -336,13 +336,13 @@ func TestGetContainersPs(t *testing.T) {
|
||||||
}
|
}
|
||||||
defer runtime.Destroy(container)
|
defer runtime.Destroy(container)
|
||||||
|
|
||||||
req, err := http.NewRequest("GET", "/containers?quiet=1&all=1", nil)
|
req, err := http.NewRequest("GET", "/containers/json?all=1", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
r := httptest.NewRecorder()
|
r := httptest.NewRecorder()
|
||||||
if err := getContainersPs(srv, API_VERSION, r, req, nil); err != nil {
|
if err := getContainersJson(srv, API_VERSION, r, req, nil); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
containers := []ApiContainers{}
|
containers := []ApiContainers{}
|
||||||
|
|
|
@ -788,7 +788,7 @@ func (cli *DockerCli) CmdPs(args ...string) error {
|
||||||
v.Set("before", *before)
|
v.Set("before", *before)
|
||||||
}
|
}
|
||||||
|
|
||||||
body, _, err := cli.call("GET", "/containers/ps?"+v.Encode(), nil)
|
body, _, err := cli.call("GET", "/containers/json?"+v.Encode(), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -806,9 +806,9 @@ func (cli *DockerCli) CmdPs(args ...string) error {
|
||||||
for _, out := range outs {
|
for _, out := range outs {
|
||||||
if !*quiet {
|
if !*quiet {
|
||||||
if *noTrunc {
|
if *noTrunc {
|
||||||
fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s ago\t%s\n", out.Id, out.Image, out.Command, out.Status, utils.HumanDuration(time.Now().Sub(time.Unix(out.Created, 0))), out.Ports)
|
fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s ago\t%s\n", out.Id, out.Image, out.Command, utils.HumanDuration(time.Now().Sub(time.Unix(out.Created, 0))), out.Status, out.Ports)
|
||||||
} else {
|
} else {
|
||||||
fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s ago\t%s\n", utils.TruncateId(out.Id), out.Image, utils.Trunc(out.Command, 20), out.Status, utils.HumanDuration(time.Now().Sub(time.Unix(out.Created, 0))), out.Ports)
|
fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s ago\t%s\n", utils.TruncateId(out.Id), out.Image, utils.Trunc(out.Command, 20), utils.HumanDuration(time.Now().Sub(time.Unix(out.Created, 0))), out.Status, out.Ports)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if *noTrunc {
|
if *noTrunc {
|
||||||
|
|
|
@ -24,7 +24,7 @@ Docker Remote API
|
||||||
List containers
|
List containers
|
||||||
***************
|
***************
|
||||||
|
|
||||||
.. http:get:: /containers/ps
|
.. http:get:: /containers/json
|
||||||
|
|
||||||
List containers
|
List containers
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ List containers
|
||||||
|
|
||||||
.. sourcecode:: http
|
.. sourcecode:: http
|
||||||
|
|
||||||
GET /containers/ps?all=1&before=8dfafdbc3a40 HTTP/1.1
|
GET /containers/json?all=1&before=8dfafdbc3a40 HTTP/1.1
|
||||||
|
|
||||||
**Example response**:
|
**Example response**:
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue