diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-02-17 11:10:33 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-17 11:10:33 -0500 |
commit | 516dc6d1ff618019079bc68055dd7f6c2a447aa2 (patch) | |
tree | 85d04556ee54e886621691524c60d5e14071c0bf /cmd | |
parent | 2e522ff29cfea06a37debfc4a31a231bf7097b34 (diff) | |
parent | e2d5a1d0512abed12e0844ab33fdbf023f206c7c (diff) | |
download | podman-516dc6d1ff618019079bc68055dd7f6c2a447aa2.tar.gz podman-516dc6d1ff618019079bc68055dd7f6c2a447aa2.tar.bz2 podman-516dc6d1ff618019079bc68055dd7f6c2a447aa2.zip |
Merge pull request #9409 from rhatdan/size
podman ps --format '{{ .Size }}' requires --size option
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/podman/containers/ps.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/cmd/podman/containers/ps.go b/cmd/podman/containers/ps.go index 51e7bf5b5..55b53b4d9 100644 --- a/cmd/podman/containers/ps.go +++ b/cmd/podman/containers/ps.go @@ -22,6 +22,7 @@ import ( "github.com/cri-o/ocicni/pkg/ocicni" "github.com/docker/go-units" "github.com/pkg/errors" + "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -390,6 +391,11 @@ func (l psReporter) Command() string { // Size returns the rootfs and virtual sizes in human duration in // and output form (string) suitable for ps func (l psReporter) Size() string { + if l.ListContainer.Size == nil { + logrus.Errorf("Size format requires --size option") + return "" + } + virt := units.HumanSizeWithPrecision(float64(l.ListContainer.Size.RootFsSize), 3) s := units.HumanSizeWithPrecision(float64(l.ListContainer.Size.RwSize), 3) return fmt.Sprintf("%s (virtual %s)", s, virt) |