| ... | ... |
@@ -140,7 +140,8 @@ func postAuth(srv *Server, version float64, w http.ResponseWriter, r *http.Reque |
| 140 | 140 |
} |
| 141 | 141 |
|
| 142 | 142 |
func getVersion(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
| 143 |
- return writeJSON(w, http.StatusOK, srv.DockerVersion()) |
|
| 143 |
+ srv.Eng.ServeHTTP(w, r) |
|
| 144 |
+ return nil |
|
| 144 | 145 |
} |
| 145 | 146 |
|
| 146 | 147 |
func postContainersKill(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
| ... | ... |
@@ -11,6 +11,7 @@ import ( |
| 11 | 11 |
"fmt" |
| 12 | 12 |
"github.com/dotcloud/docker/archive" |
| 13 | 13 |
"github.com/dotcloud/docker/auth" |
| 14 |
+ "github.com/dotcloud/docker/engine" |
|
| 14 | 15 |
"github.com/dotcloud/docker/registry" |
| 15 | 16 |
"github.com/dotcloud/docker/term" |
| 16 | 17 |
"github.com/dotcloud/docker/utils" |
| ... | ... |
@@ -391,26 +392,24 @@ func (cli *DockerCli) CmdVersion(args ...string) error {
|
| 391 | 391 |
return err |
| 392 | 392 |
} |
| 393 | 393 |
|
| 394 |
- var out APIVersion |
|
| 395 |
- err = json.Unmarshal(body, &out) |
|
| 394 |
+ out := engine.NewOutput() |
|
| 395 |
+ remoteVersion, err := out.AddEnv() |
|
| 396 | 396 |
if err != nil {
|
| 397 |
- utils.Errorf("Error unmarshal: body: %s, err: %s\n", body, err)
|
|
| 397 |
+ utils.Errorf("Error reading remote version: %s\n", err)
|
|
| 398 | 398 |
return err |
| 399 | 399 |
} |
| 400 |
- if out.Version != "" {
|
|
| 401 |
- fmt.Fprintf(cli.out, "Server version: %s\n", out.Version) |
|
| 402 |
- } |
|
| 403 |
- if out.GitCommit != "" {
|
|
| 404 |
- fmt.Fprintf(cli.out, "Git commit (server): %s\n", out.GitCommit) |
|
| 405 |
- } |
|
| 406 |
- if out.GoVersion != "" {
|
|
| 407 |
- fmt.Fprintf(cli.out, "Go version (server): %s\n", out.GoVersion) |
|
| 400 |
+ if _, err := out.Write(body); err != nil {
|
|
| 401 |
+ utils.Errorf("Error reading remote version: %s\n", err)
|
|
| 402 |
+ return err |
|
| 408 | 403 |
} |
| 409 |
- |
|
| 404 |
+ out.Close() |
|
| 405 |
+ fmt.Fprintf(cli.out, "Server version: %s\n", remoteVersion.Get("Version"))
|
|
| 406 |
+ fmt.Fprintf(cli.out, "Git commit (server): %s\n", remoteVersion.Get("GitCommit"))
|
|
| 407 |
+ fmt.Fprintf(cli.out, "Go version (server): %s\n", remoteVersion.Get("GoVersion"))
|
|
| 410 | 408 |
release := utils.GetReleaseVersion() |
| 411 | 409 |
if release != "" {
|
| 412 | 410 |
fmt.Fprintf(cli.out, "Last stable version: %s", release) |
| 413 |
- if (VERSION != "" || out.Version != "") && (strings.Trim(VERSION, "-dev") != release || strings.Trim(out.Version, "-dev") != release) {
|
|
| 411 |
+ if (VERSION != "" || remoteVersion.Exists("Version")) && (strings.Trim(VERSION, "-dev") != release || strings.Trim(remoteVersion.Get("Version"), "-dev") != release) {
|
|
| 414 | 412 |
fmt.Fprintf(cli.out, ", please update docker") |
| 415 | 413 |
} |
| 416 | 414 |
fmt.Fprintf(cli.out, "\n") |
| ... | ... |
@@ -7,6 +7,7 @@ import ( |
| 7 | 7 |
"encoding/json" |
| 8 | 8 |
"fmt" |
| 9 | 9 |
"github.com/dotcloud/docker" |
| 10 |
+ "github.com/dotcloud/docker/engine" |
|
| 10 | 11 |
"github.com/dotcloud/docker/utils" |
| 11 | 12 |
"io" |
| 12 | 13 |
"net" |
| ... | ... |
@@ -35,12 +36,18 @@ func TestGetVersion(t *testing.T) {
|
| 35 | 35 |
} |
| 36 | 36 |
assertHttpNotError(r, t) |
| 37 | 37 |
|
| 38 |
- v := &docker.APIVersion{}
|
|
| 39 |
- if err = json.Unmarshal(r.Body.Bytes(), v); err != nil {
|
|
| 38 |
+ out := engine.NewOutput() |
|
| 39 |
+ v, err := out.AddEnv() |
|
| 40 |
+ if err != nil {
|
|
| 41 |
+ t.Fatal(err) |
|
| 42 |
+ } |
|
| 43 |
+ if _, err := io.Copy(out, r.Body); err != nil {
|
|
| 40 | 44 |
t.Fatal(err) |
| 41 | 45 |
} |
| 42 |
- if v.Version != docker.VERSION {
|
|
| 43 |
- t.Errorf("Expected version %s, %s found", docker.VERSION, v.Version)
|
|
| 46 |
+ out.Close() |
|
| 47 |
+ expected := docker.VERSION |
|
| 48 |
+ if result := v.Get("Version"); result != expected {
|
|
| 49 |
+ t.Errorf("Expected version %s, %s found", expected, result)
|
|
| 44 | 50 |
} |
| 45 | 51 |
} |
| 46 | 52 |
|
| ... | ... |
@@ -118,14 +118,6 @@ func (srv *Server) ListenAndServe(job *engine.Job) engine.Status {
|
| 118 | 118 |
return engine.StatusOK |
| 119 | 119 |
} |
| 120 | 120 |
|
| 121 |
-func (srv *Server) DockerVersion() APIVersion {
|
|
| 122 |
- return APIVersion{
|
|
| 123 |
- Version: VERSION, |
|
| 124 |
- GitCommit: GITCOMMIT, |
|
| 125 |
- GoVersion: runtime.Version(), |
|
| 126 |
- } |
|
| 127 |
-} |
|
| 128 |
- |
|
| 129 | 121 |
// simpleVersionInfo is a simple implementation of |
| 130 | 122 |
// the interface VersionInfo, which is used |
| 131 | 123 |
// to provide version information for some product, |