github.com/kubeshop/testkube@v1.17.23/cmd/kubectl-testkube/commands/testworkflows/renderer/testworkflowexecution_obj.go (about) 1 package renderer 2 3 import ( 4 "fmt" 5 6 "github.com/pkg/errors" 7 8 "github.com/kubeshop/testkube/pkg/api/v1/client" 9 "github.com/kubeshop/testkube/pkg/api/v1/testkube" 10 "github.com/kubeshop/testkube/pkg/ui" 11 ) 12 13 func TestWorkflowExecutionRenderer(client client.Client, ui *ui.UI, obj interface{}) error { 14 execution, ok := obj.(testkube.TestWorkflowExecution) 15 if !ok { 16 return fmt.Errorf("can't use '%T' as testkube.TestWorkflowExecution in RenderObj for test workflow execution", obj) 17 } 18 19 ui.Info("Test Workflow Execution:") 20 ui.Warn("Name: ", execution.Workflow.Name) 21 if execution.Id != "" { 22 ui.Warn("Execution ID: ", execution.Id) 23 ui.Warn("Execution name: ", execution.Name) 24 if execution.Number != 0 { 25 ui.Warn("Execution number: ", fmt.Sprintf("%d", execution.Number)) 26 } 27 ui.Warn("Requested at: ", execution.ScheduledAt.String()) 28 if execution.Result != nil && execution.Result.Status != nil { 29 ui.Warn("Status: ", string(*execution.Result.Status)) 30 if !execution.Result.QueuedAt.IsZero() { 31 ui.Warn("Queued at: ", execution.Result.QueuedAt.String()) 32 } 33 if !execution.Result.StartedAt.IsZero() { 34 ui.Warn("Started at: ", execution.Result.StartedAt.String()) 35 } 36 if !execution.Result.FinishedAt.IsZero() { 37 ui.Warn("Finished at: ", execution.Result.FinishedAt.String()) 38 ui.Warn("Duration: ", execution.Result.FinishedAt.Sub(execution.Result.QueuedAt).String()) 39 } 40 } 41 } 42 43 if execution.Result != nil && execution.Result.Initialization != nil && execution.Result.Initialization.ErrorMessage != "" { 44 ui.NL() 45 ui.Err(errors.New(execution.Result.Initialization.ErrorMessage)) 46 } 47 48 return nil 49 50 }