diff --git a/CHANGELOG.md b/CHANGELOG.md index f45d8576f30..7d799f70e57 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ 1. [16338](https://github.com/influxdata/influxdb/pull/16338): Add last run status to check and notification rules 1. [16340](https://github.com/influxdata/influxdb/pull/16340): Add last run status to tasks 1. [16341](https://github.com/influxdata/influxdb/pull/16341): Extend pkger apply functionality with ability to provide secrets outside of pkg +1. [16345](https://github.com/influxdata/influxdb/pull/16345): Add hide headers flag to influx cli task find cmd ### Bug Fixes diff --git a/cmd/influx/task.go b/cmd/influx/task.go index d6f57cfeb6d..7ecbc67fc6e 100644 --- a/cmd/influx/task.go +++ b/cmd/influx/task.go @@ -32,21 +32,17 @@ func taskF(cmd *cobra.Command, args []string) error { var logCmd = &cobra.Command{ Use: "log", Short: "Log related commands", - Run: logF, -} - -func logF(cmd *cobra.Command, args []string) { - cmd.Usage() + Run: func(cmd *cobra.Command, args []string) { + cmd.Usage() + }, } var runCmd = &cobra.Command{ Use: "run", Short: "Run related commands", - Run: runF, -} - -func runF(cmd *cobra.Command, args []string) { - cmd.Usage() + Run: func(cmd *cobra.Command, args []string) { + cmd.Usage() + }, } func init() { @@ -54,13 +50,10 @@ func init() { taskCmd.AddCommand(logCmd) } -// TaskCreateFlags define the Create Command -type TaskCreateFlags struct { +var taskCreateFlags struct { organization } -var taskCreateFlags TaskCreateFlags - func init() { taskCreateCmd := &cobra.Command{ Use: "create [query literal or @/path/to/query.flux]", @@ -137,16 +130,14 @@ func taskCreateF(cmd *cobra.Command, args []string) error { return nil } -// taskFindFlags define the Find Command -type TaskFindFlags struct { - user string - id string - limit int +var taskFindFlags struct { + user string + id string + limit int + headers bool organization } -var taskFindFlags TaskFindFlags - func init() { taskFindCmd := &cobra.Command{ Use: "find", @@ -158,6 +149,7 @@ func init() { taskFindCmd.Flags().StringVarP(&taskFindFlags.user, "user-id", "n", "", "task owner ID") taskFindFlags.organization.register(taskFindCmd) taskFindCmd.Flags().IntVarP(&taskFindFlags.limit, "limit", "", platform.TaskDefaultPageSize, "the number of tasks to find") + taskFindCmd.Flags().BoolVar(&taskFindFlags.headers, "headers", true, "To print the table headers; defaults true") taskCmd.AddCommand(taskFindCmd) } @@ -220,6 +212,7 @@ func taskFindF(cmd *cobra.Command, args []string) error { } w := internal.NewTabWriter(os.Stdout) + w.HideHeaders(!taskFindFlags.headers) w.WriteHeaders( "ID", "Name", @@ -246,14 +239,11 @@ func taskFindF(cmd *cobra.Command, args []string) error { return nil } -// taskUpdateFlags define the Update Command -type TaskUpdateFlags struct { +var taskUpdateFlags struct { id string status string } -var taskUpdateFlags TaskUpdateFlags - func init() { taskUpdateCmd := &cobra.Command{ Use: "update", @@ -323,13 +313,10 @@ func taskUpdateF(cmd *cobra.Command, args []string) error { return nil } -// taskDeleteFlags define the Delete command -type TaskDeleteFlags struct { +var taskDeleteFlags struct { id string } -var taskDeleteFlags TaskDeleteFlags - func init() { taskDeleteCmd := &cobra.Command{ Use: "delete", @@ -391,14 +378,11 @@ func taskDeleteF(cmd *cobra.Command, args []string) error { return nil } -// taskLogFindFlags define the Delete command -type TaskLogFindFlags struct { +var taskLogFindFlags struct { taskID string runID string } -var taskLogFindFlags TaskLogFindFlags - func init() { taskLogFindCmd := &cobra.Command{ Use: "find", @@ -459,8 +443,7 @@ func taskLogFindF(cmd *cobra.Command, args []string) error { return nil } -// taskLogFindFlags define the Delete command -type TaskRunFindFlags struct { +var taskRunFindFlags struct { runID string taskID string afterTime string @@ -468,8 +451,6 @@ type TaskRunFindFlags struct { limit int } -var taskRunFindFlags TaskRunFindFlags - func init() { taskRunFindCmd := &cobra.Command{ Use: "find", @@ -556,12 +537,10 @@ func taskRunFindF(cmd *cobra.Command, args []string) error { return nil } -type RunRetryFlags struct { +var runRetryFlags struct { taskID, runID string } -var runRetryFlags RunRetryFlags - func init() { cmd := &cobra.Command{ Use: "retry",