From 2d9f1e95eb00242751ff0d9655bb513c27173475 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Mon, 24 Jun 2019 14:08:25 -0400 Subject: 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 --- cmd/podman/inspect.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'cmd') 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 { -- cgit v1.2.3-54-g00ecf