aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2018-02-11 06:05:29 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2018-02-11 11:50:34 +0000
commit2e96acf3007cbd05a37a8af7156f0abda073cb5a (patch)
treeeab653d95e0d9fe3deb44f12140782c84059eaa2
parentd26266659d8649b36b91e8f8f78f8073007554ac (diff)
downloadpodman-2e96acf3007cbd05a37a8af7156f0abda073cb5a.tar.gz
podman-2e96acf3007cbd05a37a8af7156f0abda073cb5a.tar.bz2
podman-2e96acf3007cbd05a37a8af7156f0abda073cb5a.zip
Change json to match docker inspect
Changing these fields caused the output of podman inspect to more closely match docker inspect. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com> Closes: #306 Approved by: mheon
-rw-r--r--cmd/podman/create.go18
-rw-r--r--cmd/podman/inspect.go4
-rw-r--r--cmd/podman/run_test.go18
-rw-r--r--docs/podman-inspect.1.md2
-rw-r--r--libpod/image_inspect.go30
-rw-r--r--pkg/inspect/inspect.go36
-rw-r--r--test/e2e/import_test.go2
7 files changed, 57 insertions, 53 deletions
diff --git a/cmd/podman/create.go b/cmd/podman/create.go
index f847b2d22..2012aa6de 100644
--- a/cmd/podman/create.go
+++ b/cmd/podman/create.go
@@ -520,12 +520,12 @@ func parseCreateOpts(c *cli.Context, runtime *libpod.Runtime, imageName string,
// USER
user := c.String("user")
if user == "" {
- user = data.Config.User
+ user = data.ContainerConfig.User
}
// STOP SIGNAL
stopSignal := syscall.SIGTERM
- signalString := data.Config.StopSignal
+ signalString := data.ContainerConfig.StopSignal
if c.IsSet("stop-signal") {
signalString = c.String("stop-signal")
}
@@ -538,7 +538,7 @@ func parseCreateOpts(c *cli.Context, runtime *libpod.Runtime, imageName string,
// ENVIRONMENT VARIABLES
env := defaultEnvVariables
- for _, e := range data.Config.Env {
+ for _, e := range data.ContainerConfig.Env {
split := strings.SplitN(e, "=", 2)
if len(split) > 1 {
env[split[0]] = split[1]
@@ -555,7 +555,7 @@ func parseCreateOpts(c *cli.Context, runtime *libpod.Runtime, imageName string,
if err != nil {
return nil, errors.Wrapf(err, "unable to process labels")
}
- for key, val := range data.Config.Labels {
+ for key, val := range data.ContainerConfig.Labels {
if _, ok := labels[key]; !ok {
labels[key] = val
}
@@ -564,14 +564,14 @@ func parseCreateOpts(c *cli.Context, runtime *libpod.Runtime, imageName string,
// WORKING DIRECTORY
workDir := c.String("workdir")
if workDir == "" {
- workDir = data.Config.WorkingDir
+ workDir = data.ContainerConfig.WorkingDir
}
// ENTRYPOINT
// User input entrypoint takes priority over image entrypoint
entrypoint := c.StringSlice("entrypoint")
if len(entrypoint) == 0 {
- entrypoint = data.Config.Entrypoint
+ entrypoint = data.ContainerConfig.Entrypoint
}
// Build the command
@@ -582,13 +582,13 @@ func parseCreateOpts(c *cli.Context, runtime *libpod.Runtime, imageName string,
if len(inputCommand) > 0 {
// User command overrides data CMD
command = append(command, inputCommand...)
- } else if len(data.Config.Cmd) > 0 && !c.IsSet("entrypoint") {
+ } else if len(data.ContainerConfig.Cmd) > 0 && !c.IsSet("entrypoint") {
// If not user command, add CMD
- command = append(command, data.Config.Cmd...)
+ command = append(command, data.ContainerConfig.Cmd...)
}
// EXPOSED PORTS
- portBindings, err := exposedPorts(c, data.Config.ExposedPorts)
+ portBindings, err := exposedPorts(c, data.ContainerConfig.ExposedPorts)
if err != nil {
return nil, err
}
diff --git a/cmd/podman/inspect.go b/cmd/podman/inspect.go
index 84107f3db..ce5a3b823 100644
--- a/cmd/podman/inspect.go
+++ b/cmd/podman/inspect.go
@@ -78,6 +78,10 @@ func inspectCmd(c *cli.Context) error {
inspectType = inspectTypeContainer
}
outputFormat := c.String("format")
+ if strings.Contains(outputFormat, "{{.Id}}") {
+ outputFormat = strings.Replace(outputFormat, "{{.Id}}", formats.IDString, -1)
+ }
+
var data interface{}
switch inspectType {
case inspectTypeContainer:
diff --git a/cmd/podman/run_test.go b/cmd/podman/run_test.go
index 55c535337..344fdcce5 100644
--- a/cmd/podman/run_test.go
+++ b/cmd/podman/run_test.go
@@ -36,15 +36,15 @@ func generateAlpineImageData() *inspect.ImageData {
}
data := &inspect.ImageData{
- ID: "e21c333399e0aeedfd70e8827c9fba3f8e9b170ef8a48a29945eb7702bf6aa5f",
- RepoTags: []string{"docker.io/library/alpine:latest"},
- RepoDigests: []string{"docker.io/library/alpine@sha256:5cb04fce748f576d7b72a37850641de8bd725365519673c643ef2d14819b42c6"},
- Comment: "Created:2017-12-01 18:48:48.949613376 +0000",
- Author: "",
- Architecture: "amd64",
- Os: "linux",
- Version: "17.06.2-ce",
- Config: config,
+ ID: "e21c333399e0aeedfd70e8827c9fba3f8e9b170ef8a48a29945eb7702bf6aa5f",
+ RepoTags: []string{"docker.io/library/alpine:latest"},
+ RepoDigests: []string{"docker.io/library/alpine@sha256:5cb04fce748f576d7b72a37850641de8bd725365519673c643ef2d14819b42c6"},
+ Comment: "Created:2017-12-01 18:48:48.949613376 +0000",
+ Author: "",
+ Architecture: "amd64",
+ Os: "linux",
+ Version: "17.06.2-ce",
+ ContainerConfig: config,
}
return data
}
diff --git a/docs/podman-inspect.1.md b/docs/podman-inspect.1.md
index e40dfa29f..9f39deceb 100644
--- a/docs/podman-inspect.1.md
+++ b/docs/podman-inspect.1.md
@@ -46,7 +46,7 @@ Display the total file size if the type is a container
"Parent": "",
"Comment": "",
"Created": "2017-11-14T21:07:08.475840838Z",
- "Config": {
+ "ContainerConfig": {
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"DISTTAG=f27container",
diff --git a/libpod/image_inspect.go b/libpod/image_inspect.go
index cc4b8307a..df2d3640e 100644
--- a/libpod/image_inspect.go
+++ b/libpod/image_inspect.go
@@ -42,21 +42,21 @@ func getImageData(img storage.Image, imgRef types.Image, size int64, driver *ins
}
data := &inspect.ImageData{
- ID: img.ID,
- RepoTags: img.Names,
- RepoDigests: repoDigests,
- Comment: ociv1Img.History[0].Comment,
- Created: ociv1Img.Created,
- Author: ociv1Img.Author,
- Architecture: ociv1Img.Architecture,
- Os: ociv1Img.OS,
- Config: &ociv1Img.Config,
- Version: info.DockerVersion,
- Size: size,
- VirtualSize: size + imgSize,
- Annotations: annotations,
- Digest: imgDigest,
- Labels: info.Labels,
+ ID: img.ID,
+ RepoTags: img.Names,
+ RepoDigests: repoDigests,
+ Comment: ociv1Img.History[0].Comment,
+ Created: ociv1Img.Created,
+ Author: ociv1Img.Author,
+ Architecture: ociv1Img.Architecture,
+ Os: ociv1Img.OS,
+ ContainerConfig: &ociv1Img.Config,
+ Version: info.DockerVersion,
+ Size: size,
+ VirtualSize: size + imgSize,
+ Annotations: annotations,
+ Digest: imgDigest,
+ Labels: info.Labels,
RootFS: &inspect.RootFS{
Type: ociv1Img.RootFS.Type,
Layers: ociv1Img.RootFS.DiffIDs,
diff --git a/pkg/inspect/inspect.go b/pkg/inspect/inspect.go
index 11a252535..e523d4c4d 100644
--- a/pkg/inspect/inspect.go
+++ b/pkg/inspect/inspect.go
@@ -106,24 +106,24 @@ type LogConfig struct {
// ImageData holds the inspect information of an image
type ImageData struct {
- ID string `json:"ID"`
- Digest digest.Digest `json:"Digest"`
- RepoTags []string `json:"RepoTags"`
- RepoDigests []string `json:"RepoDigests"`
- Parent string `json:"Parent"`
- Comment string `json:"Comment"`
- Created *time.Time `json:"Created"`
- Config *v1.ImageConfig `json:"Config"`
- Version string `json:"Version"`
- Author string `json:"Author"`
- Architecture string `json:"Architecture"`
- Os string `json:"Os"`
- Size int64 `json:"Size"`
- VirtualSize int64 `json:"VirtualSize"`
- GraphDriver *Data `json:"GraphDriver"`
- RootFS *RootFS `json:"RootFS"`
- Labels map[string]string `json:"Labels"`
- Annotations map[string]string `json:"Annotations"`
+ ID string `json:"Id"`
+ Digest digest.Digest `json:"Digest"`
+ RepoTags []string `json:"RepoTags"`
+ RepoDigests []string `json:"RepoDigests"`
+ Parent string `json:"Parent"`
+ Comment string `json:"Comment"`
+ Created *time.Time `json:"Created"`
+ ContainerConfig *v1.ImageConfig `json:"ContainerConfig"`
+ Version string `json:"Version"`
+ Author string `json:"Author"`
+ Architecture string `json:"Architecture"`
+ Os string `json:"Os"`
+ Size int64 `json:"Size"`
+ VirtualSize int64 `json:"VirtualSize"`
+ GraphDriver *Data `json:"GraphDriver"`
+ RootFS *RootFS `json:"RootFS"`
+ Labels map[string]string `json:"Labels"`
+ Annotations map[string]string `json:"Annotations"`
}
// RootFS holds the root fs information of an image
diff --git a/test/e2e/import_test.go b/test/e2e/import_test.go
index 448a89539..ed90ede0f 100644
--- a/test/e2e/import_test.go
+++ b/test/e2e/import_test.go
@@ -101,7 +101,7 @@ var _ = Describe("Podman import", func() {
results.WaitWithDefaultTimeout()
Expect(results.ExitCode()).To(Equal(0))
imageData := results.InspectImageJSON()
- Expect(imageData.Config.Cmd[0]).To(Equal("/bin/bash"))
+ Expect(imageData.ContainerConfig.Cmd[0]).To(Equal("/bin/bash"))
})
})