Bläddra i källkod

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 10 år sedan
förälder
incheckning
1b0b1ec657
3 ändrade filer med 6 tillägg och 2 borttagningar
  1. 1 1
      builtins/builtins.go
  2. 1 1
      daemon/inspect.go
  3. 4 0
      integration-cli/docker_api_inspect_test.go

+ 1 - 1
builtins/builtins.go

@@ -61,7 +61,7 @@ func dockerVersion(job *engine.Job) engine.Status {
 	v := &engine.Env{}
 	v := &engine.Env{}
 	v.SetJson("Version", dockerversion.VERSION)
 	v.SetJson("Version", dockerversion.VERSION)
 	v.SetJson("ApiVersion", api.APIVERSION)
 	v.SetJson("ApiVersion", api.APIVERSION)
-	v.Set("GitCommit", dockerversion.GITCOMMIT)
+	v.SetJson("GitCommit", dockerversion.GITCOMMIT)
 	v.Set("GoVersion", runtime.Version())
 	v.Set("GoVersion", runtime.Version())
 	v.Set("Os", runtime.GOOS)
 	v.Set("Os", runtime.GOOS)
 	v.Set("Arch", runtime.GOARCH)
 	v.Set("Arch", runtime.GOARCH)

+ 1 - 1
daemon/inspect.go

@@ -31,7 +31,7 @@ func (daemon *Daemon) ContainerInspect(job *engine.Job) engine.Status {
 		out := &engine.Env{}
 		out := &engine.Env{}
 		out.Set("Id", container.ID)
 		out.Set("Id", container.ID)
 		out.SetAuto("Created", container.Created)
 		out.SetAuto("Created", container.Created)
-		out.Set("Path", container.Path)
+		out.SetJson("Path", container.Path)
 		out.SetList("Args", container.Args)
 		out.SetList("Args", container.Args)
 		out.SetJson("Config", container.Config)
 		out.SetJson("Config", container.Config)
 		out.SetJson("State", container.State)
 		out.SetJson("State", container.State)

+ 4 - 0
integration-cli/docker_api_inspect_test.go

@@ -46,6 +46,10 @@ func TestInspectContainerResponse(t *testing.T) {
 				t.Fatalf("%s does not exist in reponse for %s version", key, testVersion)
 				t.Fatalf("%s does not exist in reponse for %s version", key, testVersion)
 			}
 			}
 		}
 		}
+		//Issue #6830: type not properly converted to JSON/back
+		if _, ok := inspect_json["Path"].(bool); ok {
+			t.Fatalf("Path of `true` should not be converted to boolean `true` via JSON marshalling")
+		}
 	}
 	}
 
 
 	deleteAllContainers()
 	deleteAllContainers()