Skip to content

Commit

Permalink
fix: error handling when creating TW
Browse files Browse the repository at this point in the history
  • Loading branch information
exu committed Jul 3, 2024
1 parent 1444718 commit b7bf2ca
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cmd/kubectl-testkube/commands/testworkflows/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ func NewCreateTestWorkflowCmd() *cobra.Command {
obj.Name = name
}

// pass name from metadata in case of updating file
if obj.Name == "" {
obj.Name = obj.GetObjectMeta().GetName()
}

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

Expand All @@ -67,7 +72,9 @@ func NewCreateTestWorkflowCmd() *cobra.Command {
}
}

workflow, _ := client.GetTestWorkflow(obj.Name)
workflow, err := client.GetTestWorkflow(obj.Name)
ui.ExitOnError("getting test workflow "+obj.Name+" in namespace "+obj.Namespace, err)

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)
Expand Down

0 comments on commit b7bf2ca

Please sign in to comment.