mirror of https://github.com/containers/podman.git
Merge pull request #6482 from mheon/split_inspect
Ensure that image/container inspect are specialized
This commit is contained in:
commit
a3f2a8d73c
|
@ -26,9 +26,15 @@ func init() {
|
|||
Command: inspectCmd,
|
||||
Parent: containerCmd,
|
||||
})
|
||||
inspectOpts = inspect.AddInspectFlagSet(inspectCmd)
|
||||
inspectOpts = new(entities.InspectOptions)
|
||||
flags := inspectCmd.Flags()
|
||||
flags.BoolVarP(&inspectOpts.Size, "size", "s", false, "Display total file size")
|
||||
flags.StringVarP(&inspectOpts.Format, "format", "f", "json", "Format the output to a Go template or json")
|
||||
flags.BoolVarP(&inspectOpts.Latest, "latest", "l", false, "Act on the latest container Podman is aware of")
|
||||
}
|
||||
|
||||
func inspectExec(cmd *cobra.Command, args []string) error {
|
||||
// Force container type
|
||||
inspectOpts.Type = inspect.ContainerType
|
||||
return inspect.Inspect(args, *inspectOpts)
|
||||
}
|
||||
|
|
|
@ -27,11 +27,12 @@ func init() {
|
|||
Command: inspectCmd,
|
||||
Parent: imageCmd,
|
||||
})
|
||||
inspectOpts = inspect.AddInspectFlagSet(inspectCmd)
|
||||
inspectOpts = new(entities.InspectOptions)
|
||||
flags := inspectCmd.Flags()
|
||||
_ = flags.MarkHidden("latest") // Shared with container-inspect but not wanted here.
|
||||
flags.StringVarP(&inspectOpts.Format, "format", "f", "json", "Format the output to a Go template or json")
|
||||
}
|
||||
|
||||
func inspectExec(cmd *cobra.Command, args []string) error {
|
||||
inspectOpts.Type = inspect.ImageType
|
||||
return inspect.Inspect(args, *inspectOpts)
|
||||
}
|
||||
|
|
|
@ -178,4 +178,49 @@ var _ = Describe("Podman inspect", func() {
|
|||
session.WaitWithDefaultTimeout()
|
||||
Expect(session.ExitCode()).To(Not(Equal(0)))
|
||||
})
|
||||
|
||||
It("podman [image,container] inspect on image", func() {
|
||||
baseInspect := podmanTest.Podman([]string{"inspect", ALPINE})
|
||||
baseInspect.WaitWithDefaultTimeout()
|
||||
Expect(baseInspect.ExitCode()).To(Equal(0))
|
||||
baseJSON := baseInspect.InspectImageJSON()
|
||||
Expect(len(baseJSON)).To(Equal(1))
|
||||
|
||||
ctrInspect := podmanTest.Podman([]string{"container", "inspect", ALPINE})
|
||||
ctrInspect.WaitWithDefaultTimeout()
|
||||
Expect(ctrInspect.ExitCode()).To(Not(Equal(0)))
|
||||
|
||||
imageInspect := podmanTest.Podman([]string{"image", "inspect", ALPINE})
|
||||
imageInspect.WaitWithDefaultTimeout()
|
||||
Expect(imageInspect.ExitCode()).To(Equal(0))
|
||||
imageJSON := imageInspect.InspectImageJSON()
|
||||
Expect(len(imageJSON)).To(Equal(1))
|
||||
|
||||
Expect(baseJSON[0].ID).To(Equal(imageJSON[0].ID))
|
||||
})
|
||||
|
||||
It("podman [image, container] inspect on container", func() {
|
||||
ctrName := "testCtr"
|
||||
create := podmanTest.Podman([]string{"create", "--name", ctrName, ALPINE, "sh"})
|
||||
create.WaitWithDefaultTimeout()
|
||||
Expect(create.ExitCode()).To(Equal(0))
|
||||
|
||||
baseInspect := podmanTest.Podman([]string{"inspect", ctrName})
|
||||
baseInspect.WaitWithDefaultTimeout()
|
||||
Expect(baseInspect.ExitCode()).To(Equal(0))
|
||||
baseJSON := baseInspect.InspectContainerToJSON()
|
||||
Expect(len(baseJSON)).To(Equal(1))
|
||||
|
||||
ctrInspect := podmanTest.Podman([]string{"container", "inspect", ctrName})
|
||||
ctrInspect.WaitWithDefaultTimeout()
|
||||
Expect(ctrInspect.ExitCode()).To(Equal(0))
|
||||
ctrJSON := ctrInspect.InspectContainerToJSON()
|
||||
Expect(len(ctrJSON)).To(Equal(1))
|
||||
|
||||
imageInspect := podmanTest.Podman([]string{"image", "inspect", ctrName})
|
||||
imageInspect.WaitWithDefaultTimeout()
|
||||
Expect(imageInspect.ExitCode()).To(Not(Equal(0)))
|
||||
|
||||
Expect(baseJSON[0].ID).To(Equal(ctrJSON[0].ID))
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue