Browse code

Do not return "<unknown>" in /info response

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2018/07/16 23:07:47
Showing 3 changed files
... ...
@@ -60,6 +60,14 @@ func (s *systemRouter) getInfo(ctx context.Context, w http.ResponseWriter, r *ht
60 60
 		old.SecurityOptions = nameOnlySecurityOptions
61 61
 		return httputils.WriteJSON(w, http.StatusOK, old)
62 62
 	}
63
+	if versions.LessThan(httputils.VersionFromContext(ctx), "1.39") {
64
+		if info.KernelVersion == "" {
65
+			info.KernelVersion = "<unknown>"
66
+		}
67
+		if info.OperatingSystem == "" {
68
+			info.OperatingSystem = "<unknown>"
69
+		}
70
+	}
63 71
 	return httputils.WriteJSON(w, http.StatusOK, info)
64 72
 }
65 73
 
... ...
@@ -179,7 +179,7 @@ func hostName() string {
179 179
 }
180 180
 
181 181
 func kernelVersion() string {
182
-	kernelVersion := "<unknown>"
182
+	var kernelVersion string
183 183
 	if kv, err := kernel.GetKernelVersion(); err != nil {
184 184
 		logrus.Warnf("Could not get kernel version: %v", err)
185 185
 	} else {
... ...
@@ -198,7 +198,7 @@ func memInfo() *system.MemInfo {
198 198
 }
199 199
 
200 200
 func operatingSystem() string {
201
-	operatingSystem := "<unknown>"
201
+	var operatingSystem string
202 202
 	if s, err := operatingsystem.GetOperatingSystem(); err != nil {
203 203
 		logrus.Warnf("Could not get operating system name: %v", err)
204 204
 	} else {
... ...
@@ -13,6 +13,13 @@ keywords: "API, Docker, rcli, REST, documentation"
13 13
      will be rejected.
14 14
 -->
15 15
 
16
+## V1.39 API changes
17
+
18
+[Docker Engine API v1.39](https://docs.docker.com/engine/api/v1.39/) documentation
19
+
20
+* `GET /info` now returns an empty string, instead of `<unknown>` for `KernelVersion`
21
+  and `OperatingSystem` if the daemon was unable to obtain this information.
22
+
16 23
 ## V1.38 API changes
17 24
 
18 25
 [Docker Engine API v1.38](https://docs.docker.com/engine/api/v1.38/) documentation