mirror of https://github.com/containers/podman.git
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
This commit is contained in:
parent
d26266659d
commit
2e96acf300
|
@ -520,12 +520,12 @@ func parseCreateOpts(c *cli.Context, runtime *libpod.Runtime, imageName string,
|
||||||
// USER
|
// USER
|
||||||
user := c.String("user")
|
user := c.String("user")
|
||||||
if user == "" {
|
if user == "" {
|
||||||
user = data.Config.User
|
user = data.ContainerConfig.User
|
||||||
}
|
}
|
||||||
|
|
||||||
// STOP SIGNAL
|
// STOP SIGNAL
|
||||||
stopSignal := syscall.SIGTERM
|
stopSignal := syscall.SIGTERM
|
||||||
signalString := data.Config.StopSignal
|
signalString := data.ContainerConfig.StopSignal
|
||||||
if c.IsSet("stop-signal") {
|
if c.IsSet("stop-signal") {
|
||||||
signalString = c.String("stop-signal")
|
signalString = c.String("stop-signal")
|
||||||
}
|
}
|
||||||
|
@ -538,7 +538,7 @@ func parseCreateOpts(c *cli.Context, runtime *libpod.Runtime, imageName string,
|
||||||
|
|
||||||
// ENVIRONMENT VARIABLES
|
// ENVIRONMENT VARIABLES
|
||||||
env := defaultEnvVariables
|
env := defaultEnvVariables
|
||||||
for _, e := range data.Config.Env {
|
for _, e := range data.ContainerConfig.Env {
|
||||||
split := strings.SplitN(e, "=", 2)
|
split := strings.SplitN(e, "=", 2)
|
||||||
if len(split) > 1 {
|
if len(split) > 1 {
|
||||||
env[split[0]] = split[1]
|
env[split[0]] = split[1]
|
||||||
|
@ -555,7 +555,7 @@ func parseCreateOpts(c *cli.Context, runtime *libpod.Runtime, imageName string,
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "unable to process labels")
|
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 {
|
if _, ok := labels[key]; !ok {
|
||||||
labels[key] = val
|
labels[key] = val
|
||||||
}
|
}
|
||||||
|
@ -564,14 +564,14 @@ func parseCreateOpts(c *cli.Context, runtime *libpod.Runtime, imageName string,
|
||||||
// WORKING DIRECTORY
|
// WORKING DIRECTORY
|
||||||
workDir := c.String("workdir")
|
workDir := c.String("workdir")
|
||||||
if workDir == "" {
|
if workDir == "" {
|
||||||
workDir = data.Config.WorkingDir
|
workDir = data.ContainerConfig.WorkingDir
|
||||||
}
|
}
|
||||||
|
|
||||||
// ENTRYPOINT
|
// ENTRYPOINT
|
||||||
// User input entrypoint takes priority over image entrypoint
|
// User input entrypoint takes priority over image entrypoint
|
||||||
entrypoint := c.StringSlice("entrypoint")
|
entrypoint := c.StringSlice("entrypoint")
|
||||||
if len(entrypoint) == 0 {
|
if len(entrypoint) == 0 {
|
||||||
entrypoint = data.Config.Entrypoint
|
entrypoint = data.ContainerConfig.Entrypoint
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build the command
|
// Build the command
|
||||||
|
@ -582,13 +582,13 @@ func parseCreateOpts(c *cli.Context, runtime *libpod.Runtime, imageName string,
|
||||||
if len(inputCommand) > 0 {
|
if len(inputCommand) > 0 {
|
||||||
// User command overrides data CMD
|
// User command overrides data CMD
|
||||||
command = append(command, inputCommand...)
|
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
|
// If not user command, add CMD
|
||||||
command = append(command, data.Config.Cmd...)
|
command = append(command, data.ContainerConfig.Cmd...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// EXPOSED PORTS
|
// EXPOSED PORTS
|
||||||
portBindings, err := exposedPorts(c, data.Config.ExposedPorts)
|
portBindings, err := exposedPorts(c, data.ContainerConfig.ExposedPorts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,6 +78,10 @@ func inspectCmd(c *cli.Context) error {
|
||||||
inspectType = inspectTypeContainer
|
inspectType = inspectTypeContainer
|
||||||
}
|
}
|
||||||
outputFormat := c.String("format")
|
outputFormat := c.String("format")
|
||||||
|
if strings.Contains(outputFormat, "{{.Id}}") {
|
||||||
|
outputFormat = strings.Replace(outputFormat, "{{.Id}}", formats.IDString, -1)
|
||||||
|
}
|
||||||
|
|
||||||
var data interface{}
|
var data interface{}
|
||||||
switch inspectType {
|
switch inspectType {
|
||||||
case inspectTypeContainer:
|
case inspectTypeContainer:
|
||||||
|
|
|
@ -36,15 +36,15 @@ func generateAlpineImageData() *inspect.ImageData {
|
||||||
}
|
}
|
||||||
|
|
||||||
data := &inspect.ImageData{
|
data := &inspect.ImageData{
|
||||||
ID: "e21c333399e0aeedfd70e8827c9fba3f8e9b170ef8a48a29945eb7702bf6aa5f",
|
ID: "e21c333399e0aeedfd70e8827c9fba3f8e9b170ef8a48a29945eb7702bf6aa5f",
|
||||||
RepoTags: []string{"docker.io/library/alpine:latest"},
|
RepoTags: []string{"docker.io/library/alpine:latest"},
|
||||||
RepoDigests: []string{"docker.io/library/alpine@sha256:5cb04fce748f576d7b72a37850641de8bd725365519673c643ef2d14819b42c6"},
|
RepoDigests: []string{"docker.io/library/alpine@sha256:5cb04fce748f576d7b72a37850641de8bd725365519673c643ef2d14819b42c6"},
|
||||||
Comment: "Created:2017-12-01 18:48:48.949613376 +0000",
|
Comment: "Created:2017-12-01 18:48:48.949613376 +0000",
|
||||||
Author: "",
|
Author: "",
|
||||||
Architecture: "amd64",
|
Architecture: "amd64",
|
||||||
Os: "linux",
|
Os: "linux",
|
||||||
Version: "17.06.2-ce",
|
Version: "17.06.2-ce",
|
||||||
Config: config,
|
ContainerConfig: config,
|
||||||
}
|
}
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ Display the total file size if the type is a container
|
||||||
"Parent": "",
|
"Parent": "",
|
||||||
"Comment": "",
|
"Comment": "",
|
||||||
"Created": "2017-11-14T21:07:08.475840838Z",
|
"Created": "2017-11-14T21:07:08.475840838Z",
|
||||||
"Config": {
|
"ContainerConfig": {
|
||||||
"Env": [
|
"Env": [
|
||||||
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
||||||
"DISTTAG=f27container",
|
"DISTTAG=f27container",
|
||||||
|
|
|
@ -42,21 +42,21 @@ func getImageData(img storage.Image, imgRef types.Image, size int64, driver *ins
|
||||||
}
|
}
|
||||||
|
|
||||||
data := &inspect.ImageData{
|
data := &inspect.ImageData{
|
||||||
ID: img.ID,
|
ID: img.ID,
|
||||||
RepoTags: img.Names,
|
RepoTags: img.Names,
|
||||||
RepoDigests: repoDigests,
|
RepoDigests: repoDigests,
|
||||||
Comment: ociv1Img.History[0].Comment,
|
Comment: ociv1Img.History[0].Comment,
|
||||||
Created: ociv1Img.Created,
|
Created: ociv1Img.Created,
|
||||||
Author: ociv1Img.Author,
|
Author: ociv1Img.Author,
|
||||||
Architecture: ociv1Img.Architecture,
|
Architecture: ociv1Img.Architecture,
|
||||||
Os: ociv1Img.OS,
|
Os: ociv1Img.OS,
|
||||||
Config: &ociv1Img.Config,
|
ContainerConfig: &ociv1Img.Config,
|
||||||
Version: info.DockerVersion,
|
Version: info.DockerVersion,
|
||||||
Size: size,
|
Size: size,
|
||||||
VirtualSize: size + imgSize,
|
VirtualSize: size + imgSize,
|
||||||
Annotations: annotations,
|
Annotations: annotations,
|
||||||
Digest: imgDigest,
|
Digest: imgDigest,
|
||||||
Labels: info.Labels,
|
Labels: info.Labels,
|
||||||
RootFS: &inspect.RootFS{
|
RootFS: &inspect.RootFS{
|
||||||
Type: ociv1Img.RootFS.Type,
|
Type: ociv1Img.RootFS.Type,
|
||||||
Layers: ociv1Img.RootFS.DiffIDs,
|
Layers: ociv1Img.RootFS.DiffIDs,
|
||||||
|
|
|
@ -106,24 +106,24 @@ type LogConfig struct {
|
||||||
|
|
||||||
// ImageData holds the inspect information of an image
|
// ImageData holds the inspect information of an image
|
||||||
type ImageData struct {
|
type ImageData struct {
|
||||||
ID string `json:"ID"`
|
ID string `json:"Id"`
|
||||||
Digest digest.Digest `json:"Digest"`
|
Digest digest.Digest `json:"Digest"`
|
||||||
RepoTags []string `json:"RepoTags"`
|
RepoTags []string `json:"RepoTags"`
|
||||||
RepoDigests []string `json:"RepoDigests"`
|
RepoDigests []string `json:"RepoDigests"`
|
||||||
Parent string `json:"Parent"`
|
Parent string `json:"Parent"`
|
||||||
Comment string `json:"Comment"`
|
Comment string `json:"Comment"`
|
||||||
Created *time.Time `json:"Created"`
|
Created *time.Time `json:"Created"`
|
||||||
Config *v1.ImageConfig `json:"Config"`
|
ContainerConfig *v1.ImageConfig `json:"ContainerConfig"`
|
||||||
Version string `json:"Version"`
|
Version string `json:"Version"`
|
||||||
Author string `json:"Author"`
|
Author string `json:"Author"`
|
||||||
Architecture string `json:"Architecture"`
|
Architecture string `json:"Architecture"`
|
||||||
Os string `json:"Os"`
|
Os string `json:"Os"`
|
||||||
Size int64 `json:"Size"`
|
Size int64 `json:"Size"`
|
||||||
VirtualSize int64 `json:"VirtualSize"`
|
VirtualSize int64 `json:"VirtualSize"`
|
||||||
GraphDriver *Data `json:"GraphDriver"`
|
GraphDriver *Data `json:"GraphDriver"`
|
||||||
RootFS *RootFS `json:"RootFS"`
|
RootFS *RootFS `json:"RootFS"`
|
||||||
Labels map[string]string `json:"Labels"`
|
Labels map[string]string `json:"Labels"`
|
||||||
Annotations map[string]string `json:"Annotations"`
|
Annotations map[string]string `json:"Annotations"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// RootFS holds the root fs information of an image
|
// RootFS holds the root fs information of an image
|
||||||
|
|
|
@ -101,7 +101,7 @@ var _ = Describe("Podman import", func() {
|
||||||
results.WaitWithDefaultTimeout()
|
results.WaitWithDefaultTimeout()
|
||||||
Expect(results.ExitCode()).To(Equal(0))
|
Expect(results.ExitCode()).To(Equal(0))
|
||||||
imageData := results.InspectImageJSON()
|
imageData := results.InspectImageJSON()
|
||||||
Expect(imageData.Config.Cmd[0]).To(Equal("/bin/bash"))
|
Expect(imageData.ContainerConfig.Cmd[0]).To(Equal("/bin/bash"))
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue