Skip to content
Open
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
5 changes: 4 additions & 1 deletion cmd/podman/farm/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,12 @@ func init() {
formatFlagName := "format"
flags.StringVar(&lsOpts.Format, formatFlagName, "", "Format farm output using Go template")
_ = lsCommand.RegisterFlagCompletionFunc(formatFlagName, common.AutocompleteFormat(&config.Farm{}))

flags.BoolP("noheading", "n", false, "Do not print headers")
}

func list(cmd *cobra.Command, args []string) error {
noHeading, _ := cmd.Flags().GetBool("noheading")
format := lsOpts.Format
if format == "" && len(args) > 0 {
format = "json"
Expand Down Expand Up @@ -85,7 +88,7 @@ func list(cmd *cobra.Command, args []string) error {
return err
}

if rpt.RenderHeaders {
if rpt.RenderHeaders && !noHeading {
err = rpt.Execute([]map[string]string{{
"Default": "Default",
"Connections": "Connections",
Expand Down
10 changes: 10 additions & 0 deletions docs/source/markdown/podman-farm-list.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ Valid placeholders for the Go template listed below:
| .Name | Farm name |
| .ReadWrite | Indicates if this farm can be modified using the podman farm commands |

@@option noheading

## EXAMPLE

List all farms:
Expand All @@ -34,6 +36,14 @@ Name Connections Default ReadWrite
farm1 [f38 f37] false true
farm2 [f37] true true
```

List all farms without showing the headers:
```
$ podman farm list --noheading
farm1 [f38 f37] false true
farm2 [f37] true true
```

Show farms in JSON format:
```
$ podman farm list --format json
Expand Down
13 changes: 13 additions & 0 deletions test/farm/001-farm.bats
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,21 @@ load helpers.bash
run_podman farm ls
assert "$output" =~ $FARMNAME
assert "$output" =~ "test-node"

#Test the farm list output for no headers
run_podman farm ls --noheading
assert "$output" !~ "Name"
assert "$output" =~ "$FARMNAME"

#Test the farm list noheading shorthand
run_podman farm ls -n
assert "$output" !~ "Name"
assert "$output" =~ "$FARMNAME"
}




@test "farm - build on local only" {
iname="test-image-1"
empty_farm="empty-farm"
Expand Down
Loading