summaryrefslogtreecommitdiff
path: root/cmd/podman/networks
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/networks
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/networks')
-rw-r--r--cmd/podman/networks/list.go16
1 files changed, 9 insertions, 7 deletions
diff --git a/cmd/podman/networks/list.go b/cmd/podman/networks/list.go
index 124a17d5d..6f1a7742a 100644
--- a/cmd/podman/networks/list.go
+++ b/cmd/podman/networks/list.go
@@ -84,7 +84,7 @@ func networkList(cmd *cobra.Command, args []string) error {
// table or other format output
default:
- err = templateOut(responses, cmd)
+ err = templateOut(cmd, responses)
}
return err
@@ -105,7 +105,7 @@ func jsonOut(responses []types.Network) error {
return nil
}
-func templateOut(responses []types.Network, cmd *cobra.Command) error {
+func templateOut(cmd *cobra.Command, responses []types.Network) error {
nlprs := make([]ListPrintReports, 0, len(responses))
for _, r := range responses {
nlprs = append(nlprs, ListPrintReports{r})
@@ -120,14 +120,16 @@ func templateOut(responses []types.Network, cmd *cobra.Command) error {
})
renderHeaders := report.HasTable(networkListOptions.Format)
- var row, format string
- if cmd.Flags().Changed("format") {
+ var row string
+ switch {
+ case cmd.Flags().Changed("format"):
row = report.NormalizeFormat(networkListOptions.Format)
- } else { // 'podman network ls' equivalent to 'podman network ls --format="table {{.ID}} {{.Name}} {{.Version}} {{.Plugins}}" '
- renderHeaders = true
+ default:
+ // 'podman network ls' equivalent to 'podman network ls --format="table {{.ID}} {{.Name}} {{.Version}} {{.Plugins}}" '
row = "{{.ID}}\t{{.Name}}\t{{.Driver}}\n"
+ renderHeaders = true
}
- format = report.EnforceRange(row)
+ format := report.EnforceRange(row)
tmpl, err := report.NewTemplate("list").Parse(format)
if err != nil {