summaryrefslogtreecommitdiff
path: root/cmd/podman/images/mount.go
diff options
context:
space:
mode:
authorJhon Honce <jhonce@redhat.com>2021-11-18 09:03:00 -0700
committerJhon Honce <jhonce@redhat.com>2021-12-02 09:07:27 -0700
commit61792de36ea2ea98f6e3aef3821d1b15beebf9e0 (patch)
treef2e73122b2cdb0323e1d38792eef44a625b85d10 /cmd/podman/images/mount.go
parentfbcebcb46a2444ce078dee10d8d51555bee8f177 (diff)
downloadpodman-61792de36ea2ea98f6e3aef3821d1b15beebf9e0.tar.gz
podman-61792de36ea2ea98f6e3aef3821d1b15beebf9e0.tar.bz2
podman-61792de36ea2ea98f6e3aef3821d1b15beebf9e0.zip
Refactor podman image command output
Leverage new report.Formatter allowing better compatibility from podman command output. Follow on PR's will cover containers, etc. See #10974 Signed-off-by: Jhon Honce <jhonce@redhat.com>
Diffstat (limited to 'cmd/podman/images/mount.go')
-rw-r--r--cmd/podman/images/mount.go15
1 files changed, 4 insertions, 11 deletions
diff --git a/cmd/podman/images/mount.go b/cmd/podman/images/mount.go
index 89c00cb70..cdeb9eecf 100644
--- a/cmd/podman/images/mount.go
+++ b/cmd/podman/images/mount.go
@@ -87,7 +87,7 @@ func mount(cmd *cobra.Command, args []string) error {
case report.IsJSON(mountOpts.Format):
return printJSON(reports)
case mountOpts.Format == "":
- break // default format
+ break // see default format below
default:
return errors.Errorf("unknown --format argument: %q", mountOpts.Format)
}
@@ -97,19 +97,12 @@ func mount(cmd *cobra.Command, args []string) error {
mrs = append(mrs, mountReporter{r})
}
- row := "{{range . }}{{.ID}}\t{{.Path}}\n{{end -}}"
- tmpl, err := report.NewTemplate("mounts").Parse(row)
+ rpt, err := report.New(os.Stdout, cmd.Name()).Parse(report.OriginPodman, "{{range . }}{{.ID}}\t{{.Path}}\n{{end -}}")
if err != nil {
return err
}
-
- w, err := report.NewWriterDefault(os.Stdout)
- if err != nil {
- return err
- }
- defer w.Flush()
-
- return tmpl.Execute(w, mrs)
+ defer rpt.Flush()
+ return rpt.Execute(mrs)
}
func printJSON(reports []*entities.ImageMountReport) error {