Skip to content

Commit

Permalink
Feature: support wave filtering by status
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 96cc6d7 commit 7009824
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
9 changes: 6 additions & 3 deletions client/foundries.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions subcommands/waves/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 7009824

Please sign in to comment.