From cc7de97aaa986515edb9cef4944c953d24d6bfdf Mon Sep 17 00:00:00 2001 From: xianlubird Date: Sat, 8 Jun 2019 09:59:39 +0800 Subject: [PATCH 1/2] Add paging for list command --- cmd/argo/commands/list.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/cmd/argo/commands/list.go b/cmd/argo/commands/list.go index 7f779aa13bb6..3d8492a84823 100644 --- a/cmd/argo/commands/list.go +++ b/cmd/argo/commands/list.go @@ -30,6 +30,7 @@ type listFlags struct { running bool // --running output string // --output since string // --since + limit int64 // --limit } func NewListCommand() *cobra.Command { @@ -61,20 +62,33 @@ func NewListCommand() *cobra.Command { labelSelector = labelSelector.Add(*req) } listOpts.LabelSelector = labelSelector.String() + listOpts.Limit = listArgs.limit wfList, err := wfClient.List(listOpts) if err != nil { log.Fatal(err) } + + var tmpWorkFlows []wfv1.Workflow + tmpWorkFlows = wfList.Items + for wfList.ListMeta.Continue != "" { + listOpts.Continue = wfList.ListMeta.Continue + wfList, err = wfClient.List(listOpts) + if err != nil { + log.Fatal(err) + } + tmpWorkFlows = append(tmpWorkFlows, wfList.Items...) + } + var workflows []wfv1.Workflow if listArgs.since == "" { - workflows = wfList.Items + workflows = tmpWorkFlows } else { workflows = make([]wfv1.Workflow, 0) minTime, err := argotime.ParseSince(listArgs.since) if err != nil { log.Fatal(err) } - for _, wf := range wfList.Items { + for _, wf := range tmpWorkFlows { if wf.Status.FinishedAt.IsZero() || wf.ObjectMeta.CreationTimestamp.After(*minTime) { workflows = append(workflows, wf) } @@ -100,6 +114,7 @@ func NewListCommand() *cobra.Command { command.Flags().BoolVar(&listArgs.running, "running", false, "Show only running workflows") command.Flags().StringVarP(&listArgs.output, "output", "o", "", "Output format. One of: wide|name") command.Flags().StringVar(&listArgs.since, "since", "", "Show only workflows newer than a relative duration") + command.Flags().Int64VarP(&listArgs.limit, "limit", "", 100, "Limit per num in one request") return command } From 6162813baac0736383b46d32c7dee57865c3f847 Mon Sep 17 00:00:00 2001 From: xianlubird Date: Mon, 17 Jun 2019 10:13:13 +0800 Subject: [PATCH 2/2] Rename limit to chunk-size --- cmd/argo/commands/list.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cmd/argo/commands/list.go b/cmd/argo/commands/list.go index 3d8492a84823..9b895f750a1e 100644 --- a/cmd/argo/commands/list.go +++ b/cmd/argo/commands/list.go @@ -30,7 +30,7 @@ type listFlags struct { running bool // --running output string // --output since string // --since - limit int64 // --limit + chunkSize int64 // --chunk-size } func NewListCommand() *cobra.Command { @@ -62,7 +62,9 @@ func NewListCommand() *cobra.Command { labelSelector = labelSelector.Add(*req) } listOpts.LabelSelector = labelSelector.String() - listOpts.Limit = listArgs.limit + if listArgs.chunkSize != 0 { + listOpts.Limit = listArgs.chunkSize + } wfList, err := wfClient.List(listOpts) if err != nil { log.Fatal(err) @@ -114,7 +116,7 @@ func NewListCommand() *cobra.Command { command.Flags().BoolVar(&listArgs.running, "running", false, "Show only running workflows") command.Flags().StringVarP(&listArgs.output, "output", "o", "", "Output format. One of: wide|name") command.Flags().StringVar(&listArgs.since, "since", "", "Show only workflows newer than a relative duration") - command.Flags().Int64VarP(&listArgs.limit, "limit", "", 100, "Limit per num in one request") + command.Flags().Int64VarP(&listArgs.chunkSize, "chunk-size", "", 500, "Return large lists in chunks rather than all at once. Pass 0 to disable.") return command }