Skip to content

Commit

Permalink
Merge pull request #9610 from duglin/Issue9602
Browse files Browse the repository at this point in the history
Wrap strings that could look like ints in quotes
  • Loading branch information
crosbymichael committed Dec 16, 2014
2 parents 03aea37 + d942c59 commit eea9f0e
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 23 deletions.
2 changes: 1 addition & 1 deletion daemon/image_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (daemon *Daemon) DeleteImage(eng *engine.Engine, name string, imgs *engine.
return err
}
out := &engine.Env{}
out.Set("Deleted", img.ID)
out.SetJson("Deleted", img.ID)
imgs.Add(out)
eng.Job("log", "delete", img.ID, "").Run()
if img.Parent != "" && !noprune {
Expand Down
4 changes: 2 additions & 2 deletions daemon/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (daemon *Daemon) CmdInfo(job *engine.Job) engine.Status {
return job.Error(err)
}
v := &engine.Env{}
v.Set("ID", daemon.ID)
v.SetJson("ID", daemon.ID)
v.SetInt("Containers", len(daemon.List()))
v.SetInt("Images", imgcount)
v.Set("Driver", daemon.GraphDriver().String())
Expand All @@ -78,7 +78,7 @@ func (daemon *Daemon) CmdInfo(job *engine.Job) engine.Status {
v.SetInt64("MemTotal", meminfo.MemTotal)
v.Set("DockerRootDir", daemon.Config().Root)
if hostname, err := os.Hostname(); err == nil {
v.Set("Name", hostname)
v.SetJson("Name", hostname)
}
v.SetList("Labels", daemon.Config().Labels)
if _, err := v.WriteTo(job.Stdout); err != nil {
Expand Down
6 changes: 3 additions & 3 deletions daemon/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ func (daemon *Daemon) ContainerInspect(job *engine.Job) engine.Status {
}

out := &engine.Env{}
out.Set("Id", container.ID)
out.SetJson("Id", container.ID)
out.SetAuto("Created", container.Created)
out.SetJson("Path", container.Path)
out.SetList("Args", container.Args)
out.SetJson("Config", container.Config)
out.SetJson("State", container.State)
out.Set("Image", container.Image)
out.SetJson("Image", container.Image)
out.SetJson("NetworkSettings", container.NetworkSettings)
out.Set("ResolvConfPath", container.ResolvConfPath)
out.Set("HostnamePath", container.HostnamePath)
out.Set("HostsPath", container.HostsPath)
out.Set("Name", container.Name)
out.SetJson("Name", container.Name)
out.SetInt("RestartCount", container.RestartCount)
out.Set("Driver", container.Driver)
out.Set("ExecDriver", container.ExecDriver)
Expand Down
4 changes: 2 additions & 2 deletions daemon/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ func (daemon *Daemon) Containers(job *engine.Job) engine.Status {
}
displayed++
out := &engine.Env{}
out.Set("Id", container.ID)
out.SetJson("Id", container.ID)
out.SetList("Names", names[container.ID])
out.Set("Image", daemon.Repositories().ImageName(container.Image))
out.SetJson("Image", daemon.Repositories().ImageName(container.Image))
if len(container.Args) > 0 {
args := []string{}
for _, arg := range container.Args {
Expand Down
2 changes: 1 addition & 1 deletion graph/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (s *TagStore) CmdHistory(job *engine.Job) engine.Status {
outs := engine.NewTable("Created", 0)
err = foundImage.WalkHistory(func(img *image.Image) error {
out := &engine.Env{}
out.Set("Id", img.ID)
out.SetJson("Id", img.ID)
out.SetInt64("Created", img.Created.Unix())
out.Set("CreatedBy", strings.Join(img.ContainerConfig.Cmd, " "))
out.SetList("Tags", lookupMap[img.ID])
Expand Down
8 changes: 4 additions & 4 deletions graph/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ func (s *TagStore) CmdImages(job *engine.Job) engine.Status {
delete(allImages, id)
if filt_tagged {
out := &engine.Env{}
out.Set("ParentId", image.Parent)
out.SetJson("ParentId", image.Parent)
out.SetList("RepoTags", []string{fmt.Sprintf("%s:%s", name, tag)})
out.Set("Id", image.ID)
out.SetJson("Id", image.ID)
out.SetInt64("Created", image.Created.Unix())
out.SetInt64("Size", image.Size)
out.SetInt64("VirtualSize", image.GetParentsSize(0)+image.Size)
Expand All @@ -85,9 +85,9 @@ func (s *TagStore) CmdImages(job *engine.Job) engine.Status {
if job.Getenv("filter") == "" {
for _, image := range allImages {
out := &engine.Env{}
out.Set("ParentId", image.Parent)
out.SetJson("ParentId", image.Parent)
out.SetList("RepoTags", []string{"<none>:<none>"})
out.Set("Id", image.ID)
out.SetJson("Id", image.ID)
out.SetInt64("Created", image.Created.Unix())
out.SetInt64("Size", image.Size)
out.SetInt64("VirtualSize", image.GetParentsSize(0)+image.Size)
Expand Down
16 changes: 8 additions & 8 deletions graph/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ func (s *TagStore) CmdGet(job *engine.Job) engine.Status {
// metaphor, in practice people either ignore it or use it as a
// generic description field which it isn't. On deprecation shortlist.
res.SetAuto("Created", img.Created)
res.Set("Author", img.Author)
res.SetJson("Author", img.Author)
res.Set("Os", img.OS)
res.Set("Architecture", img.Architecture)
res.Set("DockerVersion", img.DockerVersion)
res.Set("Id", img.ID)
res.Set("Parent", img.Parent)
res.SetJson("Id", img.ID)
res.SetJson("Parent", img.Parent)
}
res.WriteTo(job.Stdout)
return engine.StatusOK
Expand All @@ -137,14 +137,14 @@ func (s *TagStore) CmdLookup(job *engine.Job) engine.Status {
}

out := &engine.Env{}
out.Set("Id", image.ID)
out.Set("Parent", image.Parent)
out.Set("Comment", image.Comment)
out.SetJson("Id", image.ID)
out.SetJson("Parent", image.Parent)
out.SetJson("Comment", image.Comment)
out.SetAuto("Created", image.Created)
out.Set("Container", image.Container)
out.SetJson("Container", image.Container)
out.SetJson("ContainerConfig", image.ContainerConfig)
out.Set("DockerVersion", image.DockerVersion)
out.Set("Author", image.Author)
out.SetJson("Author", image.Author)
out.SetJson("Config", image.Config)
out.Set("Architecture", image.Architecture)
out.Set("Os", image.OS)
Expand Down
26 changes: 24 additions & 2 deletions integration-cli/docker_cli_build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3004,13 +3004,35 @@ docker.com>"
t.Fatal(err)
}

if res != "Docker IO <io@docker.com>" {
t.Fatal("Parsed string did not match the escaped string")
if res != "\"Docker IO <io@docker.com>\"" {
t.Fatalf("Parsed string did not match the escaped string. Got: %q", res)
}

logDone("build - validate escaping whitespace")
}

func TestBuildVerifyIntString(t *testing.T) {
// Verify that strings that look like ints are still passed as strings
name := "testbuildstringing"
defer deleteImages(name)

_, err := buildImage(name, `
FROM busybox
MAINTAINER 123
`, true)

out, rc, err := runCommandWithOutput(exec.Command(dockerBinary, "inspect", name))
if rc != 0 || err != nil {
t.Fatalf("Unexcepted error from inspect: rc: %v err: %v", rc, err)
}

if !strings.Contains(out, "\"123\"") {
t.Fatalf("Output does not contain the int as a string:\n%s", out)
}

logDone("build - verify int/strings as strings")
}

func TestBuildDockerignore(t *testing.T) {
name := "testbuilddockerignore"
defer deleteImages(name)
Expand Down

0 comments on commit eea9f0e

Please sign in to comment.