Browse code

Merge pull request #6130 from vieux/standardize_api_keys

Standardize api keys to CamelCase

Michael Crosby authored on 2014/06/03 04:03:11
Showing 8 changed files
... ...
@@ -848,6 +848,9 @@ func getContainersByName(eng *engine.Engine, version version.Version, w http.Res
848 848
 		return fmt.Errorf("Missing parameter")
849 849
 	}
850 850
 	var job = eng.Job("container_inspect", vars["name"])
851
+	if version.LessThan("1.12") {
852
+		job.SetenvBool("dirty", true)
853
+	}
851 854
 	streamJSON(job, w, false)
852 855
 	return job.Run()
853 856
 }
... ...
@@ -857,6 +860,9 @@ func getImagesByName(eng *engine.Engine, version version.Version, w http.Respons
857 857
 		return fmt.Errorf("Missing parameter")
858 858
 	}
859 859
 	var job = eng.Job("image_inspect", vars["name"])
860
+	if version.LessThan("1.12") {
861
+		job.SetenvBool("dirty", true)
862
+	}
860 863
 	streamJSON(job, w, false)
861 864
 	return job.Run()
862 865
 }
... ...
@@ -13,14 +13,40 @@ func (daemon *Daemon) ContainerInspect(job *engine.Job) engine.Status {
13 13
 	}
14 14
 	name := job.Args[0]
15 15
 	if container := daemon.Get(name); container != nil {
16
-		b, err := json.Marshal(&struct {
17
-			*Container
18
-			HostConfig *runconfig.HostConfig
19
-		}{container, container.HostConfig()})
20
-		if err != nil {
16
+		if job.GetenvBool("dirty") {
17
+			b, err := json.Marshal(&struct {
18
+				*Container
19
+				HostConfig *runconfig.HostConfig
20
+			}{container, container.HostConfig()})
21
+			if err != nil {
22
+				return job.Error(err)
23
+			}
24
+			job.Stdout.Write(b)
25
+			return engine.StatusOK
26
+		}
27
+
28
+		out := &engine.Env{}
29
+		out.Set("Id", container.ID)
30
+		out.SetAuto("Created", container.Created)
31
+		out.Set("Path", container.Path)
32
+		out.SetList("Args", container.Args)
33
+		out.SetJson("Config", container.Config)
34
+		out.SetJson("State", container.State)
35
+		out.Set("Image", container.Image)
36
+		out.SetJson("NetworkSettings", container.NetworkSettings)
37
+		out.Set("ResolvConfPath", container.ResolvConfPath)
38
+		out.Set("HostnamePath", container.HostnamePath)
39
+		out.Set("HostsPath", container.HostsPath)
40
+		out.Set("Name", container.Name)
41
+		out.Set("Driver", container.Driver)
42
+		out.Set("ExecDriver", container.ExecDriver)
43
+		out.Set("MountLabel", container.MountLabel)
44
+		out.Set("ProcessLabel", container.ProcessLabel)
45
+		out.SetJson("VolumesRW", container.VolumesRW)
46
+		out.SetJson("HostConfig", container.hostConfig)
47
+		if _, err := out.WriteTo(job.Stdout); err != nil {
21 48
 			return job.Error(err)
22 49
 		}
23
-		job.Stdout.Write(b)
24 50
 		return engine.StatusOK
25 51
 	}
26 52
 	return job.Errorf("No such container: %s", name)
... ...
@@ -36,7 +36,16 @@ You can still call an old version of the api using
36 36
 
37 37
 ### What's new
38 38
 
39
-docker build now has support for the `forcerm` parameter to always remove containers
39
+`POST /build`
40
+
41
+**New!**
42
+Build now has support for the `forcerm` parameter to always remove containers
43
+
44
+`GET /containers/(name)/json`
45
+`GET /images/(name)/json`
46
+
47
+**New!**
48
+All the JSON keys are now in CamelCase
40 49
 
41 50
 ## v1.11
42 51
 
... ...
@@ -798,11 +798,9 @@ Return low-level information on the image `name`
798 798
         Content-Type: application/json
799 799
 
800 800
         {
801
-             "id":"b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
802
-             "parent":"27cf784147099545",
803
-             "created":"2013-03-23T22:24:18.818426-07:00",
804
-             "container":"3d67245a8d72ecf13f33dffac9f79dcdf70f75acb84d308770391510e0c23ad0",
805
-             "container_config":
801
+             "Created":"2013-03-23T22:24:18.818426-07:00",
802
+             "Container":"3d67245a8d72ecf13f33dffac9f79dcdf70f75acb84d308770391510e0c23ad0",
803
+             "ContainerConfig":
806 804
                      {
807 805
                              "Hostname":"",
808 806
                              "User":"",
... ...
@@ -823,6 +821,8 @@ Return low-level information on the image `name`
823 823
                              "VolumesFrom":"",
824 824
                              "WorkingDir":""
825 825
                      },
826
+             "Id":"b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
827
+             "Parent":"27cf784147099545",
826 828
              "Size": 6824592
827 829
         }
828 830
 
... ...
@@ -2,7 +2,6 @@ package graph
2 2
 
3 3
 import (
4 4
 	"encoding/json"
5
-	"fmt"
6 5
 	"io"
7 6
 
8 7
 	"github.com/dotcloud/docker/engine"
... ...
@@ -117,12 +116,12 @@ func (s *TagStore) CmdGet(job *engine.Job) engine.Status {
117 117
 		//	- Comment: initially created to fulfill the "every image is a git commit"
118 118
 		//		metaphor, in practice people either ignore it or use it as a
119 119
 		//		generic description field which it isn't. On deprecation shortlist.
120
-		res.Set("created", fmt.Sprintf("%v", img.Created))
121
-		res.Set("author", img.Author)
122
-		res.Set("os", img.OS)
123
-		res.Set("architecture", img.Architecture)
124
-		res.Set("docker_version", img.DockerVersion)
125
-		res.Set("ID", img.ID)
120
+		res.SetAuto("Created", img.Created)
121
+		res.Set("Author", img.Author)
122
+		res.Set("Os", img.OS)
123
+		res.Set("Architecture", img.Architecture)
124
+		res.Set("DockerVersion", img.DockerVersion)
125
+		res.Set("Id", img.ID)
126 126
 		res.Set("Parent", img.Parent)
127 127
 	}
128 128
 	res.WriteTo(job.Stdout)
... ...
@@ -136,11 +135,31 @@ func (s *TagStore) CmdLookup(job *engine.Job) engine.Status {
136 136
 	}
137 137
 	name := job.Args[0]
138 138
 	if image, err := s.LookupImage(name); err == nil && image != nil {
139
-		b, err := json.Marshal(image)
140
-		if err != nil {
139
+		if job.GetenvBool("dirty") {
140
+			b, err := json.Marshal(image)
141
+			if err != nil {
142
+				return job.Error(err)
143
+			}
144
+			job.Stdout.Write(b)
145
+			return engine.StatusOK
146
+		}
147
+
148
+		out := &engine.Env{}
149
+		out.Set("Id", image.ID)
150
+		out.Set("Parent", image.Parent)
151
+		out.Set("Comment", image.Comment)
152
+		out.SetAuto("Created", image.Created)
153
+		out.Set("Container", image.Container)
154
+		out.SetJson("ContainerConfig", image.ContainerConfig)
155
+		out.Set("DockerVersion", image.DockerVersion)
156
+		out.Set("Author", image.Author)
157
+		out.SetJson("Config", image.Config)
158
+		out.Set("Architecture", image.Architecture)
159
+		out.Set("Os", image.OS)
160
+		out.SetInt64("Size", image.Size)
161
+		if _, err = out.WriteTo(job.Stdout); err != nil {
141 162
 			return job.Error(err)
142 163
 		}
143
-		job.Stdout.Write(b)
144 164
 		return engine.StatusOK
145 165
 	}
146 166
 	return job.Errorf("No such image: %s", name)
... ...
@@ -614,7 +614,7 @@ func TestBuildWithVolume(t *testing.T) {
614 614
 		VOLUME /test
615 615
 		`,
616 616
 		"testbuildimg",
617
-		"{{json .config.Volumes}}",
617
+		"{{json .Config.Volumes}}",
618 618
 		`{"/test":{}}`)
619 619
 
620 620
 	deleteImages("testbuildimg")
... ...
@@ -628,7 +628,7 @@ func TestBuildMaintainer(t *testing.T) {
628 628
         MAINTAINER dockerio
629 629
 		`,
630 630
 		"testbuildimg",
631
-		"{{json .author}}",
631
+		"{{json .Author}}",
632 632
 		`"dockerio"`)
633 633
 
634 634
 	deleteImages("testbuildimg")
... ...
@@ -644,7 +644,7 @@ func TestBuildUser(t *testing.T) {
644 644
 		RUN [ $(whoami) = 'dockerio' ]
645 645
 		`,
646 646
 		"testbuildimg",
647
-		"{{json .config.User}}",
647
+		"{{json .Config.User}}",
648 648
 		`"dockerio"`)
649 649
 
650 650
 	deleteImages("testbuildimg")
... ...
@@ -664,7 +664,7 @@ func TestBuildRelativeWorkdir(t *testing.T) {
664 664
 		RUN [ "$PWD" = '/test2/test3' ]
665 665
 		`,
666 666
 		"testbuildimg",
667
-		"{{json .config.WorkingDir}}",
667
+		"{{json .Config.WorkingDir}}",
668 668
 		`"/test2/test3"`)
669 669
 
670 670
 	deleteImages("testbuildimg")
... ...
@@ -679,7 +679,7 @@ func TestBuildEnv(t *testing.T) {
679 679
 		RUN [ $(env | grep PORT) = 'PORT=4243' ]
680 680
         `,
681 681
 		"testbuildimg",
682
-		"{{json .config.Env}}",
682
+		"{{json .Config.Env}}",
683 683
 		`["HOME=/","PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin","PORT=4243"]`)
684 684
 
685 685
 	deleteImages("testbuildimg")
... ...
@@ -693,7 +693,7 @@ func TestBuildCmd(t *testing.T) {
693 693
         CMD ["/bin/echo", "Hello World"]
694 694
         `,
695 695
 		"testbuildimg",
696
-		"{{json .config.Cmd}}",
696
+		"{{json .Config.Cmd}}",
697 697
 		`["/bin/echo","Hello World"]`)
698 698
 
699 699
 	deleteImages("testbuildimg")
... ...
@@ -708,7 +708,7 @@ func TestBuildExpose(t *testing.T) {
708 708
         `,
709 709
 
710 710
 		"testbuildimg",
711
-		"{{json .config.ExposedPorts}}",
711
+		"{{json .Config.ExposedPorts}}",
712 712
 		`{"4243/tcp":{}}`)
713 713
 
714 714
 	deleteImages("testbuildimg")
... ...
@@ -722,7 +722,7 @@ func TestBuildEntrypoint(t *testing.T) {
722 722
         ENTRYPOINT ["/bin/echo"]
723 723
         `,
724 724
 		"testbuildimg",
725
-		"{{json .config.Entrypoint}}",
725
+		"{{json .Config.Entrypoint}}",
726 726
 		`["/bin/echo"]`)
727 727
 
728 728
 	deleteImages("testbuildimg")
... ...
@@ -27,7 +27,7 @@ func TestTagUnprefixedRepoByName(t *testing.T) {
27 27
 
28 28
 // tagging an image by ID in a new unprefixed repo should work
29 29
 func TestTagUnprefixedRepoByID(t *testing.T) {
30
-	getIDCmd := exec.Command(dockerBinary, "inspect", "-f", "{{.id}}", "busybox")
30
+	getIDCmd := exec.Command(dockerBinary, "inspect", "-f", "{{.Id}}", "busybox")
31 31
 	out, _, err := runCommandWithOutput(getIDCmd)
32 32
 	errorOut(err, t, fmt.Sprintf("failed to get the image ID of busybox: %v", err))
33 33
 
... ...
@@ -1057,7 +1057,7 @@ func TestContainerOrphaning(t *testing.T) {
1057 1057
 		if err := job.Run(); err != nil {
1058 1058
 			t.Fatal(err)
1059 1059
 		}
1060
-		return info.Get("ID")
1060
+		return info.Get("Id")
1061 1061
 	}
1062 1062
 
1063 1063
 	// build an image