From 9ce92c9482975334950e6380e5d7e43fe8f0d4dd Mon Sep 17 00:00:00 2001 From: Volodymyr Khoroz Date: Fri, 22 Dec 2023 16:36:09 +0200 Subject: [PATCH] Feature: support filtering waves by tag Signed-off-by: Volodymyr Khoroz --- client/foundries.go | 5 ++++- subcommands/waves/list.go | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/client/foundries.go b/client/foundries.go index 22ed834e..b6b68214 100644 --- a/client/foundries.go +++ b/client/foundries.go @@ -1583,12 +1583,15 @@ func (a *Api) FactoryCreateWave(factory string, wave *WaveCreate) error { return err } -func (a *Api) FactoryListWaves(factory string, limit, page uint64, status string) (*WaveList, error) { +func (a *Api) FactoryListWaves(factory string, limit, page uint64, status, tag 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 } + if len(tag) > 0 { + url += "&tag=" + tag + } 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 1acbe0ea..b24803b1 100644 --- a/subcommands/waves/list.go +++ b/subcommands/waves/list.go @@ -19,6 +19,7 @@ func init() { 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().StringP("status", "S", "", "Only show waves with a given status; one of (active, complete, canceled)") + listCmd.Flags().StringP("tag", "T", "", "Only show waves with a given tag") } func doListWaves(cmd *cobra.Command, args []string) { @@ -26,9 +27,10 @@ func doListWaves(cmd *cobra.Command, args []string) { limit, _ := cmd.Flags().GetUint64("limit") showPage, _ := cmd.Flags().GetUint64("page") status, _ := cmd.Flags().GetString("status") + tag, _ := cmd.Flags().GetString("tag") logrus.Debugf("Showing a list of waves for %s", factory) - lst, err := api.FactoryListWaves(factory, limit, showPage, status) + lst, err := api.FactoryListWaves(factory, limit, showPage, status, tag) subcommands.DieNotNil(err) t := tabby.New()