From 70098242411ad155cc468d3b86c78e5bcef14bbb Mon Sep 17 00:00:00 2001 From: Volodymyr Khoroz Date: Fri, 22 Dec 2023 16:32:11 +0200 Subject: [PATCH] Feature: support wave filtering by status Signed-off-by: Volodymyr Khoroz --- client/foundries.go | 9 ++++++--- subcommands/waves/list.go | 6 +++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/client/foundries.go b/client/foundries.go index 24fd5773..22ed834e 100644 --- a/client/foundries.go +++ b/client/foundries.go @@ -1583,9 +1583,12 @@ func (a *Api) FactoryCreateWave(factory string, wave *WaveCreate) error { return err } -func (a *Api) FactoryListWaves(factory string, limit, page uint64, onlyActive bool) (*WaveList, error) { - url := fmt.Sprintf("%s/ota/factories/%s/waves/?limit=%d&page=%d&only-active=%t", - a.serverUrl, factory, limit, page, onlyActive) +func (a *Api) FactoryListWaves(factory string, limit, page uint64, status string) (*WaveList, error) { + url := fmt.Sprintf("%s/ota/factories/%s/waves/?limit=%d&page=%d", + a.serverUrl, factory, limit, page) + if len(status) > 0 { + url += "&status=" + status + } logrus.Debugf("Listing factory waves %s", url) body, err := a.Get(url) diff --git a/subcommands/waves/list.go b/subcommands/waves/list.go index 3b22b345..1acbe0ea 100644 --- a/subcommands/waves/list.go +++ b/subcommands/waves/list.go @@ -18,17 +18,17 @@ func init() { cmd.AddCommand(listCmd) listCmd.Flags().Uint64P("limit", "n", 20, "Limit the number of results displayed.") listCmd.Flags().Uint64P("page", "p", 1, "Page of waves to display when pagination is needed") - listCmd.Flags().BoolP("only-active", "", false, "Only show currently active waves") + listCmd.Flags().StringP("status", "S", "", "Only show waves with a given status; one of (active, complete, canceled)") } func doListWaves(cmd *cobra.Command, args []string) { factory := viper.GetString("factory") limit, _ := cmd.Flags().GetUint64("limit") showPage, _ := cmd.Flags().GetUint64("page") - onlyActive, _ := cmd.Flags().GetBool("only-active") + status, _ := cmd.Flags().GetString("status") logrus.Debugf("Showing a list of waves for %s", factory) - lst, err := api.FactoryListWaves(factory, limit, showPage, onlyActive) + lst, err := api.FactoryListWaves(factory, limit, showPage, status) subcommands.DieNotNil(err) t := tabby.New()