Skip to content

Commit

Permalink
fix: tcl for printing running context
Browse files Browse the repository at this point in the history
Signed-off-by: Vladislav Sukhin <[email protected]>
  • Loading branch information
vsukhin committed Oct 22, 2024
1 parent 8e87626 commit 89a0da2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/kubeshop/testkube/cmd/kubectl-testkube/commands/common/render"
"github.com/kubeshop/testkube/pkg/api/v1/client"
"github.com/kubeshop/testkube/pkg/api/v1/testkube"
tclcmd "github.com/kubeshop/testkube/pkg/tcl/testworkflowstcl/cmd"
"github.com/kubeshop/testkube/pkg/ui"
)

Expand Down Expand Up @@ -63,27 +64,8 @@ func printPrettyOutput(ui *ui.UI, execution testkube.TestWorkflowExecution) {
ui.NL()
ui.Warn("Tags: ", testkube.MapToString(execution.Tags))
}
if execution.RunningContext != nil {
ui.Warn("Running context: ")
ctx := execution.RunningContext
if ctx.Interface_ != nil {
ui.Warn("Interface: ")
ui.Warn(" Name: ", ctx.Interface_.Name)
if ctx.Interface_.Type_ != nil {
ui.Warn(" Type: ", string(*ctx.Interface_.Type_))
}
}
if ctx.Actor != nil {
ui.Warn("Actor: ")
ui.Warn(" Name: ", ctx.Actor.Name)
ui.Warn(" Email: ", ctx.Actor.Email)
ui.Warn(" Execution id: ", ctx.Actor.ExecutionId)
ui.Warn(" Execution path: ", ctx.Actor.ExecutionPath)
if ctx.Actor.Type_ != nil {
ui.Warn(" Type: ", string(*ctx.Actor.Type_))
}
}
}
// Pro edition only (tcl protected code)
tclcmd.PrintRunningContext(ui, execution)
if execution.Result != nil && execution.Result.Status != nil {
ui.Warn("Status: ", string(*execution.Result.Status))
if !execution.Result.QueuedAt.IsZero() {
Expand Down
25 changes: 25 additions & 0 deletions pkg/tcl/testworkflowstcl/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (

"github.com/kubeshop/testkube/internal/common"
"github.com/kubeshop/testkube/pkg/api/v1/testkube"
"github.com/kubeshop/testkube/pkg/ui"
)

func GetRunningContext(runContext, token string, interfaceType testkube.TestWorkflowRunningContextInterfaceType) *testkube.TestWorkflowRunningContext {
Expand Down Expand Up @@ -74,3 +75,27 @@ func getJWTPayload(token string) (map[string]interface{}, error) {

return payload, nil
}

func PrintRunningContext(ui *ui.UI, execution testkube.TestWorkflowExecution) {
if execution.RunningContext != nil {
ui.Warn("Running context: ")
ctx := execution.RunningContext
if ctx.Interface_ != nil {
ui.Warn("Interface: ")
ui.Warn(" Name: ", ctx.Interface_.Name)
if ctx.Interface_.Type_ != nil {
ui.Warn(" Type: ", string(*ctx.Interface_.Type_))
}
}
if ctx.Actor != nil {
ui.Warn("Actor: ")
ui.Warn(" Name: ", ctx.Actor.Name)
ui.Warn(" Email: ", ctx.Actor.Email)
ui.Warn(" Execution id: ", ctx.Actor.ExecutionId)
ui.Warn(" Execution path: ", ctx.Actor.ExecutionPath)
if ctx.Actor.Type_ != nil {
ui.Warn(" Type: ", string(*ctx.Actor.Type_))
}
}
}
}

0 comments on commit 89a0da2

Please sign in to comment.