aboutsummaryrefslogtreecommitdiff
path: root/cmd/podman/system
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-10-30 17:00:22 +0100
committerGitHub <noreply@github.com>2020-10-30 17:00:22 +0100
commite632f3f2588d00184a50a7328d54a31ccf973708 (patch)
treee7fb78c6ae6c81a77aac78015e7a0421de6d552c /cmd/podman/system
parent6b5a94cf2831df0633cc03a28f432177c0ee1d7b (diff)
parentd60a0ddcc1784b2dd807cc8e4d4f3deb0c074171 (diff)
downloadpodman-e632f3f2588d00184a50a7328d54a31ccf973708.tar.gz
podman-e632f3f2588d00184a50a7328d54a31ccf973708.tar.bz2
podman-e632f3f2588d00184a50a7328d54a31ccf973708.zip
Merge pull request #8187 from jwhonce/wip/table
Restore --format table header support
Diffstat (limited to 'cmd/podman/system')
-rw-r--r--cmd/podman/system/df.go28
1 files changed, 9 insertions, 19 deletions
diff --git a/cmd/podman/system/df.go b/cmd/podman/system/df.go
index b11167938..fbdf274fb 100644
--- a/cmd/podman/system/df.go
+++ b/cmd/podman/system/df.go
@@ -9,6 +9,7 @@ import (
"time"
"github.com/containers/common/pkg/report"
+ "github.com/containers/podman/v2/cmd/podman/parse"
"github.com/containers/podman/v2/cmd/podman/registry"
"github.com/containers/podman/v2/cmd/podman/validate"
"github.com/containers/podman/v2/pkg/domain/entities"
@@ -55,7 +56,7 @@ func df(cmd *cobra.Command, args []string) error {
w := tabwriter.NewWriter(os.Stdout, 8, 2, 2, ' ', 0)
if dfOptions.Verbose {
- return printVerbose(cmd, w, reports)
+ return printVerbose(w, cmd, reports)
}
return printSummary(w, cmd, reports)
}
@@ -131,20 +132,16 @@ func printSummary(w *tabwriter.Writer, cmd *cobra.Command, reports *entities.Sys
"Size": "SIZE",
"Reclaimable": "RECLAIMABLE",
})
-
row := "{{.Type}}\t{{.Total}}\t{{.Active}}\t{{.Size}}\t{{.Reclaimable}}\n"
if cmd.Flags().Changed("format") {
row = report.NormalizeFormat(dfOptions.Format)
}
- row = "{{range . }}" + row + "{{end}}"
-
- return writeTemplate(cmd, w, hdrs, row, dfSummaries)
+ return writeTemplate(w, cmd, hdrs, row, dfSummaries)
}
-func printVerbose(cmd *cobra.Command, w *tabwriter.Writer, reports *entities.SystemDfReport) error {
+func printVerbose(w *tabwriter.Writer, cmd *cobra.Command, reports *entities.SystemDfReport) error {
defer w.Flush()
- // Images
fmt.Fprint(w, "Images space usage:\n\n")
// convert to dfImage for output
dfImages := make([]*dfImage, 0, len(reports.Images))
@@ -157,14 +154,11 @@ func printVerbose(cmd *cobra.Command, w *tabwriter.Writer, reports *entities.Sys
"UniqueSize": "UNIQUE SIZE",
})
imageRow := "{{.Repository}}\t{{.Tag}}\t{{.ImageID}}\t{{.Created}}\t{{.Size}}\t{{.SharedSize}}\t{{.UniqueSize}}\t{{.Containers}}\n"
- format := "{{range . }}" + imageRow + "{{end}}"
- if err := writeTemplate(cmd, w, hdrs, format, dfImages); err != nil {
+ if err := writeTemplate(w, cmd, hdrs, imageRow, dfImages); err != nil {
return nil
}
- // Containers
fmt.Fprint(w, "\nContainers space usage:\n\n")
-
// convert to dfContainers for output
dfContainers := make([]*dfContainer, 0, len(reports.Containers))
for _, d := range reports.Containers {
@@ -176,14 +170,11 @@ func printVerbose(cmd *cobra.Command, w *tabwriter.Writer, reports *entities.Sys
"RWSize": "SIZE",
})
containerRow := "{{.ContainerID}}\t{{.Image}}\t{{.Command}}\t{{.LocalVolumes}}\t{{.RWSize}}\t{{.Created}}\t{{.Status}}\t{{.Names}}\n"
- format = "{{range . }}" + containerRow + "{{end}}"
- if err := writeTemplate(cmd, w, hdrs, format, dfContainers); err != nil {
+ if err := writeTemplate(w, cmd, hdrs, containerRow, dfContainers); err != nil {
return nil
}
- // Volumes
fmt.Fprint(w, "\nLocal Volumes space usage:\n\n")
-
dfVolumes := make([]*dfVolume, 0, len(reports.Volumes))
// convert to dfVolume for output
for _, d := range reports.Volumes {
@@ -193,14 +184,13 @@ func printVerbose(cmd *cobra.Command, w *tabwriter.Writer, reports *entities.Sys
"VolumeName": "VOLUME NAME",
})
volumeRow := "{{.VolumeName}}\t{{.Links}}\t{{.Size}}\n"
- format = "{{range . }}" + volumeRow + "{{end}}"
- return writeTemplate(cmd, w, hdrs, format, dfVolumes)
+ return writeTemplate(w, cmd, hdrs, volumeRow, dfVolumes)
}
-func writeTemplate(cmd *cobra.Command, w *tabwriter.Writer, hdrs []map[string]string, format string,
- output interface{}) error {
+func writeTemplate(w *tabwriter.Writer, cmd *cobra.Command, hdrs []map[string]string, format string, output interface{}) error {
defer w.Flush()
+ format = parse.EnforceRange(format)
tmpl, err := template.New("df").Parse(format)
if err != nil {
return err