From befb55183fc4c9325ac2167fbf379863539b48e8 Mon Sep 17 00:00:00 2001 From: Sam DeLuca Date: Fri, 15 Mar 2019 09:30:47 -0700 Subject: [PATCH] [CSE-14] Display new errors and warnings in the CLI (#17) * update node * UI tweaks * fixing a comment --- cmd/argo/commands/common.go | 6 ++++++ cmd/argo/commands/get.go | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/cmd/argo/commands/common.go b/cmd/argo/commands/common.go index d415089642fb..fb46d173da31 100644 --- a/cmd/argo/commands/common.go +++ b/cmd/argo/commands/common.go @@ -46,6 +46,12 @@ const ( FgDefault = 39 ) +//useful icons +var ( + YellowWarning = ansiFormat("⚠", FgYellow) + RedError = ansiFormat("✖", FgRed) +) + func initializeSession() { jobStatusIconMap = map[wfv1.NodePhase]string{ wfv1.NodePending: ansiFormat("◷", FgYellow), diff --git a/cmd/argo/commands/get.go b/cmd/argo/commands/get.go index d24e3543463d..7dbb7dc09f9c 100644 --- a/cmd/argo/commands/get.go +++ b/cmd/argo/commands/get.go @@ -114,6 +114,28 @@ func printWorkflowHelper(wf *wfv1.Workflow, outFmt string) { } } } + + errorWriter := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0) + + if wf.Status.Errors != nil || wf.Status.Warnings != nil { + + fmt.Printf("\nErrors and Warnings:\n") + fmt.Fprintf(errorWriter, "%s\tPODNAME\tCODE\tMESSAGE\n", ansiFormat("STEP", FgDefault)) + } + + if wf.Status.Errors != nil { + for _, errorResult := range wf.Status.Errors { + fmt.Fprintf(errorWriter, "%s %s\t%s\t%s\t%s\n", RedError, errorResult.StepName, errorResult.PodId, errorResult.Name, errorResult.Message) + } + } + + if wf.Status.Warnings != nil { + for _, warningResult := range wf.Status.Warnings { + fmt.Fprintf(errorWriter, "%s %s\t%s\t%s\t%s\n", YellowWarning, warningResult.StepName, warningResult.PodId, warningResult.Name, warningResult.Message) + } + } + _ = errorWriter.Flush() + printTree := true if wf.Status.Nodes == nil { printTree = false