diff --git a/cmd/kubectl-testkube/commands/executors/create.go b/cmd/kubectl-testkube/commands/executors/create.go index bed89ba0460..de1eee972f8 100644 --- a/cmd/kubectl-testkube/commands/executors/create.go +++ b/cmd/kubectl-testkube/commands/executors/create.go @@ -42,7 +42,11 @@ func NewCreateExecutorCmd() *cobra.Command { executor, _ := client.GetExecutor(name) if name == executor.Name { - if !update { + if cmd.Flag("update").Changed { + if !update { + ui.Failf("Executor with name '%s' already exists in namespace %s, ", executor.Name, namespace) + } + } else { ok := ui.Confirm(fmt.Sprintf("Executor with name '%s' already exists in namespace %s, ", executor.Name, namespace) + "do you want to overwrite it?") if !ok { diff --git a/cmd/kubectl-testkube/commands/templates/create.go b/cmd/kubectl-testkube/commands/templates/create.go index b15f71f9d66..8d03a7d5b55 100644 --- a/cmd/kubectl-testkube/commands/templates/create.go +++ b/cmd/kubectl-testkube/commands/templates/create.go @@ -42,7 +42,11 @@ func NewCreateTemplateCmd() *cobra.Command { template, _ := client.GetTemplate(name) if name == template.Name { - if !update { + if cmd.Flag("update").Changed { + if !update { + ui.Failf("Template with name '%s' already exists in namespace %s, ", template.Name, namespace) + } + } else { ok := ui.Confirm(fmt.Sprintf("Template with name '%s' already exists in namespace %s, ", template.Name, namespace) + "do you want to overwrite it?") if !ok { diff --git a/cmd/kubectl-testkube/commands/tests/create.go b/cmd/kubectl-testkube/commands/tests/create.go index 71eed183f90..73ed11f879a 100644 --- a/cmd/kubectl-testkube/commands/tests/create.go +++ b/cmd/kubectl-testkube/commands/tests/create.go @@ -105,7 +105,11 @@ func NewCreateTestsCmd() *cobra.Command { test, _ := client.GetTest(testName) if testName == test.Name { - if !update { + if cmd.Flag("update").Changed { + if !update { + ui.Failf("Test with name '%s' already exists in namespace %s, ", testName, namespace) + } + } else { ok := ui.Confirm(fmt.Sprintf("Test with name '%s' already exists in namespace %s, ", testName, namespace) + "do you want to overwrite it?") if !ok { diff --git a/cmd/kubectl-testkube/commands/testsources/create.go b/cmd/kubectl-testkube/commands/testsources/create.go index 61037a092ec..eedeed52afa 100644 --- a/cmd/kubectl-testkube/commands/testsources/create.go +++ b/cmd/kubectl-testkube/commands/testsources/create.go @@ -53,7 +53,11 @@ func NewCreateTestSourceCmd() *cobra.Command { testsource, _ := client.GetTestSource(name) if name == testsource.Name { - if !update { + if cmd.Flag("update").Changed { + if !update { + ui.Failf("TestSource with name '%s' already exists in namespace %s, ", testsource.Name, namespace) + } + } else { ok := ui.Confirm(fmt.Sprintf("TestSource with name '%s' already exists in namespace %s, ", testsource.Name, namespace) + "do you want to overwrite it?") if !ok { diff --git a/cmd/kubectl-testkube/commands/testsuites/create.go b/cmd/kubectl-testkube/commands/testsuites/create.go index 67bbaa87039..8f45f09bfc0 100644 --- a/cmd/kubectl-testkube/commands/testsuites/create.go +++ b/cmd/kubectl-testkube/commands/testsuites/create.go @@ -61,7 +61,11 @@ func NewCreateTestSuitesCmd() *cobra.Command { testSuite, _ := client.GetTestSuite(options.Name) if options.Name == testSuite.Name { - if !update { + if cmd.Flag("update").Changed { + if !update { + ui.Failf("TestSuite with name '%s' already exists in namespace %s, ", testSuite.Name, namespace) + } + } else { ok := ui.Confirm(fmt.Sprintf("TestSuite with name '%s' already exists in namespace %s, ", testSuite.Name, namespace) + "do you want to overwrite it?") if !ok { diff --git a/cmd/kubectl-testkube/commands/webhooks/create.go b/cmd/kubectl-testkube/commands/webhooks/create.go index 8e2b3a01a39..046cd2c75a1 100644 --- a/cmd/kubectl-testkube/commands/webhooks/create.go +++ b/cmd/kubectl-testkube/commands/webhooks/create.go @@ -46,7 +46,11 @@ func NewCreateWebhookCmd() *cobra.Command { webhook, _ := client.GetWebhook(name) if name == webhook.Name { - if !update { + if cmd.Flag("update").Changed { + if !update { + ui.Failf("Webhook with name '%s' already exists in namespace %s, ", webhook.Name, namespace) + } + } else { ok := ui.Confirm(fmt.Sprintf("Webhook with name '%s' already exists in namespace %s, ", webhook.Name, namespace) + "do you want to overwrite it?") if !ok {