Merge pull request #29541 from The-indigo/no-heading

Added implementation for --noheading option for podman farm list
This commit is contained in:
Matt Heon 2026-08-21 17:35:21 -04:00 • committed by GitHub
commit fbb90e15b0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 28 additions and 3 deletions

View file

@ -51,13 +51,14 @@ func init() {
_ = lsCommand.RegisterFlagCompletionFunc(formatFlagName, common.AutocompleteFormat(&config.Farm{}))
flags.BoolVarP(&lsOpts.Quiet, "quiet", "q", false, "Print farm names only")
flags.BoolP("noheading", "n", false, "Do not print headers")
}
func list(cmd *cobra.Command, args []string) error {
if lsOpts.Quiet && cmd.Flag("format").Changed {
return errors.New("quiet and format flags cannot be used together")
}
noHeading, _ := cmd.Flags().GetBool("noheading")
format := lsOpts.Format
if format == "" && len(args) > 0 {
format = "json"
@ -96,7 +97,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",

View file

@ -14,6 +14,7 @@ podman-create.1.md
podman-diff.1.md
podman-exec.1.md
podman-farm-build.1.md
podman-farm-list.1.md
podman-image-sign.1.md
podman-image-trust.1.md
podman-images.1.md

View file

@ -1,5 +1,5 @@
####> This option file is used in:
####> podman artifact ls, image trust, images, machine list, network ls, pod ps, quadlet list, secret ls, volume ls
####> podman artifact ls, farm list, image trust, images, machine list, network ls, pod ps, quadlet list, secret ls, volume ls
####> If file is edited, make sure the changes
####> are applicable to all of those.
#### **--noheading**, **-n**

View file

@ -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
#### **--quiet**, **-q**
Print farm output in quiet mode. Only print the farm names.
@ -38,6 +40,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

View file

@ -9,6 +9,19 @@ load helpers.bash
run_podman farm ls
assert "$output" =~ $FARMNAME
assert "$output" =~ ${CONNECTION_NAME}
#Confirm name header present on farm list output
assert "$output" =~ "Name"
#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" {