diff --git a/cmd/argo/commands/archive/list.go b/cmd/argo/commands/archive/list.go index 1ea5946537b6..1b40ff849e06 100644 --- a/cmd/argo/commands/archive/list.go +++ b/cmd/argo/commands/archive/list.go @@ -21,6 +21,7 @@ func NewListCommand() *cobra.Command { selector string output = common.NewPrintWorkflowOutputValue("wide") chunkSize int64 + prefix string ) command := &cobra.Command{ Use: "list", @@ -47,7 +48,7 @@ func NewListCommand() *cobra.Command { return err } namespace := client.Namespace() - workflows, err := listArchivedWorkflows(ctx, serviceClient, namespace, selector, chunkSize) + workflows, err := listArchivedWorkflows(ctx, serviceClient, namespace, selector, chunkSize, prefix) if err != nil { return err } @@ -55,12 +56,13 @@ func NewListCommand() *cobra.Command { }, } command.Flags().VarP(&output, "output", "o", "Output format. "+output.Usage()) + command.Flags().StringVar(&prefix, "prefix", "", "Filter workflows by prefix") command.Flags().StringVarP(&selector, "selector", "l", "", "Selector (label query) to filter on, not including uninitialized ones, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2)") command.Flags().Int64VarP(&chunkSize, "chunk-size", "", 0, "Return large lists in chunks rather than all at once. Pass 0 to disable.") return command } -func listArchivedWorkflows(ctx context.Context, serviceClient workflowarchivepkg.ArchivedWorkflowServiceClient, namespace string, labelSelector string, chunkSize int64) (wfv1.Workflows, error) { +func listArchivedWorkflows(ctx context.Context, serviceClient workflowarchivepkg.ArchivedWorkflowServiceClient, namespace string, labelSelector string, chunkSize int64, prefix string) (wfv1.Workflows, error) { listOpts := &metav1.ListOptions{ LabelSelector: labelSelector, Limit: chunkSize, @@ -68,7 +70,7 @@ func listArchivedWorkflows(ctx context.Context, serviceClient workflowarchivepkg var workflows wfv1.Workflows for { log.WithField("listOpts", listOpts).Debug() - resp, err := serviceClient.ListArchivedWorkflows(ctx, &workflowarchivepkg.ListArchivedWorkflowsRequest{Namespace: namespace, ListOptions: listOpts}) + resp, err := serviceClient.ListArchivedWorkflows(ctx, &workflowarchivepkg.ListArchivedWorkflowsRequest{Namespace: namespace, ListOptions: listOpts, NamePrefix: prefix}) if err != nil { return nil, err } diff --git a/cmd/argo/commands/archive/resubmit.go b/cmd/argo/commands/archive/resubmit.go index fb26dde5172e..6014bdaefb4e 100644 --- a/cmd/argo/commands/archive/resubmit.go +++ b/cmd/argo/commands/archive/resubmit.go @@ -105,7 +105,7 @@ func resubmitArchivedWorkflows(ctx context.Context, archiveServiceClient workflo ) if resubmitOpts.hasSelector() { - wfs, err = listArchivedWorkflows(ctx, archiveServiceClient, resubmitOpts.fieldSelector, resubmitOpts.labelSelector, 0) + wfs, err = listArchivedWorkflows(ctx, archiveServiceClient, resubmitOpts.fieldSelector, resubmitOpts.labelSelector, 0, "") if err != nil { return err } diff --git a/cmd/argo/commands/archive/retry.go b/cmd/argo/commands/archive/retry.go index 585ee5b19606..c03bdbc7d6f4 100644 --- a/cmd/argo/commands/archive/retry.go +++ b/cmd/argo/commands/archive/retry.go @@ -111,7 +111,7 @@ func retryArchivedWorkflows(ctx context.Context, archiveServiceClient workflowar } var wfs wfv1.Workflows if retryOpts.hasSelector() { - wfs, err = listArchivedWorkflows(ctx, archiveServiceClient, retryOpts.fieldSelector, retryOpts.labelSelector, 0) + wfs, err = listArchivedWorkflows(ctx, archiveServiceClient, retryOpts.fieldSelector, retryOpts.labelSelector, 0, "") if err != nil { return err } diff --git a/docs/cli/argo_archive_list.md b/docs/cli/argo_archive_list.md index 72f710582d72..ed3c1ae1b869 100644 --- a/docs/cli/argo_archive_list.md +++ b/docs/cli/argo_archive_list.md @@ -29,6 +29,7 @@ argo archive list [flags] --chunk-size int Return large lists in chunks rather than all at once. Pass 0 to disable. -h, --help help for list -o, --output string Output format. One of: name|json|yaml|wide (default "wide") + --prefix string Filter workflows by prefix -l, --selector string Selector (label query) to filter on, not including uninitialized ones, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2) ```