Browse code

Add API version to `docker version`

Docker-DCO-1.1-Signed-off-by: Guillaume J. Charmes <guillaume@charmes.net> (github: creack)

Guillaume J. Charmes authored on 2014/04/02 09:30:02
Showing 3 changed files
... ...
@@ -357,6 +357,7 @@ func (cli *DockerCli) CmdVersion(args ...string) error {
357 357
 	if dockerversion.VERSION != "" {
358 358
 		fmt.Fprintf(cli.out, "Client version: %s\n", dockerversion.VERSION)
359 359
 	}
360
+	fmt.Fprintf(cli.out, "Client API version: %s\n", api.APIVERSION)
360 361
 	fmt.Fprintf(cli.out, "Go version (client): %s\n", goruntime.Version())
361 362
 	if dockerversion.GITCOMMIT != "" {
362 363
 		fmt.Fprintf(cli.out, "Git commit (client): %s\n", dockerversion.GITCOMMIT)
... ...
@@ -379,6 +380,9 @@ func (cli *DockerCli) CmdVersion(args ...string) error {
379 379
 	}
380 380
 	out.Close()
381 381
 	fmt.Fprintf(cli.out, "Server version: %s\n", remoteVersion.Get("Version"))
382
+	if apiVersion := remoteVersion.Get("ApiVersion"); apiVersion != "" {
383
+		fmt.Fprintf(cli.out, "Server API version: %s\n", apiVersion)
384
+	}
382 385
 	fmt.Fprintf(cli.out, "Git commit (server): %s\n", remoteVersion.Get("GitCommit"))
383 386
 	fmt.Fprintf(cli.out, "Go version (server): %s\n", remoteVersion.Get("GoVersion"))
384 387
 	release := utils.GetReleaseVersion()
... ...
@@ -17,7 +17,17 @@ func TestVersionEnsureSucceeds(t *testing.T) {
17 17
 		t.Fatal("failed to execute docker version")
18 18
 	}
19 19
 
20
-	stringsToCheck := []string{"Client version:", "Go version (client):", "Git commit (client):", "Server version:", "Git commit (server):", "Go version (server):", "Last stable version:"}
20
+	stringsToCheck := []string{
21
+		"Client version:",
22
+		"Client API version:",
23
+		"Go version (client):",
24
+		"Git commit (client):",
25
+		"Server version:",
26
+		"Server API version:",
27
+		"Git commit (server):",
28
+		"Go version (server):",
29
+		"Last stable version:",
30
+	}
21 31
 
22 32
 	for _, linePrefix := range stringsToCheck {
23 33
 		if !strings.Contains(out, linePrefix) {
... ...
@@ -3,6 +3,7 @@ package server
3 3
 import (
4 4
 	"encoding/json"
5 5
 	"fmt"
6
+	"github.com/dotcloud/docker/api"
6 7
 	"github.com/dotcloud/docker/archive"
7 8
 	"github.com/dotcloud/docker/daemonconfig"
8 9
 	"github.com/dotcloud/docker/dockerversion"
... ...
@@ -823,6 +824,7 @@ func (srv *Server) DockerInfo(job *engine.Job) engine.Status {
823 823
 func (srv *Server) DockerVersion(job *engine.Job) engine.Status {
824 824
 	v := &engine.Env{}
825 825
 	v.Set("Version", dockerversion.VERSION)
826
+	v.Set("ApiVersion", api.APIVERSION)
826 827
 	v.Set("GitCommit", dockerversion.GITCOMMIT)
827 828
 	v.Set("GoVersion", goruntime.Version())
828 829
 	v.Set("Os", goruntime.GOOS)