Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter workflows in list based on name prefix #1721

Merged
merged 7 commits into from
Nov 5, 2019
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions cmd/argo/commands/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func NewListCommand() *cobra.Command {
listArgs listFlags
)
var command = &cobra.Command{
Use: "list",
Use: "list [WORKFLOW]",
Short: "list workflows",
Run: func(cmd *cobra.Command, args []string) {
var wfClient v1alpha1.WorkflowInterface
Expand Down Expand Up @@ -101,7 +101,7 @@ func NewListCommand() *cobra.Command {

switch listArgs.output {
case "", "wide":
printTable(workflows, &listArgs)
printTable(args, workflows, &listArgs)
case "name":
for _, wf := range workflows {
fmt.Println(wf.ObjectMeta.Name)
Expand All @@ -121,7 +121,7 @@ func NewListCommand() *cobra.Command {
return command
}

func printTable(wfList []wfv1.Workflow, listArgs *listFlags) {
func printTable(args []string, wfList []wfv1.Workflow, listArgs *listFlags) {
w := tabwriter.NewWriter(os.Stdout, 0, 0, 3, ' ', 0)
if listArgs.allNamespaces {
fmt.Fprint(w, "NAMESPACE\t")
Expand All @@ -132,6 +132,9 @@ func printTable(wfList []wfv1.Workflow, listArgs *listFlags) {
}
fmt.Fprint(w, "\n")
for _, wf := range wfList {
if len(args) != 0 && !strings.HasPrefix(wf.ObjectMeta.Name, args[0]) {
continue
}
ageStr := humanize.RelativeDurationShort(wf.ObjectMeta.CreationTimestamp.Time, time.Now())
durationStr := humanize.RelativeDurationShort(wf.Status.StartedAt.Time, wf.Status.FinishedAt.Time)
if listArgs.allNamespaces {
Expand Down