Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix podman system df format error #7156

Merged
merged 1 commit into from
Jul 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions cmd/podman/system/df.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"io"
"os"
"strconv"
"strings"
"text/tabwriter"
"text/template"
Expand Down Expand Up @@ -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
}

Expand Down
7 changes: 4 additions & 3 deletions test/system/320-system-df.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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)
#
Expand Down