-
Notifications
You must be signed in to change notification settings - Fork 127
/
execution_obj.go
64 lines (52 loc) · 2.1 KB
/
execution_obj.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package renderer
import (
"fmt"
"github.com/kubeshop/testkube/cmd/kubectl-testkube/commands/common/render"
"github.com/kubeshop/testkube/cmd/kubectl-testkube/commands/renderer"
"github.com/kubeshop/testkube/pkg/api/v1/testkube"
"github.com/kubeshop/testkube/pkg/ui"
)
func ExecutionRenderer(ui *ui.UI, obj interface{}) error {
execution, ok := obj.(testkube.Execution)
if !ok {
return fmt.Errorf("can't render execution, expecrted obj to be testkube.Execution but got '%T'", obj)
}
ui.Warn("ID: ", execution.Id)
ui.Warn("Name: ", execution.Name)
if execution.Number != 0 {
ui.Warn("Number: ", fmt.Sprintf("%d", execution.Number))
}
ui.Warn("Test name: ", execution.TestName)
ui.Warn("Type: ", execution.TestType)
ui.Warn("Status: ", string(*execution.ExecutionResult.Status))
ui.Warn("Start time: ", execution.StartTime.String())
ui.Warn("End time: ", execution.EndTime.String())
ui.Warn("Duration: ", execution.Duration)
if execution.RunningContext != nil {
ui.Warn("Running context:")
ui.Warn("Type: ", execution.RunningContext.Type_)
ui.Warn("Context:", execution.RunningContext.Context)
}
if len(execution.Labels) > 0 {
ui.Warn("Labels: ", testkube.MapToString(execution.Labels))
}
renderer.RenderVariables(execution.Variables)
if len(execution.Command) > 0 {
ui.Warn("Command: ", execution.Command...)
}
if len(execution.Args) > 0 {
ui.Warn("Args: ", execution.Args...)
}
if execution.Content != nil && execution.Content.Repository != nil {
ui.Warn("Repository parameters:")
ui.Warn(" Branch: ", execution.Content.Repository.Branch)
ui.Warn(" Commit: ", execution.Content.Repository.Commit)
ui.Warn(" Path: ", execution.Content.Repository.Path)
ui.Warn(" Working dir: ", execution.Content.Repository.WorkingDir)
ui.Warn(" Certificate: ", execution.Content.Repository.CertificateSecret)
ui.Warn(" Auth type: ", execution.Content.Repository.AuthType)
}
render.RenderExecutionResult(&execution, false)
ui.NL()
return nil
}