Merge pull request #6130 from vieux/standardize_api_keys

Standardize api keys to CamelCase
This commit is contained in:
Michael Crosby 2014-06-02 12:03:11 -07:00
Родитель 43b7af1dd1 1dd02ff4a0
Коммит 3e13aaec00
8 изменённых файлов: 92 добавлений и 32 удалений

Просмотреть файл

@ -848,6 +848,9 @@ func getContainersByName(eng *engine.Engine, version version.Version, w http.Res
return fmt.Errorf("Missing parameter") return fmt.Errorf("Missing parameter")
} }
var job = eng.Job("container_inspect", vars["name"]) var job = eng.Job("container_inspect", vars["name"])
if version.LessThan("1.12") {
job.SetenvBool("dirty", true)
}
streamJSON(job, w, false) streamJSON(job, w, false)
return job.Run() return job.Run()
} }
@ -857,6 +860,9 @@ func getImagesByName(eng *engine.Engine, version version.Version, w http.Respons
return fmt.Errorf("Missing parameter") return fmt.Errorf("Missing parameter")
} }
var job = eng.Job("image_inspect", vars["name"]) var job = eng.Job("image_inspect", vars["name"])
if version.LessThan("1.12") {
job.SetenvBool("dirty", true)
}
streamJSON(job, w, false) streamJSON(job, w, false)
return job.Run() return job.Run()
} }

Просмотреть файл

@ -13,14 +13,40 @@ func (daemon *Daemon) ContainerInspect(job *engine.Job) engine.Status {
} }
name := job.Args[0] name := job.Args[0]
if container := daemon.Get(name); container != nil { if container := daemon.Get(name); container != nil {
b, err := json.Marshal(&struct { if job.GetenvBool("dirty") {
*Container b, err := json.Marshal(&struct {
HostConfig *runconfig.HostConfig *Container
}{container, container.HostConfig()}) HostConfig *runconfig.HostConfig
if err != nil { }{container, container.HostConfig()})
if err != nil {
return job.Error(err)
}
job.Stdout.Write(b)
return engine.StatusOK
}
out := &engine.Env{}
out.Set("Id", container.ID)
out.SetAuto("Created", container.Created)
out.Set("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("NetworkSettings", container.NetworkSettings)
out.Set("ResolvConfPath", container.ResolvConfPath)
out.Set("HostnamePath", container.HostnamePath)
out.Set("HostsPath", container.HostsPath)
out.Set("Name", container.Name)
out.Set("Driver", container.Driver)
out.Set("ExecDriver", container.ExecDriver)
out.Set("MountLabel", container.MountLabel)
out.Set("ProcessLabel", container.ProcessLabel)
out.SetJson("VolumesRW", container.VolumesRW)
out.SetJson("HostConfig", container.hostConfig)
if _, err := out.WriteTo(job.Stdout); err != nil {
return job.Error(err) return job.Error(err)
} }
job.Stdout.Write(b)
return engine.StatusOK return engine.StatusOK
} }
return job.Errorf("No such container: %s", name) return job.Errorf("No such container: %s", name)

Просмотреть файл

@ -36,7 +36,16 @@ You can still call an old version of the api using
### What's new ### What's new
docker build now has support for the `forcerm` parameter to always remove containers `POST /build`
**New!**
Build now has support for the `forcerm` parameter to always remove containers
`GET /containers/(name)/json`
`GET /images/(name)/json`
**New!**
All the JSON keys are now in CamelCase
## v1.11 ## v1.11

Просмотреть файл

@ -798,11 +798,9 @@ Return low-level information on the image `name`
Content-Type: application/json Content-Type: application/json
{ {
"id":"b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc", "Created":"2013-03-23T22:24:18.818426-07:00",
"parent":"27cf784147099545", "Container":"3d67245a8d72ecf13f33dffac9f79dcdf70f75acb84d308770391510e0c23ad0",
"created":"2013-03-23T22:24:18.818426-07:00", "ContainerConfig":
"container":"3d67245a8d72ecf13f33dffac9f79dcdf70f75acb84d308770391510e0c23ad0",
"container_config":
{ {
"Hostname":"", "Hostname":"",
"User":"", "User":"",
@ -823,6 +821,8 @@ Return low-level information on the image `name`
"VolumesFrom":"", "VolumesFrom":"",
"WorkingDir":"" "WorkingDir":""
}, },
"Id":"b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
"Parent":"27cf784147099545",
"Size": 6824592 "Size": 6824592
} }

Просмотреть файл

@ -2,7 +2,6 @@ package graph
import ( import (
"encoding/json" "encoding/json"
"fmt"
"io" "io"
"github.com/dotcloud/docker/engine" "github.com/dotcloud/docker/engine"
@ -117,12 +116,12 @@ func (s *TagStore) CmdGet(job *engine.Job) engine.Status {
// - Comment: initially created to fulfill the "every image is a git commit" // - Comment: initially created to fulfill the "every image is a git commit"
// metaphor, in practice people either ignore it or use it as a // metaphor, in practice people either ignore it or use it as a
// generic description field which it isn't. On deprecation shortlist. // generic description field which it isn't. On deprecation shortlist.
res.Set("created", fmt.Sprintf("%v", img.Created)) res.SetAuto("Created", img.Created)
res.Set("author", img.Author) res.Set("Author", img.Author)
res.Set("os", img.OS) res.Set("Os", img.OS)
res.Set("architecture", img.Architecture) res.Set("Architecture", img.Architecture)
res.Set("docker_version", img.DockerVersion) res.Set("DockerVersion", img.DockerVersion)
res.Set("ID", img.ID) res.Set("Id", img.ID)
res.Set("Parent", img.Parent) res.Set("Parent", img.Parent)
} }
res.WriteTo(job.Stdout) res.WriteTo(job.Stdout)
@ -136,11 +135,31 @@ func (s *TagStore) CmdLookup(job *engine.Job) engine.Status {
} }
name := job.Args[0] name := job.Args[0]
if image, err := s.LookupImage(name); err == nil && image != nil { if image, err := s.LookupImage(name); err == nil && image != nil {
b, err := json.Marshal(image) if job.GetenvBool("dirty") {
if err != nil { b, err := json.Marshal(image)
if err != nil {
return job.Error(err)
}
job.Stdout.Write(b)
return engine.StatusOK
}
out := &engine.Env{}
out.Set("Id", image.ID)
out.Set("Parent", image.Parent)
out.Set("Comment", image.Comment)
out.SetAuto("Created", image.Created)
out.Set("Container", image.Container)
out.SetJson("ContainerConfig", image.ContainerConfig)
out.Set("DockerVersion", image.DockerVersion)
out.Set("Author", image.Author)
out.SetJson("Config", image.Config)
out.Set("Architecture", image.Architecture)
out.Set("Os", image.OS)
out.SetInt64("Size", image.Size)
if _, err = out.WriteTo(job.Stdout); err != nil {
return job.Error(err) return job.Error(err)
} }
job.Stdout.Write(b)
return engine.StatusOK return engine.StatusOK
} }
return job.Errorf("No such image: %s", name) return job.Errorf("No such image: %s", name)

Просмотреть файл

@ -614,7 +614,7 @@ func TestBuildWithVolume(t *testing.T) {
VOLUME /test VOLUME /test
`, `,
"testbuildimg", "testbuildimg",
"{{json .config.Volumes}}", "{{json .Config.Volumes}}",
`{"/test":{}}`) `{"/test":{}}`)
deleteImages("testbuildimg") deleteImages("testbuildimg")
@ -628,7 +628,7 @@ func TestBuildMaintainer(t *testing.T) {
MAINTAINER dockerio MAINTAINER dockerio
`, `,
"testbuildimg", "testbuildimg",
"{{json .author}}", "{{json .Author}}",
`"dockerio"`) `"dockerio"`)
deleteImages("testbuildimg") deleteImages("testbuildimg")
@ -644,7 +644,7 @@ func TestBuildUser(t *testing.T) {
RUN [ $(whoami) = 'dockerio' ] RUN [ $(whoami) = 'dockerio' ]
`, `,
"testbuildimg", "testbuildimg",
"{{json .config.User}}", "{{json .Config.User}}",
`"dockerio"`) `"dockerio"`)
deleteImages("testbuildimg") deleteImages("testbuildimg")
@ -664,7 +664,7 @@ func TestBuildRelativeWorkdir(t *testing.T) {
RUN [ "$PWD" = '/test2/test3' ] RUN [ "$PWD" = '/test2/test3' ]
`, `,
"testbuildimg", "testbuildimg",
"{{json .config.WorkingDir}}", "{{json .Config.WorkingDir}}",
`"/test2/test3"`) `"/test2/test3"`)
deleteImages("testbuildimg") deleteImages("testbuildimg")
@ -679,7 +679,7 @@ func TestBuildEnv(t *testing.T) {
RUN [ $(env | grep PORT) = 'PORT=4243' ] RUN [ $(env | grep PORT) = 'PORT=4243' ]
`, `,
"testbuildimg", "testbuildimg",
"{{json .config.Env}}", "{{json .Config.Env}}",
`["HOME=/","PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin","PORT=4243"]`) `["HOME=/","PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin","PORT=4243"]`)
deleteImages("testbuildimg") deleteImages("testbuildimg")
@ -693,7 +693,7 @@ func TestBuildCmd(t *testing.T) {
CMD ["/bin/echo", "Hello World"] CMD ["/bin/echo", "Hello World"]
`, `,
"testbuildimg", "testbuildimg",
"{{json .config.Cmd}}", "{{json .Config.Cmd}}",
`["/bin/echo","Hello World"]`) `["/bin/echo","Hello World"]`)
deleteImages("testbuildimg") deleteImages("testbuildimg")
@ -708,7 +708,7 @@ func TestBuildExpose(t *testing.T) {
`, `,
"testbuildimg", "testbuildimg",
"{{json .config.ExposedPorts}}", "{{json .Config.ExposedPorts}}",
`{"4243/tcp":{}}`) `{"4243/tcp":{}}`)
deleteImages("testbuildimg") deleteImages("testbuildimg")
@ -722,7 +722,7 @@ func TestBuildEntrypoint(t *testing.T) {
ENTRYPOINT ["/bin/echo"] ENTRYPOINT ["/bin/echo"]
`, `,
"testbuildimg", "testbuildimg",
"{{json .config.Entrypoint}}", "{{json .Config.Entrypoint}}",
`["/bin/echo"]`) `["/bin/echo"]`)
deleteImages("testbuildimg") deleteImages("testbuildimg")

Просмотреть файл

@ -27,7 +27,7 @@ func TestTagUnprefixedRepoByName(t *testing.T) {
// tagging an image by ID in a new unprefixed repo should work // tagging an image by ID in a new unprefixed repo should work
func TestTagUnprefixedRepoByID(t *testing.T) { func TestTagUnprefixedRepoByID(t *testing.T) {
getIDCmd := exec.Command(dockerBinary, "inspect", "-f", "{{.id}}", "busybox") getIDCmd := exec.Command(dockerBinary, "inspect", "-f", "{{.Id}}", "busybox")
out, _, err := runCommandWithOutput(getIDCmd) out, _, err := runCommandWithOutput(getIDCmd)
errorOut(err, t, fmt.Sprintf("failed to get the image ID of busybox: %v", err)) errorOut(err, t, fmt.Sprintf("failed to get the image ID of busybox: %v", err))

Просмотреть файл

@ -1057,7 +1057,7 @@ func TestContainerOrphaning(t *testing.T) {
if err := job.Run(); err != nil { if err := job.Run(); err != nil {
t.Fatal(err) t.Fatal(err)
} }
return info.Get("ID") return info.Get("Id")
} }
// build an image // build an image