Adds check if a component exists before deleting
This commit adds a check to find if a component exists in the current application before deleting and displays a proper and formatted error message
@@ -8,6 +8,7 @@ import (
"github.com/redhat-developer/odo/pkg/component"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
+ "os"
)
var (
@@ -30,6 +31,14 @@ var componentDeleteCmd = &cobra.Command{
componentName := args[0]
var confirmDeletion string
+ exists, err := component.Exists(client, componentName)
+ checkError(err, "")
+
+ if !exists {
+ fmt.Printf("Component with the name %s does not exist in the current application\n", componentName)
+ os.Exit(1)
+ }
+
currentApp, err := application.GetCurrent(client)
checkError(err, "")
