mirror of
https://github.com/podman-container-tools/podman.git
synced 2026-10-26 07:47:38 +00:00
Merge pull request #29541 from The-indigo/no-heading
Added implementation for --noheading option for podman farm list
This commit is contained in:
commit
fbb90e15b0
5 changed files with 28 additions and 3 deletions
|
|
@ -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",
|
||||
|
|
|
|||
1
docs/source/markdown/.gitignore
vendored
1
docs/source/markdown/.gitignore
vendored
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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**
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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" {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue