Skip to content

Commit

Permalink
Feature: support filtering waves by tag
Browse files Browse the repository at this point in the history
Signed-off-by: Volodymyr Khoroz <[email protected]>
  • Loading branch information
vkhoroz committed Dec 22, 2023
1 parent 7009824 commit 9ce92c9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion client/foundries.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion subcommands/waves/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,18 @@ 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) {
factory := viper.GetString("factory")
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()
Expand Down

0 comments on commit 9ce92c9

Please sign in to comment.