api: generalize version information to any platform component
Sebastiaan van Stijn authored on 2017/12/07 09:43:38... | ... |
@@ -53,7 +53,8 @@ DOCKER_ENVS := \ |
53 | 53 |
-e http_proxy \ |
54 | 54 |
-e https_proxy \ |
55 | 55 |
-e no_proxy \ |
56 |
- -e VERSION |
|
56 |
+ -e VERSION \ |
|
57 |
+ -e PLATFORM |
|
57 | 58 |
# note: we _cannot_ add "-e DOCKER_BUILDTAGS" here because even if it's unset in the shell, that would shadow the "ENV DOCKER_BUILDTAGS" set in our Dockerfile, which is very important for our official builds |
58 | 59 |
|
59 | 60 |
# to allow `make BIND_DIR=. shell` or `make BIND_DIR= test` |
... | ... |
@@ -6,7 +6,6 @@ import ( |
6 | 6 |
"net/http" |
7 | 7 |
"time" |
8 | 8 |
|
9 |
- "github.com/docker/docker/api" |
|
10 | 9 |
"github.com/docker/docker/api/server/httputils" |
11 | 10 |
"github.com/docker/docker/api/types" |
12 | 11 |
"github.com/docker/docker/api/types/events" |
... | ... |
@@ -65,7 +64,6 @@ func (s *systemRouter) getInfo(ctx context.Context, w http.ResponseWriter, r *ht |
65 | 65 |
|
66 | 66 |
func (s *systemRouter) getVersion(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error { |
67 | 67 |
info := s.backend.SystemVersion() |
68 |
- info.APIVersion = api.DefaultVersion |
|
69 | 68 |
|
70 | 69 |
return httputils.WriteJSON(w, http.StatusOK, info) |
71 | 70 |
} |
... | ... |
@@ -6761,6 +6761,28 @@ paths: |
6761 | 6761 |
schema: |
6762 | 6762 |
type: "object" |
6763 | 6763 |
properties: |
6764 |
+ Platform: |
|
6765 |
+ type: "object" |
|
6766 |
+ required: [Name] |
|
6767 |
+ properties: |
|
6768 |
+ Name: |
|
6769 |
+ type: "string" |
|
6770 |
+ Components: |
|
6771 |
+ type: "array" |
|
6772 |
+ items: |
|
6773 |
+ type: "object" |
|
6774 |
+ x-go-name: ComponentVersion |
|
6775 |
+ required: [Name, Version] |
|
6776 |
+ properties: |
|
6777 |
+ Name: |
|
6778 |
+ type: "string" |
|
6779 |
+ Version: |
|
6780 |
+ type: "string" |
|
6781 |
+ x-nullable: false |
|
6782 |
+ Details: |
|
6783 |
+ type: "object" |
|
6784 |
+ x-nullable: true |
|
6785 |
+ |
|
6764 | 6786 |
Version: |
6765 | 6787 |
type: "string" |
6766 | 6788 |
ApiVersion: |
... | ... |
@@ -107,9 +107,21 @@ type Ping struct { |
107 | 107 |
Experimental bool |
108 | 108 |
} |
109 | 109 |
|
110 |
+// ComponentVersion describes the version information for a specific component. |
|
111 |
+type ComponentVersion struct { |
|
112 |
+ Name string |
|
113 |
+ Version string |
|
114 |
+ Details map[string]string `json:",omitempty"` |
|
115 |
+} |
|
116 |
+ |
|
110 | 117 |
// Version contains response of Engine API: |
111 | 118 |
// GET "/version" |
112 | 119 |
type Version struct { |
120 |
+ Platform struct{ Name string } `json:",omitempty"` |
|
121 |
+ Components []ComponentVersion `json:",omitempty"` |
|
122 |
+ |
|
123 |
+ // The following fields are deprecated, they relate to the Engine component and are kept for backwards compatibility |
|
124 |
+ |
|
113 | 125 |
Version string |
114 | 126 |
APIVersion string `json:"ApiVersion"` |
115 | 127 |
MinAPIVersion string `json:"MinAPIVersion,omitempty"` |
... | ... |
@@ -154,24 +154,46 @@ func (daemon *Daemon) SystemInfo() (*types.Info, error) { |
154 | 154 |
|
155 | 155 |
// SystemVersion returns version information about the daemon. |
156 | 156 |
func (daemon *Daemon) SystemVersion() types.Version { |
157 |
+ kernelVersion := "<unknown>" |
|
158 |
+ if kv, err := kernel.GetKernelVersion(); err != nil { |
|
159 |
+ logrus.Warnf("Could not get kernel version: %v", err) |
|
160 |
+ } else { |
|
161 |
+ kernelVersion = kv.String() |
|
162 |
+ } |
|
163 |
+ |
|
157 | 164 |
v := types.Version{ |
165 |
+ Components: []types.ComponentVersion{ |
|
166 |
+ { |
|
167 |
+ Name: "Engine", |
|
168 |
+ Version: dockerversion.Version, |
|
169 |
+ Details: map[string]string{ |
|
170 |
+ "GitCommit": dockerversion.GitCommit, |
|
171 |
+ "ApiVersion": api.DefaultVersion, |
|
172 |
+ "MinAPIVersion": api.MinVersion, |
|
173 |
+ "GoVersion": runtime.Version(), |
|
174 |
+ "Os": runtime.GOOS, |
|
175 |
+ "Arch": runtime.GOARCH, |
|
176 |
+ "BuildTime": dockerversion.BuildTime, |
|
177 |
+ "KernelVersion": kernelVersion, |
|
178 |
+ "Experimental": fmt.Sprintf("%t", daemon.configStore.Experimental), |
|
179 |
+ }, |
|
180 |
+ }, |
|
181 |
+ }, |
|
182 |
+ |
|
183 |
+ // Populate deprecated fields for older clients |
|
158 | 184 |
Version: dockerversion.Version, |
159 | 185 |
GitCommit: dockerversion.GitCommit, |
186 |
+ APIVersion: api.DefaultVersion, |
|
160 | 187 |
MinAPIVersion: api.MinVersion, |
161 | 188 |
GoVersion: runtime.Version(), |
162 | 189 |
Os: runtime.GOOS, |
163 | 190 |
Arch: runtime.GOARCH, |
164 | 191 |
BuildTime: dockerversion.BuildTime, |
192 |
+ KernelVersion: kernelVersion, |
|
165 | 193 |
Experimental: daemon.configStore.Experimental, |
166 | 194 |
} |
167 | 195 |
|
168 |
- kernelVersion := "<unknown>" |
|
169 |
- if kv, err := kernel.GetKernelVersion(); err != nil { |
|
170 |
- logrus.Warnf("Could not get kernel version: %v", err) |
|
171 |
- } else { |
|
172 |
- kernelVersion = kv.String() |
|
173 |
- } |
|
174 |
- v.KernelVersion = kernelVersion |
|
196 |
+ v.Platform.Name = dockerversion.PlatformName |
|
175 | 197 |
|
176 | 198 |
return v |
177 | 199 |
} |
... | ... |
@@ -365,7 +365,7 @@ Try { |
365 | 365 |
# Run autogen if building binaries or running unit tests. |
366 | 366 |
if ($Client -or $Daemon -or $TestUnit) { |
367 | 367 |
Write-Host "INFO: Invoking autogen..." |
368 |
- Try { .\hack\make\.go-autogen.ps1 -CommitString $gitCommit -DockerVersion $dockerVersion } |
|
368 |
+ Try { .\hack\make\.go-autogen.ps1 -CommitString $gitCommit -DockerVersion $dockerVersion -Platform "$env:PLATFORM" } |
|
369 | 369 |
Catch [Exception] { Throw $_ } |
370 | 370 |
} |
371 | 371 |
|
... | ... |
@@ -18,6 +18,7 @@ const ( |
18 | 18 |
BuildTime string = "$BUILDTIME" |
19 | 19 |
IAmStatic string = "${IAMSTATIC:-true}" |
20 | 20 |
ContainerdCommitID string = "${CONTAINERD_COMMIT}" |
21 |
+ PlatformName string = "${PLATFORM}" |
|
21 | 22 |
) |
22 | 23 |
|
23 | 24 |
// AUTOGENERATED FILE; see /go/src/github.com/docker/docker/hack/make/.go-autogen |
... | ... |
@@ -14,7 +14,8 @@ |
14 | 14 |
|
15 | 15 |
param( |
16 | 16 |
[Parameter(Mandatory=$true)][string]$CommitString, |
17 |
- [Parameter(Mandatory=$true)][string]$DockerVersion |
|
17 |
+ [Parameter(Mandatory=$true)][string]$DockerVersion, |
|
18 |
+ [Parameter(Mandatory=$false)][string]$Platform |
|
18 | 19 |
) |
19 | 20 |
|
20 | 21 |
$ErrorActionPreference = "Stop" |
... | ... |
@@ -43,6 +44,7 @@ const ( |
43 | 43 |
GitCommit string = "'+$CommitString+'" |
44 | 44 |
Version string = "'+$DockerVersion+'" |
45 | 45 |
BuildTime string = "'+$buildDateTime+'" |
46 |
+ PlatformName string = "'+$Platform+'" |
|
46 | 47 |
) |
47 | 48 |
|
48 | 49 |
// AUTOGENERATED FILE; see hack\make\.go-autogen.ps1 |