From 58dc1713764f1895a7f112580665bdec13e8d7b1 Mon Sep 17 00:00:00 2001 From: Olivier Gerbron Date: Mon, 20 Jan 2020 10:27:03 +0100 Subject: [PATCH] Delete headers for list-images and list-workloads --- cmd/fluxctl/list_images_cmd.go | 13 +++++++++---- cmd/fluxctl/list_workloads_cmd.go | 7 ++++++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/cmd/fluxctl/list_images_cmd.go b/cmd/fluxctl/list_images_cmd.go index 42727ec653..a59fda2e4a 100644 --- a/cmd/fluxctl/list_images_cmd.go +++ b/cmd/fluxctl/list_images_cmd.go @@ -17,9 +17,10 @@ import ( type imageListOpts struct { *rootOpts - namespace string - workload string - limit int + namespace string + workload string + limit int + noHeaders bool // Deprecated controller string @@ -39,6 +40,7 @@ func (opts *imageListOpts) Command() *cobra.Command { cmd.Flags().StringVarP(&opts.namespace, "namespace", "n", "", "Namespace") cmd.Flags().StringVarP(&opts.workload, "workload", "w", "", "Show images for this workload") cmd.Flags().IntVarP(&opts.limit, "limit", "l", 10, "Number of images to show (0 for all)") + cmd.Flags().BoolVar(&opts.noHeaders, "no-headers", false, "Don't print headers (default print headers)") // Deprecated cmd.Flags().StringVarP(&opts.controller, "controller", "c", "", "Show images for this controller") @@ -83,7 +85,10 @@ func (opts *imageListOpts) RunE(cmd *cobra.Command, args []string) error { out := newTabwriter() - fmt.Fprintln(out, "WORKLOAD\tCONTAINER\tIMAGE\tCREATED") + if !opts.noHeaders { + fmt.Fprintln(out, "WORKLOAD\tCONTAINER\tIMAGE\tCREATED") + } + for _, workload := range workloads { if len(workload.Containers) == 0 { fmt.Fprintf(out, "%s\t\t\t\n", workload.ID) diff --git a/cmd/fluxctl/list_workloads_cmd.go b/cmd/fluxctl/list_workloads_cmd.go index 78dfb3deb9..722dae19d9 100644 --- a/cmd/fluxctl/list_workloads_cmd.go +++ b/cmd/fluxctl/list_workloads_cmd.go @@ -16,6 +16,7 @@ type workloadListOpts struct { *rootOpts namespace string allNamespaces bool + noHeaders bool } func newWorkloadList(parent *rootOpts) *workloadListOpts { @@ -32,6 +33,7 @@ func (opts *workloadListOpts) Command() *cobra.Command { } cmd.Flags().StringVarP(&opts.namespace, "namespace", "n", "", "Confine query to namespace") cmd.Flags().BoolVarP(&opts.allNamespaces, "all-namespaces", "a", false, "Query across all namespaces") + cmd.Flags().BoolVar(&opts.noHeaders, "no-headers", false, "Don't print headers (default print headers)") return cmd } @@ -57,7 +59,10 @@ func (opts *workloadListOpts) RunE(cmd *cobra.Command, args []string) error { sort.Sort(workloadStatusByName(workloads)) w := newTabwriter() - fmt.Fprintf(w, "WORKLOAD\tCONTAINER\tIMAGE\tRELEASE\tPOLICY\n") + if !opts.noHeaders { + fmt.Fprintf(w, "WORKLOAD\tCONTAINER\tIMAGE\tRELEASE\tPOLICY\n") + } + for _, workload := range workloads { if len(workload.Containers) > 0 { c := workload.Containers[0]