aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@pm.me>2019-06-24 14:08:25 -0400
committerMatthew Heon <matthew.heon@pm.me>2019-06-24 14:08:25 -0400
commit2d9f1e95eb00242751ff0d9655bb513c27173475 (patch)
treea38018210ca6c08aa34bb92211d396a6b896ae6c
parent7625d28c82595692f148d09b4e3e7a5e0c76efa0 (diff)
downloadpodman-2d9f1e95eb00242751ff0d9655bb513c27173475.tar.gz
podman-2d9f1e95eb00242751ff0d9655bb513c27173475.tar.bz2
podman-2d9f1e95eb00242751ff0d9655bb513c27173475.zip
Support aliases for .Src and .Dst in inspect .Mounts
This provides backwards compatability with 1.4.0-1.4.2 releases which name .Source and .Destination as .Src and .Dst - useful for not breaking toolbox. Also add a test. Signed-off-by: Matthew Heon <matthew.heon@pm.me>
-rw-r--r--cmd/podman/inspect.go8
-rw-r--r--test/e2e/inspect_test.go27
2 files changed, 35 insertions, 0 deletions
diff --git a/cmd/podman/inspect.go b/cmd/podman/inspect.go
index 4303c149c..24edfcb68 100644
--- a/cmd/podman/inspect.go
+++ b/cmd/podman/inspect.go
@@ -98,6 +98,14 @@ func inspectCmd(c *cliconfig.InspectValues) error {
if strings.Contains(outputFormat, "{{.Id}}") {
outputFormat = strings.Replace(outputFormat, "{{.Id}}", formats.IDString, -1)
}
+ // These fields were renamed, so we need to provide backward compat for
+ // the old names.
+ if strings.Contains(outputFormat, ".Src") {
+ outputFormat = strings.Replace(outputFormat, ".Src", ".Source", -1)
+ }
+ if strings.Contains(outputFormat, ".Dst") {
+ outputFormat = strings.Replace(outputFormat, ".Dst", ".Destination", -1)
+ }
if latestContainer {
lc, err := runtime.GetLatestContainer()
if err != nil {
diff --git a/test/e2e/inspect_test.go b/test/e2e/inspect_test.go
index ccd8602c4..790115133 100644
--- a/test/e2e/inspect_test.go
+++ b/test/e2e/inspect_test.go
@@ -107,4 +107,31 @@ var _ = Describe("Podman inspect", func() {
Expect(result.ExitCode()).To(Equal(125))
})
+ It("podman inspect with mount filters", func() {
+ SkipIfRemote()
+
+ ctrSession := podmanTest.Podman([]string{"create", "-v", "/tmp:/test1", ALPINE, "top"})
+ ctrSession.WaitWithDefaultTimeout()
+ Expect(ctrSession.ExitCode()).To(Equal(0))
+
+ inspectSource := podmanTest.Podman([]string{"inspect", "-l", "--format", "{{(index .Mounts 0).Source}}"})
+ inspectSource.WaitWithDefaultTimeout()
+ Expect(inspectSource.ExitCode()).To(Equal(0))
+ Expect(inspectSource.OutputToString()).To(Equal("/tmp"))
+
+ inspectSrc := podmanTest.Podman([]string{"inspect", "-l", "--format", "{{(index .Mounts 0).Src}}"})
+ inspectSrc.WaitWithDefaultTimeout()
+ Expect(inspectSrc.ExitCode()).To(Equal(0))
+ Expect(inspectSrc.OutputToString()).To(Equal("/tmp"))
+
+ inspectDestination := podmanTest.Podman([]string{"inspect", "-l", "--format", "{{(index .Mounts 0).Destination}}"})
+ inspectDestination.WaitWithDefaultTimeout()
+ Expect(inspectDestination.ExitCode()).To(Equal(0))
+ Expect(inspectDestination.OutputToString()).To(Equal("/test1"))
+
+ inspectDst := podmanTest.Podman([]string{"inspect", "-l", "--format", "{{(index .Mounts 0).Dst}}"})
+ inspectDst.WaitWithDefaultTimeout()
+ Expect(inspectDst.ExitCode()).To(Equal(0))
+ Expect(inspectDst.OutputToString()).To(Equal("/test1"))
+ })
})