Browse code

Proper JSON handling of strings that could be represented as other types Addresses #6830

Docker-DCO-1.1-Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com> (github: estesp)

Phil Estes authored on 2014/09/16 08:35:07
Showing 3 changed files
... ...
@@ -61,7 +61,7 @@ func dockerVersion(job *engine.Job) engine.Status {
61 61
 	v := &engine.Env{}
62 62
 	v.SetJson("Version", dockerversion.VERSION)
63 63
 	v.SetJson("ApiVersion", api.APIVERSION)
64
-	v.Set("GitCommit", dockerversion.GITCOMMIT)
64
+	v.SetJson("GitCommit", dockerversion.GITCOMMIT)
65 65
 	v.Set("GoVersion", runtime.Version())
66 66
 	v.Set("Os", runtime.GOOS)
67 67
 	v.Set("Arch", runtime.GOARCH)
... ...
@@ -31,7 +31,7 @@ func (daemon *Daemon) ContainerInspect(job *engine.Job) engine.Status {
31 31
 		out := &engine.Env{}
32 32
 		out.Set("Id", container.ID)
33 33
 		out.SetAuto("Created", container.Created)
34
-		out.Set("Path", container.Path)
34
+		out.SetJson("Path", container.Path)
35 35
 		out.SetList("Args", container.Args)
36 36
 		out.SetJson("Config", container.Config)
37 37
 		out.SetJson("State", container.State)
... ...
@@ -46,6 +46,10 @@ func TestInspectContainerResponse(t *testing.T) {
46 46
 				t.Fatalf("%s does not exist in reponse for %s version", key, testVersion)
47 47
 			}
48 48
 		}
49
+		//Issue #6830: type not properly converted to JSON/back
50
+		if _, ok := inspect_json["Path"].(bool); ok {
51
+			t.Fatalf("Path of `true` should not be converted to boolean `true` via JSON marshalling")
52
+		}
49 53
 	}
50 54
 
51 55
 	deleteAllContainers()