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

fix: [TKC-2343] workflow execution url #5716

Merged
merged 2 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
26 changes: 26 additions & 0 deletions cmd/kubectl-testkube/commands/common/render/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"gopkg.in/yaml.v2"

"github.com/kubeshop/testkube/cmd/kubectl-testkube/config"
"github.com/kubeshop/testkube/pkg/api/v1/client"
"github.com/kubeshop/testkube/pkg/api/v1/testkube"
"github.com/kubeshop/testkube/pkg/ui"
Expand Down Expand Up @@ -182,3 +183,28 @@ func PrintTestSuiteExecutionURIs(execution *testkube.TestSuiteExecution, dashboa
testSuiteName, execution.Id))
ui.NL()
}

func PrintTestWorkflowExecutionURIs(execution *testkube.TestWorkflowExecution) {
cfg, err := config.Load()
ui.ExitOnError("loading config file", err)

if cfg.ContextType != config.ContextTypeCloud {
return
}

if execution.Result == nil || !execution.Result.IsFinished() {
return
}

ui.NL()
workflowName := ""
if execution.Workflow != nil {
workflowName = execution.Workflow.Name
}

ui.ExecutionLink("Test Workflow URI:", fmt.Sprintf("%s/organization/%s/environment/%s/dashboard/test-workflows/%s",
cfg.CloudContext.UiUri, cfg.CloudContext.OrganizationId, cfg.CloudContext.EnvironmentId, workflowName))
ui.ExecutionLink("Test Workflow Execution URI:", fmt.Sprintf("%s/organization/%s/environment/%s/dashboard/test-workflows/%s/execution/%s",
cfg.CloudContext.UiUri, cfg.CloudContext.OrganizationId, cfg.CloudContext.EnvironmentId, workflowName, execution.Id))
ui.NL()
}
31 changes: 22 additions & 9 deletions cmd/kubectl-testkube/commands/testworkflows/executions.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ func NewGetTestWorkflowExecutionsCmd() *cobra.Command {
Long: `Gets TestWorkflow execution details by ID, or list if id is not passed`,

Run: func(cmd *cobra.Command, args []string) {
outputFlag := cmd.Flag("output")
outputType := render.OutputPretty
if outputFlag != nil {
outputType = render.OutputType(outputFlag.Value.String())
}

outputPretty := outputType == render.OutputPretty

client, _, err := common.GetClient(cmd)
ui.ExitOnError("getting client", err)

Expand All @@ -51,19 +59,24 @@ func NewGetTestWorkflowExecutionsCmd() *cobra.Command {
ui.ExitOnError("rendering obj", err)
}

ui.Info("Getting logs for test workflow execution", executionID)
if outputPretty {
ui.Info("Getting logs for test workflow execution", executionID)

logs, err := client.GetTestWorkflowExecutionLogs(executionID)
ui.ExitOnError("getting logs from executor", err)
logs, err := client.GetTestWorkflowExecutionLogs(executionID)
ui.ExitOnError("getting logs from executor", err)

sigs := flattenSignatures(execution.Signature)
sigs := flattenSignatures(execution.Signature)

var results map[string]testkube.TestWorkflowStepResult
if execution.Result != nil {
results = execution.Result.Steps
}
var results map[string]testkube.TestWorkflowStepResult
if execution.Result != nil {
results = execution.Result.Steps
}

printRawLogLines(logs, sigs, results)
printRawLogLines(logs, sigs, results)
if !logsOnly {
render.PrintTestWorkflowExecutionURIs(&execution)
}
}
},
}

Expand Down
4 changes: 4 additions & 0 deletions cmd/kubectl-testkube/commands/testworkflows/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ func NewRunTestWorkflowCmd() *cobra.Command {
uiShellWatchExecution(execution.Id)
}

execution, err = client.GetTestWorkflowExecution(execution.Id)
ui.ExitOnError("get execution failed", err)

render.PrintTestWorkflowExecutionURIs(&execution)
uiShellGetExecution(execution.Id)
}

Expand Down
4 changes: 4 additions & 0 deletions cmd/kubectl-testkube/commands/testworkflows/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ func NewWatchTestWorkflowExecutionCmd() *cobra.Command {
exitCode := uiWatch(execution, client)
ui.NL()

execution, err = client.GetTestWorkflowExecution(execution.Id)
ui.ExitOnError("get execution failed", err)

render.PrintTestWorkflowExecutionURIs(&execution)
uiShellGetExecution(execution.Id)
os.Exit(exitCode)
},
Expand Down
Loading