Skip to content

Commit

Permalink
delete require profile/machine name
Browse files Browse the repository at this point in the history
This changeset makes it necessary to pass a profile/machine name in order
to delete. This would help avoid accidental deletion of machine by just
delete command.
  • Loading branch information
darkowlzz committed Jul 20, 2017
1 parent 9e8ef22 commit 20c8128
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
17 changes: 13 additions & 4 deletions cmd/minikube/cmd/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,27 @@ import (
"os"

"github.com/spf13/cobra"
"github.com/spf13/viper"
cmdUtil "k8s.io/minikube/cmd/util"
"k8s.io/minikube/pkg/minikube/cluster"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/machine"
)

// deleteCmd represents the delete command
var deleteCmd = &cobra.Command{
Use: "delete",
Short: "Deletes a local kubernetes cluster",
Long: `Deletes a local kubernetes cluster. This command deletes the VM, and removes all
associated files.`,
Use: "delete MINIKUBE_PROFILE_NAME",
Short: "Deletes a local kubernetes cluster under a given profile",
Long: `Deletes a local kubernetes cluster under a given profile. This command deletes
the VM, and removes all associated files.`,
Run: func(cmd *cobra.Command, args []string) {
if len(args) != 1 {
fmt.Fprintln(os.Stderr, "usage: minikube delete MINIKUBE_PROFILE_NAME")
os.Exit(1)
}

viper.Set(config.MachineProfile, args[0])

fmt.Println("Deleting local Kubernetes cluster...")
api, err := machine.NewAPIClient()
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions test/integration/start_stop_delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TestStartStop(t *testing.T) {
Args: *args,
BinaryPath: *binaryPath,
T: t}
runner.RunCommand("delete", false)
runner.RunCommand("delete minikube", false)
runner.CheckStatus(state.None.String())

runner.Start()
Expand Down Expand Up @@ -63,6 +63,6 @@ func TestStartStop(t *testing.T) {
runner.Start()
runner.CheckStatus(state.Running.String())

runner.RunCommand("delete", true)
runner.RunCommand("delete minikube", true)
runner.CheckStatus(state.None.String())
}

0 comments on commit 20c8128

Please sign in to comment.