diff options
author | zhangguanzhang <zhangguanzhang@qq.com> | 2020-07-31 00:22:32 +0800 |
---|---|---|
committer | zhangguanzhang <zhangguanzhang@qq.com> | 2020-07-31 01:40:42 +0800 |
commit | b4fa2c2517fd313bb0000f7697274d2ab2498265 (patch) | |
tree | 33e8ed413795ab584b2559cccb353a58d8855d6d | |
parent | 05b3e0e16bbbfede19bc5d817c62598e1ac6fa70 (diff) | |
download | podman-b4fa2c2517fd313bb0000f7697274d2ab2498265.tar.gz podman-b4fa2c2517fd313bb0000f7697274d2ab2498265.tar.bz2 podman-b4fa2c2517fd313bb0000f7697274d2ab2498265.zip |
fix podman system df format error
Signed-off-by: zhangguanzhang <zhangguanzhang@qq.com>
-rw-r--r-- | cmd/podman/system/df.go | 9 | ||||
-rw-r--r-- | test/system/320-system-df.bats | 7 |
2 files changed, 13 insertions, 3 deletions
diff --git a/cmd/podman/system/df.go b/cmd/podman/system/df.go index a320eb5c7..03991101e 100644 --- a/cmd/podman/system/df.go +++ b/cmd/podman/system/df.go @@ -4,6 +4,7 @@ import ( "fmt" "io" "os" + "strconv" "strings" "text/tabwriter" "text/template" @@ -69,6 +70,14 @@ func printSummary(reports *entities.SystemDfReport, userFormat string) error { // Images if len(userFormat) > 0 { + if !strings.HasSuffix(userFormat, `\n`) { + userFormat += `\n` + } + // should be Unquoto from cmd line + userFormat, err := strconv.Unquote(`"` + userFormat + `"`) + if err != nil { + return err + } format = userFormat } diff --git a/test/system/320-system-df.bats b/test/system/320-system-df.bats index a96507448..217357b37 100644 --- a/test/system/320-system-df.bats +++ b/test/system/320-system-df.bats @@ -24,9 +24,10 @@ function teardown() { run_podman run -d -v /myvol2 --name c2 $IMAGE \ sh -c 'while ! test -e /stop; do sleep 0.1;done' - run_podman system df --format '{{ .Type }}:{{ .Total }}:{{ .Active }}--' - # FIXME: if/when #7149 gets fixed, split this into three tests (i.e. test "${lines[0]}", [1], [2] ) - is "$output" "Images:1:1--Containers:2:1--Local Volumes:2:1--" + run_podman system df --format '{{ .Type }}:{{ .Total }}:{{ .Active }}' + is "${lines[0]}" "Images:1:1" "system df : Images line" + is "${lines[1]}" "Containers:2:1" "system df : Containers line" + is "${lines[2]}" "Local Volumes:2:1" "system df : Volumes line" # Try -v. (Grrr. No way to specify individual formats) # |