aboutsummaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-04-21 13:20:36 -0400
committerGitHub <noreply@github.com>2021-04-21 13:20:36 -0400
commit897f6c3a4a55bfc82a989c81cb3dc8998965c408 (patch)
tree2b257f4fbd123bdea9196af0e38b0ff77228be13 /cmd/podman
parent544c3156657e078cef297623842f79cb72dc32c6 (diff)
parent8ebeadc3c68d0291e9de6ce4b6fedf17f362129f (diff)
downloadpodman-897f6c3a4a55bfc82a989c81cb3dc8998965c408.tar.gz
podman-897f6c3a4a55bfc82a989c81cb3dc8998965c408.tar.bz2
podman-897f6c3a4a55bfc82a989c81cb3dc8998965c408.zip
Merge pull request #10088 from rhatdan/no-headers
Add --noheading flag to all list commands
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/containers/ps.go4
-rw-r--r--cmd/podman/machine/list.go1
-rw-r--r--cmd/podman/networks/list.go4
-rw-r--r--cmd/podman/pods/ps.go5
-rw-r--r--cmd/podman/secrets/list.go1
-rw-r--r--cmd/podman/volumes/list.go4
6 files changed, 16 insertions, 3 deletions
diff --git a/cmd/podman/containers/ps.go b/cmd/podman/containers/ps.go
index 70bfd3574..97451eb46 100644
--- a/cmd/podman/containers/ps.go
+++ b/cmd/podman/containers/ps.go
@@ -97,6 +97,7 @@ func listFlagSet(cmd *cobra.Command) {
flags.BoolVar(&noTrunc, "no-trunc", false, "Display the extended information")
flags.BoolVarP(&listOpts.Pod, "pod", "p", false, "Print the ID and name of the pod the containers are associated with")
flags.BoolVarP(&listOpts.Quiet, "quiet", "q", false, "Print the numeric IDs of the containers only")
+ flags.Bool("noheading", false, "Do not print headers")
flags.BoolVarP(&listOpts.Size, "size", "s", false, "Display the total file sizes")
flags.BoolVar(&listOpts.Sync, "sync", false, "Sync container state with OCI runtime")
@@ -242,7 +243,8 @@ func ps(cmd *cobra.Command, _ []string) error {
defer w.Flush()
headers := func() error { return nil }
- if !(listOpts.Quiet || cmd.Flags().Changed("format")) {
+ noHeading, _ := cmd.Flags().GetBool("noheading")
+ if !(noHeading || listOpts.Quiet || cmd.Flags().Changed("format")) {
headers = func() error {
return tmpl.Execute(w, hdrs)
}
diff --git a/cmd/podman/machine/list.go b/cmd/podman/machine/list.go
index ce4129e87..af4e2c807 100644
--- a/cmd/podman/machine/list.go
+++ b/cmd/podman/machine/list.go
@@ -61,6 +61,7 @@ func init() {
formatFlagName := "format"
flags.StringVar(&listFlag.format, formatFlagName, "{{.Name}}\t{{.VMType}}\t{{.Created}}\t{{.LastUp}}\n", "Format volume output using Go template")
_ = lsCmd.RegisterFlagCompletionFunc(formatFlagName, completion.AutocompleteNone)
+ flags.BoolVar(&listFlag.noHeading, "noheading", false, "Do not print headers")
}
func list(cmd *cobra.Command, args []string) error {
diff --git a/cmd/podman/networks/list.go b/cmd/podman/networks/list.go
index fcbcb6722..bc100da8c 100644
--- a/cmd/podman/networks/list.go
+++ b/cmd/podman/networks/list.go
@@ -48,6 +48,7 @@ func networkListFlags(flags *pflag.FlagSet) {
filterFlagName := "filter"
flags.StringArrayVarP(&filters, filterFlagName, "f", nil, "Provide filter values (e.g. 'name=podman')")
+ flags.Bool("noheading", false, "Do not print headers")
_ = networklistCommand.RegisterFlagCompletionFunc(filterFlagName, common.AutocompleteNetworkFilters)
}
@@ -140,7 +141,8 @@ func templateOut(responses []*entities.NetworkListReport, cmd *cobra.Command) er
w := tabwriter.NewWriter(os.Stdout, 8, 2, 2, ' ', 0)
defer w.Flush()
- if renderHeaders {
+ noHeading, _ := cmd.Flags().GetBool("noheading")
+ if !noHeading && renderHeaders {
if err := tmpl.Execute(w, headers); err != nil {
return err
}
diff --git a/cmd/podman/pods/ps.go b/cmd/podman/pods/ps.go
index aeba80525..a4b6d1afa 100644
--- a/cmd/podman/pods/ps.go
+++ b/cmd/podman/pods/ps.go
@@ -63,6 +63,7 @@ func init() {
flags.StringVar(&psInput.Format, formatFlagName, "", "Pretty-print pods to JSON or using a Go template")
_ = psCmd.RegisterFlagCompletionFunc(formatFlagName, common.AutocompleteJSONFormat)
+ flags.Bool("noheading", false, "Do not print headers")
flags.BoolVar(&psInput.Namespace, "namespace", false, "Display namespace information of the pod")
flags.BoolVar(&psInput.Namespace, "ns", false, "Display namespace information of the pod")
flags.BoolVar(&noTrunc, "no-trunc", false, "Do not truncate pod and container IDs")
@@ -134,6 +135,10 @@ func pods(cmd *cobra.Command, _ []string) error {
renderHeaders = parse.HasTable(psInput.Format)
row = report.NormalizeFormat(psInput.Format)
}
+ noHeading, _ := cmd.Flags().GetBool("noheading")
+ if noHeading {
+ renderHeaders = false
+ }
format := parse.EnforceRange(row)
tmpl, err := template.New("listPods").Parse(format)
diff --git a/cmd/podman/secrets/list.go b/cmd/podman/secrets/list.go
index 849a8418e..2006fb0ee 100644
--- a/cmd/podman/secrets/list.go
+++ b/cmd/podman/secrets/list.go
@@ -48,6 +48,7 @@ func init() {
formatFlagName := "format"
flags.StringVar(&listFlag.format, formatFlagName, "{{.ID}}\t{{.Name}}\t{{.Driver}}\t{{.CreatedAt}}\t{{.UpdatedAt}}\t\n", "Format volume output using Go template")
_ = lsCmd.RegisterFlagCompletionFunc(formatFlagName, common.AutocompleteJSONFormat)
+ flags.BoolVar(&listFlag.noHeading, "noheading", false, "Do not print headers")
}
func ls(cmd *cobra.Command, args []string) error {
diff --git a/cmd/podman/volumes/list.go b/cmd/podman/volumes/list.go
index e04f452d4..0d764e988 100644
--- a/cmd/podman/volumes/list.go
+++ b/cmd/podman/volumes/list.go
@@ -62,6 +62,7 @@ func init() {
flags.StringVar(&cliOpts.Format, formatFlagName, "{{.Driver}}\t{{.Name}}\n", "Format volume output using Go template")
_ = lsCommand.RegisterFlagCompletionFunc(formatFlagName, common.AutocompleteJSONFormat)
+ flags.Bool("noheading", false, "Do not print headers")
flags.BoolVarP(&cliOpts.Quiet, "quiet", "q", false, "Print volume output in quiet mode")
}
@@ -94,6 +95,7 @@ func list(cmd *cobra.Command, args []string) error {
}
func outputTemplate(cmd *cobra.Command, responses []*entities.VolumeListReport) error {
+ noHeading, _ := cmd.Flags().GetBool("noheading")
headers := report.Headers(entities.VolumeListReport{}, map[string]string{
"Name": "VOLUME NAME",
})
@@ -111,7 +113,7 @@ func outputTemplate(cmd *cobra.Command, responses []*entities.VolumeListReport)
w := tabwriter.NewWriter(os.Stdout, 12, 2, 2, ' ', 0)
defer w.Flush()
- if !cliOpts.Quiet && !cmd.Flag("format").Changed {
+ if !(noHeading || cliOpts.Quiet || cmd.Flag("format").Changed) {
if err := tmpl.Execute(w, headers); err != nil {
return errors.Wrapf(err, "failed to write report column headers")
}