diff --git a/cmd/kubernetes/kubernetes_remove.go b/cmd/kubernetes/kubernetes_remove.go index 4952ee8e..d9959079 100644 --- a/cmd/kubernetes/kubernetes_remove.go +++ b/cmd/kubernetes/kubernetes_remove.go @@ -4,8 +4,6 @@ import ( "errors" "fmt" "os" - "os/exec" - "path/filepath" "strings" pluralize "github.com/alejandrojnm/go-pluralize" @@ -17,7 +15,6 @@ import ( ) var kuberneteList []utility.ObjecteList -var keepConfig bool var kubernetesRemoveCmd = &cobra.Command{ Use: "remove", Aliases: []string{"rm", "delete", "destroy"}, @@ -92,13 +89,6 @@ var kubernetesRemoveCmd = &cobra.Command{ utility.Error("error deleting the kubernetes cluster: %s", err) os.Exit(1) } - - if !keepConfig { - err = removeKubectlConfig(v.Name) - if err != nil { - utility.Warning("Failed to remove kubectl config for cluster %s: %s", v.Name, err) - } - } } ow := utility.NewOutputWriter() @@ -125,27 +115,3 @@ var kubernetesRemoveCmd = &cobra.Command{ } }, } - -func removeKubectlConfig(clusterName string) error { - kubeConfigPath := os.Getenv("KUBECONFIG") - if kubeConfigPath == "" { - kubeConfigPath = filepath.Join(os.Getenv("HOME"), ".kube", "config") - } - - cmd := exec.Command("kubectl", "config", "delete-context", clusterName) - if err := cmd.Run(); err != nil { - return fmt.Errorf("failed to delete context: %w", err) - } - - cmd = exec.Command("kubectl", "config", "delete-cluster", clusterName) - if err := cmd.Run(); err != nil { - return fmt.Errorf("failed to delete cluster: %w", err) - } - - cmd = exec.Command("kubectl", "config", "unset", fmt.Sprintf("users.%s", clusterName)) - if err := cmd.Run(); err != nil { - return fmt.Errorf("failed to unset user: %w", err) - } - - return nil -}