mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Standardize API keys: CamelCase
Docker-DCO-1.1-Signed-off-by: Victor Vieux <vieux@docker.com> (github: vieux)
This commit is contained in:
parent
8ac516094e
commit
68fb7f4b74
6 changed files with 77 additions and 26 deletions
|
@ -848,6 +848,9 @@ func getContainersByName(eng *engine.Engine, version version.Version, w http.Res
|
|||
return fmt.Errorf("Missing parameter")
|
||||
}
|
||||
var job = eng.Job("container_inspect", vars["name"])
|
||||
if version.LessThan("1.12") {
|
||||
job.SetenvBool("dirty", true)
|
||||
}
|
||||
streamJSON(job, w, false)
|
||||
return job.Run()
|
||||
}
|
||||
|
@ -857,6 +860,9 @@ func getImagesByName(eng *engine.Engine, version version.Version, w http.Respons
|
|||
return fmt.Errorf("Missing parameter")
|
||||
}
|
||||
var job = eng.Job("image_inspect", vars["name"])
|
||||
if version.LessThan("1.12") {
|
||||
job.SetenvBool("dirty", true)
|
||||
}
|
||||
streamJSON(job, w, false)
|
||||
return job.Run()
|
||||
}
|
||||
|
|
|
@ -13,14 +13,40 @@ func (daemon *Daemon) ContainerInspect(job *engine.Job) engine.Status {
|
|||
}
|
||||
name := job.Args[0]
|
||||
if container := daemon.Get(name); container != nil {
|
||||
b, err := json.Marshal(&struct {
|
||||
*Container
|
||||
HostConfig *runconfig.HostConfig
|
||||
}{container, container.HostConfig()})
|
||||
if err != nil {
|
||||
if job.GetenvBool("dirty") {
|
||||
b, err := json.Marshal(&struct {
|
||||
*Container
|
||||
HostConfig *runconfig.HostConfig
|
||||
}{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)
|
||||
}
|
||||
job.Stdout.Write(b)
|
||||
return engine.StatusOK
|
||||
}
|
||||
return job.Errorf("No such container: %s", name)
|
||||
|
|
|
@ -2,7 +2,6 @@ package graph
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"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"
|
||||
// metaphor, in practice people either ignore it or use it as a
|
||||
// generic description field which it isn't. On deprecation shortlist.
|
||||
res.Set("created", fmt.Sprintf("%v", img.Created))
|
||||
res.Set("author", img.Author)
|
||||
res.Set("os", img.OS)
|
||||
res.Set("architecture", img.Architecture)
|
||||
res.Set("docker_version", img.DockerVersion)
|
||||
res.Set("ID", img.ID)
|
||||
res.SetAuto("Created", img.Created)
|
||||
res.Set("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.WriteTo(job.Stdout)
|
||||
|
@ -136,11 +135,31 @@ func (s *TagStore) CmdLookup(job *engine.Job) engine.Status {
|
|||
}
|
||||
name := job.Args[0]
|
||||
if image, err := s.LookupImage(name); err == nil && image != nil {
|
||||
b, err := json.Marshal(image)
|
||||
if err != nil {
|
||||
if job.GetenvBool("dirty") {
|
||||
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)
|
||||
}
|
||||
job.Stdout.Write(b)
|
||||
return engine.StatusOK
|
||||
}
|
||||
return job.Errorf("No such image: %s", name)
|
||||
|
|
|
@ -439,7 +439,7 @@ func TestBuildWithVolume(t *testing.T) {
|
|||
VOLUME /test
|
||||
`,
|
||||
"testbuildimg",
|
||||
"{{json .config.Volumes}}",
|
||||
"{{json .Config.Volumes}}",
|
||||
`{"/test":{}}`)
|
||||
|
||||
deleteImages("testbuildimg")
|
||||
|
@ -453,7 +453,7 @@ func TestBuildMaintainer(t *testing.T) {
|
|||
MAINTAINER dockerio
|
||||
`,
|
||||
"testbuildimg",
|
||||
"{{json .author}}",
|
||||
"{{json .Author}}",
|
||||
`"dockerio"`)
|
||||
|
||||
deleteImages("testbuildimg")
|
||||
|
@ -469,7 +469,7 @@ func TestBuildUser(t *testing.T) {
|
|||
RUN [ $(whoami) = 'dockerio' ]
|
||||
`,
|
||||
"testbuildimg",
|
||||
"{{json .config.User}}",
|
||||
"{{json .Config.User}}",
|
||||
`"dockerio"`)
|
||||
|
||||
deleteImages("testbuildimg")
|
||||
|
@ -489,7 +489,7 @@ func TestBuildRelativeWorkdir(t *testing.T) {
|
|||
RUN [ "$PWD" = '/test2/test3' ]
|
||||
`,
|
||||
"testbuildimg",
|
||||
"{{json .config.WorkingDir}}",
|
||||
"{{json .Config.WorkingDir}}",
|
||||
`"/test2/test3"`)
|
||||
|
||||
deleteImages("testbuildimg")
|
||||
|
@ -504,7 +504,7 @@ func TestBuildEnv(t *testing.T) {
|
|||
RUN [ $(env | grep PORT) = 'PORT=4243' ]
|
||||
`,
|
||||
"testbuildimg",
|
||||
"{{json .config.Env}}",
|
||||
"{{json .Config.Env}}",
|
||||
`["HOME=/","PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin","PORT=4243"]`)
|
||||
|
||||
deleteImages("testbuildimg")
|
||||
|
@ -518,7 +518,7 @@ func TestBuildCmd(t *testing.T) {
|
|||
CMD ["/bin/echo", "Hello World"]
|
||||
`,
|
||||
"testbuildimg",
|
||||
"{{json .config.Cmd}}",
|
||||
"{{json .Config.Cmd}}",
|
||||
`["/bin/echo","Hello World"]`)
|
||||
|
||||
deleteImages("testbuildimg")
|
||||
|
@ -533,7 +533,7 @@ func TestBuildExpose(t *testing.T) {
|
|||
`,
|
||||
|
||||
"testbuildimg",
|
||||
"{{json .config.ExposedPorts}}",
|
||||
"{{json .Config.ExposedPorts}}",
|
||||
`{"4243/tcp":{}}`)
|
||||
|
||||
deleteImages("testbuildimg")
|
||||
|
@ -547,7 +547,7 @@ func TestBuildEntrypoint(t *testing.T) {
|
|||
ENTRYPOINT ["/bin/echo"]
|
||||
`,
|
||||
"testbuildimg",
|
||||
"{{json .config.Entrypoint}}",
|
||||
"{{json .Config.Entrypoint}}",
|
||||
`["/bin/echo"]`)
|
||||
|
||||
deleteImages("testbuildimg")
|
||||
|
|
|
@ -27,7 +27,7 @@ func TestTagUnprefixedRepoByName(t *testing.T) {
|
|||
|
||||
// tagging an image by ID in a new unprefixed repo should work
|
||||
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)
|
||||
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 {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return info.Get("ID")
|
||||
return info.Get("Id")
|
||||
}
|
||||
|
||||
// build an image
|
||||
|
|
Loading…
Reference in a new issue