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

Add --status filter for get command #1325

Merged
merged 2 commits into from
May 10, 2019
Merged
Changes from 1 commit
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
8 changes: 8 additions & 0 deletions cmd/argo/commands/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ import (

const onExitSuffix = "onExit"

var (
status string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of a global variable, we should make this a local variable to NewGetCommand() instead, and pass the status filter down to printNode() through function arguments.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jessesuen

According to your comments, I change the code and pass param through function arguments.

Pls take a look. cc @sarabala1979

)

func NewGetCommand() *cobra.Command {
var (
output string
Expand Down Expand Up @@ -46,6 +50,7 @@ func NewGetCommand() *cobra.Command {

command.Flags().StringVarP(&output, "output", "o", "", "Output format. One of: json|yaml|wide")
command.Flags().BoolVar(&noColor, "no-color", false, "Disable colorized output")
command.Flags().StringVar(&status, "status", "", "Filter by status (Pending, Running, Succeeded, Skipped, Failed, Error)")
return command
}

Expand Down Expand Up @@ -411,6 +416,9 @@ func printNode(w *tabwriter.Writer, wf *wfv1.Workflow, node wfv1.NodeStatus, dep
var args []interface{}
duration := humanize.RelativeDurationShort(node.StartedAt.Time, node.FinishedAt.Time)
if node.Type == wfv1.NodeTypePod {
if status != "" && string(node.Phase) != status {
return
}
args = []interface{}{nodePrefix, nodeName, node.ID, duration, node.Message}
} else {
args = []interface{}{nodePrefix, nodeName, "", "", node.Message}
Expand Down