From 5f734c4088b9af65e9f34b696607567e3202114a Mon Sep 17 00:00:00 2001 From: Jacek Wysocki Date: Wed, 3 Jul 2024 16:20:27 +0200 Subject: [PATCH] fix: error handling when creating TW (#5631) * fix: error handling when creating TW * fix: remove object.name update * fix: move error to debug * fix: handle error on update --- cmd/kubectl-testkube/commands/testworkflows/create.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cmd/kubectl-testkube/commands/testworkflows/create.go b/cmd/kubectl-testkube/commands/testworkflows/create.go index 07424cea09f..47e0db5c8c0 100644 --- a/cmd/kubectl-testkube/commands/testworkflows/create.go +++ b/cmd/kubectl-testkube/commands/testworkflows/create.go @@ -67,7 +67,15 @@ func NewCreateTestWorkflowCmd() *cobra.Command { } } - workflow, _ := client.GetTestWorkflow(obj.Name) + workflow, err := client.GetTestWorkflow(obj.Name) + if err != nil { + if update { + ui.ExitOnError("getting test workflow "+obj.Name+" in namespace "+obj.Namespace, err) + } else { + ui.Debug("getting test workflow "+obj.Name+" in namespace "+obj.Namespace, err.Error()) + } + } + if workflow.Name != "" { if !update { ui.Failf("Test workflow with name '%s' already exists in namespace %s, use --update flag for upsert", obj.Name, namespace)