diff --git a/cmd/minikube/cmd/delete.go b/cmd/minikube/cmd/delete.go index 9125650c0087..6aac39c98f2a 100644 --- a/cmd/minikube/cmd/delete.go +++ b/cmd/minikube/cmd/delete.go @@ -42,6 +42,8 @@ import ( "k8s.io/minikube/pkg/minikube/out" ) +var deleteAll bool + // deleteCmd represents the delete command var deleteCmd = &cobra.Command{ Use: "delete", @@ -51,26 +53,121 @@ associated files.`, Run: runDelete, } +type typeOfError int + +const ( + Fatal typeOfError = 0 + MissingProfile typeOfError = 1 + MissingCluster typeOfError = 2 +) + +type DeletionError struct { + Err error + Errtype typeOfError +} + +func (error DeletionError) Error() string { + return error.Err.Error() +} + // runDelete handles the executes the flow of "minikube delete" func runDelete(cmd *cobra.Command, args []string) { if len(args) > 0 { exit.UsageT("Usage: minikube delete") } - profile := viper.GetString(pkg_config.MachineProfile) + profileFlag, err := cmd.Flags().GetString("profile") + if err != nil { + exit.WithError("Could not get profile flag", err) + } + + if deleteAll { + if profileFlag != constants.DefaultMachineName { + exit.UsageT("usage: minikube delete --all") + } + + validProfiles, invalidProfiles, err := pkg_config.ListProfiles() + profilesToDelete := append(validProfiles, invalidProfiles...) + + if err != nil { + exit.WithError("Error getting profiles to delete", err) + } + + errs := DeleteProfiles(profilesToDelete) + if len(errs) > 0 { + HandleDeletionErrors(errs) + } else { + out.T(out.DeletingHost, "Successfully deleted all profiles") + } + } else { + if len(args) > 0 { + exit.UsageT("usage: minikube delete") + } + + profileName := viper.GetString(pkg_config.MachineProfile) + profile, err := pkg_config.LoadProfile(profileName) + if err != nil { + out.ErrT(out.Meh, `"{{.name}}" profile does not exist`, out.V{"name": profileName}) + } + + errs := DeleteProfiles([]*pkg_config.Profile{profile}) + if len(errs) > 0 { + HandleDeletionErrors(errs) + } else { + out.T(out.DeletingHost, "Successfully deleted profile \"{{.name}}\"", out.V{"name": profileName}) + } + } +} + +// Deletes one or more profiles +func DeleteProfiles(profiles []*pkg_config.Profile) []error { + var errs []error + for _, profile := range profiles { + err := deleteProfile(profile) + + if err != nil { + mm, loadErr := cluster.LoadMachine(profile.Name) + + if !profile.IsValid() || (loadErr != nil || !mm.IsValid()) { + invalidProfileDeletionErrs := deleteInvalidProfile(profile) + if len(invalidProfileDeletionErrs) > 0 { + errs = append(errs, invalidProfileDeletionErrs...) + } + } else { + errs = append(errs, err) + } + } + } + return errs +} + +func deleteProfile(profile *pkg_config.Profile) error { + viper.Set(pkg_config.MachineProfile, profile.Name) + api, err := machine.NewAPIClient() if err != nil { - exit.WithError("Error getting client", err) + delErr := profileDeletionErr(profile.Name, fmt.Sprintf("error getting client %v", err)) + return DeletionError{Err: delErr, Errtype: Fatal} } defer api.Close() cc, err := pkg_config.Load() if err != nil && !os.IsNotExist(err) { out.ErrT(out.Sad, "Error loading profile {{.name}}: {{.error}}", out.V{"name": profile, "error": err}) + delErr := profileDeletionErr(profile.Name, fmt.Sprintf("error loading profile config: %v", err)) + return DeletionError{Err: delErr, Errtype: MissingProfile} } // In the case of "none", we want to uninstall Kubernetes as there is no VM to delete if err == nil && cc.MachineConfig.VMDriver == constants.DriverNone { - uninstallKubernetes(api, cc.KubernetesConfig, viper.GetString(cmdcfg.Bootstrapper)) + if err := uninstallKubernetes(api, cc.KubernetesConfig, viper.GetString(cmdcfg.Bootstrapper)); err != nil { + deletionError, ok := err.(DeletionError) + if ok { + delErr := profileDeletionErr(profile.Name, fmt.Sprintf("%v", err)) + deletionError.Err = delErr + return deletionError + } + return err + } } if err := killMountProcess(); err != nil { @@ -83,39 +180,111 @@ func runDelete(cmd *cobra.Command, args []string) { out.T(out.Meh, `"{{.name}}" cluster does not exist. Proceeding ahead with cleanup.`, out.V{"name": profile}) default: out.T(out.FailureType, "Failed to delete cluster: {{.error}}", out.V{"error": err}) - out.T(out.Notice, `You may need to manually remove the "{{.name}}" VM from your hypervisor`, out.V{"name": profile}) + out.T(out.Notice, `You may need to manually remove the "{{.name}}" VM from your hypervisor`, out.V{"name": profile.Name}) } } // In case DeleteHost didn't complete the job. - deleteProfileDirectory(profile) + deleteProfileDirectory(profile.Name) - if err := pkg_config.DeleteProfile(profile); err != nil { + if err := pkg_config.DeleteProfile(profile.Name); err != nil { if os.IsNotExist(err) { - out.T(out.Meh, `"{{.name}}" profile does not exist`, out.V{"name": profile}) - os.Exit(0) + delErr := profileDeletionErr(profile.Name, fmt.Sprintf("\"%s\" profile does not exist", profile.Name)) + return DeletionError{Err: delErr, Errtype: MissingProfile} } - exit.WithError("Failed to remove profile", err) + delErr := profileDeletionErr(profile.Name, fmt.Sprintf("failed to remove profile %v", err)) + return DeletionError{Err: delErr, Errtype: Fatal} } - out.T(out.Crushed, `The "{{.name}}" cluster has been deleted.`, out.V{"name": profile}) + + out.T(out.Crushed, `The "{{.name}}" cluster has been deleted.`, out.V{"name": profile.Name}) machineName := pkg_config.GetMachineName() if err := kubeconfig.DeleteContext(constants.KubeconfigPath, machineName); err != nil { - exit.WithError("update config", err) + return DeletionError{Err: fmt.Errorf("update config: %v", err), Errtype: Fatal} } if err := cmdcfg.Unset(pkg_config.MachineProfile); err != nil { - exit.WithError("unset minikube profile", err) + return DeletionError{Err: fmt.Errorf("unset minikube profile: %v", err), Errtype: Fatal} } + return nil } -func uninstallKubernetes(api libmachine.API, kc pkg_config.KubernetesConfig, bsName string) { +func deleteInvalidProfile(profile *pkg_config.Profile) []error { + out.T(out.DeletingHost, "Trying to delete invalid profile {{.profile}}", out.V{"profile": profile.Name}) + + var errs []error + pathToProfile := pkg_config.ProfileFolderPath(profile.Name, localpath.MiniPath()) + if _, err := os.Stat(pathToProfile); !os.IsNotExist(err) { + err := os.RemoveAll(pathToProfile) + if err != nil { + errs = append(errs, DeletionError{err, Fatal}) + } + } + + pathToMachine := cluster.MachinePath(profile.Name, localpath.MiniPath()) + if _, err := os.Stat(pathToMachine); !os.IsNotExist(err) { + err := os.RemoveAll(pathToMachine) + if err != nil { + errs = append(errs, DeletionError{err, Fatal}) + } + } + return errs +} + +func profileDeletionErr(profileName string, additionalInfo string) error { + return fmt.Errorf("error deleting profile \"%s\": %s", profileName, additionalInfo) +} + +func uninstallKubernetes(api libmachine.API, kc pkg_config.KubernetesConfig, bsName string) error { out.T(out.Resetting, "Uninstalling Kubernetes {{.kubernetes_version}} using {{.bootstrapper_name}} ...", out.V{"kubernetes_version": kc.KubernetesVersion, "bootstrapper_name": bsName}) clusterBootstrapper, err := getClusterBootstrapper(api, bsName) if err != nil { - out.ErrT(out.Empty, "Unable to get bootstrapper: {{.error}}", out.V{"error": err}) + return DeletionError{Err: fmt.Errorf("unable to get bootstrapper: %v", err), Errtype: Fatal} } else if err = clusterBootstrapper.DeleteCluster(kc); err != nil { - out.ErrT(out.Empty, "Failed to delete cluster: {{.error}}", out.V{"error": err}) + return DeletionError{Err: fmt.Errorf("failed to delete cluster: %v", err), Errtype: Fatal} + } + return nil +} + +// Handles deletion error from DeleteProfiles +func HandleDeletionErrors(errors []error) { + if len(errors) == 1 { + handleSingleDeletionError(errors[0]) + } else { + handleMultipleDeletionErrors(errors) + } +} + +func handleSingleDeletionError(err error) { + deletionError, ok := err.(DeletionError) + + if ok { + switch deletionError.Errtype { + case Fatal: + out.FatalT(deletionError.Error()) + case MissingProfile: + out.ErrT(out.Sad, deletionError.Error()) + case MissingCluster: + out.ErrT(out.Meh, deletionError.Error()) + default: + out.FatalT(deletionError.Error()) + } + } else { + exit.WithError("Could not process error from failed deletion", err) + } +} + +func handleMultipleDeletionErrors(errors []error) { + out.ErrT(out.Sad, "Multiple errors deleting profiles") + + for _, err := range errors { + deletionError, ok := err.(DeletionError) + + if ok { + glog.Errorln(deletionError.Error()) + } else { + exit.WithError("Could not process errors from failed deletion", err) + } } } @@ -177,3 +346,8 @@ func killMountProcess() error { } return nil } + +func init() { + deleteCmd.Flags().BoolVar(&deleteAll, "all", false, "Set flag to delete all profiles") + RootCmd.AddCommand(deleteCmd) +} diff --git a/cmd/minikube/cmd/delete_test.go b/cmd/minikube/cmd/delete_test.go new file mode 100644 index 000000000000..042b86dd4cc8 --- /dev/null +++ b/cmd/minikube/cmd/delete_test.go @@ -0,0 +1,493 @@ +/* +Copyright 2016 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package cmd + +import ( + "io/ioutil" + "os" + "path/filepath" + "testing" + + "github.com/spf13/viper" + "k8s.io/minikube/pkg/minikube/cluster" + "k8s.io/minikube/pkg/minikube/config" + "k8s.io/minikube/pkg/minikube/localpath" +) + +func TestDeleteProfileWithValidConfig(t *testing.T) { + testMinikubeDir := "../../../pkg/minikube/config/testdata/delete-single/.minikube" + miniDir, err := filepath.Abs(testMinikubeDir) + + if err != nil { + t.Errorf("error getting dir path for %s : %v", testMinikubeDir, err) + } + + err = os.Setenv(localpath.MinikubeHome, miniDir) + if err != nil { + t.Errorf("error setting up test environment. could not set %s", localpath.MinikubeHome) + } + + files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "profiles")) + numberOfProfileDirs := len(files) + + files, _ = ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "machines")) + numberOfMachineDirs := len(files) + + profileToDelete := "p1" + profile, _ := config.LoadProfile(profileToDelete) + + errs := DeleteProfiles([]*config.Profile{profile}) + + if len(errs) > 0 { + HandleDeletionErrors(errs) + t.Fatal("Errors while deleting profiles") + } + + pathToProfile := config.ProfileFolderPath(profile.Name, localpath.MiniPath()) + if _, err := os.Stat(pathToProfile); !os.IsNotExist(err) { + t.Fatalf("Profile folder of profile \"%s\" was not deleted", profile.Name) + } + + pathToMachine := cluster.MachinePath(profile.Name, localpath.MiniPath()) + if _, err := os.Stat(pathToMachine); !os.IsNotExist(err) { + t.Fatalf("Profile folder of profile \"%s\" was not deleted", profile.Name) + } + + if files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "profiles")); len(files) != (numberOfProfileDirs - 1) { + t.Fatal("Did not delete exactly one profile") + } + + if files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "machines")); len(files) != (numberOfMachineDirs - 1) { + t.Fatal("Did not delete exactly one profile") + } + + viper.Set(config.MachineProfile, "") +} + +func TestDeleteProfileWithEmptyProfileConfig(t *testing.T) { + testMinikubeDir := "../../../pkg/minikube/config/testdata/delete-single/.minikube" + miniDir, err := filepath.Abs(testMinikubeDir) + + if err != nil { + t.Errorf("error getting dir path for %s : %v", testMinikubeDir, err) + } + + err = os.Setenv(localpath.MinikubeHome, miniDir) + if err != nil { + t.Errorf("error setting up test environment. could not set %s", localpath.MinikubeHome) + } + + files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "profiles")) + numberOfProfileDirs := len(files) + + files, _ = ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "machines")) + numberOfMachineDirs := len(files) + + profileToDelete := "p2_empty_profile_config" + profile, _ := config.LoadProfile(profileToDelete) + + errs := DeleteProfiles([]*config.Profile{profile}) + + if len(errs) > 0 { + HandleDeletionErrors(errs) + t.Fatal("Errors while deleting profiles") + } + + pathToProfile := config.ProfileFolderPath(profile.Name, localpath.MiniPath()) + if _, err := os.Stat(pathToProfile); !os.IsNotExist(err) { + t.Fatalf("Profile folder of profile \"%s\" was not deleted", profile.Name) + } + + pathToMachine := cluster.MachinePath(profile.Name, localpath.MiniPath()) + if _, err := os.Stat(pathToMachine); !os.IsNotExist(err) { + t.Fatalf("Profile folder of profile \"%s\" was not deleted", profile.Name) + } + + if files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "profiles")); len(files) != (numberOfProfileDirs - 1) { + t.Fatal("Did not delete exactly one profile") + } + + if files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "machines")); len(files) != (numberOfMachineDirs - 1) { + t.Fatal("Did not delete exactly one profile") + } + + viper.Set(config.MachineProfile, "") +} + +func TestDeleteProfileWithInvalidProfileConfig(t *testing.T) { + testMinikubeDir := "../../../pkg/minikube/config/testdata/delete-single/.minikube" + miniDir, err := filepath.Abs(testMinikubeDir) + + if err != nil { + t.Errorf("error getting dir path for %s : %v", testMinikubeDir, err) + } + + err = os.Setenv(localpath.MinikubeHome, miniDir) + if err != nil { + t.Errorf("error setting up test environment. could not set %s", localpath.MinikubeHome) + } + + files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "profiles")) + numberOfProfileDirs := len(files) + + files, _ = ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "machines")) + numberOfMachineDirs := len(files) + + profileToDelete := "p3_invalid_profile_config" + profile, _ := config.LoadProfile(profileToDelete) + + errs := DeleteProfiles([]*config.Profile{profile}) + + if len(errs) > 0 { + HandleDeletionErrors(errs) + t.Fatal("Errors while deleting profiles") + } + + pathToProfile := config.ProfileFolderPath(profile.Name, localpath.MiniPath()) + if _, err := os.Stat(pathToProfile); !os.IsNotExist(err) { + t.Fatalf("Profile folder of profile \"%s\" was not deleted", profile.Name) + } + + pathToMachine := cluster.MachinePath(profile.Name, localpath.MiniPath()) + if _, err := os.Stat(pathToMachine); !os.IsNotExist(err) { + t.Fatalf("Profile folder of profile \"%s\" was not deleted", profile.Name) + } + + if files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "profiles")); len(files) != (numberOfProfileDirs - 1) { + t.Fatal("Did not delete exactly one profile") + } + + if files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "machines")); len(files) != (numberOfMachineDirs - 1) { + t.Fatal("Did not delete exactly one profile") + } + + viper.Set(config.MachineProfile, "") +} + +func TestDeleteProfileWithPartialProfileConfig(t *testing.T) { + testMinikubeDir := "../../../pkg/minikube/config/testdata/delete-single/.minikube" + miniDir, err := filepath.Abs(testMinikubeDir) + + if err != nil { + t.Errorf("error getting dir path for %s : %v", testMinikubeDir, err) + } + + err = os.Setenv(localpath.MinikubeHome, miniDir) + if err != nil { + t.Errorf("error setting up test environment. could not set %s", localpath.MinikubeHome) + } + + files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "profiles")) + numberOfProfileDirs := len(files) + + files, _ = ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "machines")) + numberOfMachineDirs := len(files) + + profileToDelete := "p4_partial_profile_config" + profile, _ := config.LoadProfile(profileToDelete) + + errs := DeleteProfiles([]*config.Profile{profile}) + + if len(errs) > 0 { + HandleDeletionErrors(errs) + t.Fatal("Errors while deleting profiles") + } + + pathToProfile := config.ProfileFolderPath(profile.Name, localpath.MiniPath()) + if _, err := os.Stat(pathToProfile); !os.IsNotExist(err) { + t.Fatalf("Profile folder of profile \"%s\" was not deleted", profile.Name) + } + + pathToMachine := cluster.MachinePath(profile.Name, localpath.MiniPath()) + if _, err := os.Stat(pathToMachine); !os.IsNotExist(err) { + t.Fatalf("Profile folder of profile \"%s\" was not deleted", profile.Name) + } + + if files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "profiles")); len(files) != (numberOfProfileDirs - 1) { + t.Fatal("Did not delete exactly one profile") + } + + if files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "machines")); len(files) != (numberOfMachineDirs - 1) { + t.Fatal("Did not delete exactly one profile") + } + + viper.Set(config.MachineProfile, "") +} + +func TestDeleteProfileWithMissingMachineConfig(t *testing.T) { + testMinikubeDir := "../../../pkg/minikube/config/testdata/delete-single/.minikube" + miniDir, err := filepath.Abs(testMinikubeDir) + + if err != nil { + t.Errorf("error getting dir path for %s : %v", testMinikubeDir, err) + } + + err = os.Setenv(localpath.MinikubeHome, miniDir) + if err != nil { + t.Errorf("error setting up test environment. could not set %s", localpath.MinikubeHome) + } + + files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "profiles")) + numberOfProfileDirs := len(files) + + files, _ = ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "machines")) + numberOfMachineDirs := len(files) + + profileToDelete := "p5_missing_machine_config" + profile, _ := config.LoadProfile(profileToDelete) + + errs := DeleteProfiles([]*config.Profile{profile}) + + if len(errs) > 0 { + HandleDeletionErrors(errs) + t.Fatal("Errors while deleting profiles") + } + + pathToProfile := config.ProfileFolderPath(profile.Name, localpath.MiniPath()) + if _, err := os.Stat(pathToProfile); !os.IsNotExist(err) { + t.Fatalf("Profile folder of profile \"%s\" was not deleted", profile.Name) + } + + pathToMachine := cluster.MachinePath(profile.Name, localpath.MiniPath()) + if _, err := os.Stat(pathToMachine); !os.IsNotExist(err) { + t.Fatalf("Profile folder of profile \"%s\" was not deleted", profile.Name) + } + + if files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "profiles")); len(files) != (numberOfProfileDirs - 1) { + t.Fatal("Did not delete exactly one profile") + } + + if files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "machines")); len(files) != numberOfMachineDirs { + t.Fatal("Deleted a machine config when it should not") + } + + viper.Set(config.MachineProfile, "") +} + +func TestDeleteProfileWithEmptyMachineConfig(t *testing.T) { + testMinikubeDir := "../../../pkg/minikube/config/testdata/delete-single/.minikube" + miniDir, err := filepath.Abs(testMinikubeDir) + + if err != nil { + t.Errorf("error getting dir path for %s : %v", testMinikubeDir, err) + } + + err = os.Setenv(localpath.MinikubeHome, miniDir) + if err != nil { + t.Errorf("error setting up test environment. could not set %s", localpath.MinikubeHome) + } + + files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "profiles")) + numberOfProfileDirs := len(files) + + files, _ = ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "machines")) + numberOfMachineDirs := len(files) + + profileToDelete := "p6_empty_machine_config" + profile, _ := config.LoadProfile(profileToDelete) + + errs := DeleteProfiles([]*config.Profile{profile}) + + if len(errs) > 0 { + HandleDeletionErrors(errs) + t.Fatal("Errors while deleting profiles") + } + + pathToProfile := config.ProfileFolderPath(profile.Name, localpath.MiniPath()) + if _, err := os.Stat(pathToProfile); !os.IsNotExist(err) { + t.Fatalf("Profile folder of profile \"%s\" was not deleted", profile.Name) + } + + pathToMachine := cluster.MachinePath(profile.Name, localpath.MiniPath()) + if _, err := os.Stat(pathToMachine); !os.IsNotExist(err) { + t.Fatalf("Profile folder of profile \"%s\" was not deleted", profile.Name) + } + + if files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "profiles")); len(files) != (numberOfProfileDirs - 1) { + t.Fatal("Did not delete exactly one profile") + } + + if files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "machines")); len(files) != (numberOfMachineDirs - 1) { + t.Fatal("Did not delete exactly one profile") + } + + viper.Set(config.MachineProfile, "") +} + +func TestDeleteProfileWithInvalidMachineConfig(t *testing.T) { + testMinikubeDir := "../../../pkg/minikube/config/testdata/delete-single/.minikube" + miniDir, err := filepath.Abs(testMinikubeDir) + + if err != nil { + t.Errorf("error getting dir path for %s : %v", testMinikubeDir, err) + } + + err = os.Setenv(localpath.MinikubeHome, miniDir) + if err != nil { + t.Errorf("error setting up test environment. could not set %s", localpath.MinikubeHome) + } + + files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "profiles")) + numberOfProfileDirs := len(files) + + files, _ = ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "machines")) + numberOfMachineDirs := len(files) + + profileToDelete := "p7_invalid_machine_config" + profile, _ := config.LoadProfile(profileToDelete) + + errs := DeleteProfiles([]*config.Profile{profile}) + + if len(errs) > 0 { + HandleDeletionErrors(errs) + t.Fatal("Errors while deleting profiles") + } + + pathToProfile := config.ProfileFolderPath(profile.Name, localpath.MiniPath()) + if _, err := os.Stat(pathToProfile); !os.IsNotExist(err) { + t.Fatalf("Profile folder of profile \"%s\" was not deleted", profile.Name) + } + + pathToMachine := cluster.MachinePath(profile.Name, localpath.MiniPath()) + if _, err := os.Stat(pathToMachine); !os.IsNotExist(err) { + t.Fatalf("Profile folder of profile \"%s\" was not deleted", profile.Name) + } + + if files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "profiles")); len(files) != (numberOfProfileDirs - 1) { + t.Fatal("Did not delete exactly one profile") + } + + if files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "machines")); len(files) != (numberOfMachineDirs - 1) { + t.Fatal("Did not delete exactly one profile") + } + + viper.Set(config.MachineProfile, "") +} + +func TestDeleteProfileWithPartialMachineConfig(t *testing.T) { + testMinikubeDir := "../../../pkg/minikube/config/testdata/delete-single/.minikube" + miniDir, err := filepath.Abs(testMinikubeDir) + + if err != nil { + t.Errorf("error getting dir path for %s : %v", testMinikubeDir, err) + } + + err = os.Setenv(localpath.MinikubeHome, miniDir) + if err != nil { + t.Errorf("error setting up test environment. could not set %s", localpath.MinikubeHome) + } + + files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "profiles")) + numberOfProfileDirs := len(files) + + files, _ = ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "machines")) + numberOfMachineDirs := len(files) + + profileToDelete := "p8_partial_machine_config" + profile, _ := config.LoadProfile(profileToDelete) + + errs := DeleteProfiles([]*config.Profile{profile}) + + if len(errs) > 0 { + HandleDeletionErrors(errs) + t.Fatal("Errors while deleting profiles") + } + + pathToProfile := config.ProfileFolderPath(profile.Name, localpath.MiniPath()) + if _, err := os.Stat(pathToProfile); !os.IsNotExist(err) { + t.Fatalf("Profile folder of profile \"%s\" was not deleted", profile.Name) + } + + pathToMachine := cluster.MachinePath(profile.Name, localpath.MiniPath()) + if _, err := os.Stat(pathToMachine); !os.IsNotExist(err) { + t.Fatalf("Profile folder of profile \"%s\" was not deleted", profile.Name) + } + + if files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "profiles")); len(files) != (numberOfProfileDirs - 1) { + t.Fatal("Did not delete exactly one profile") + } + + if files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "machines")); len(files) != (numberOfMachineDirs - 1) { + t.Fatal("Did not delete exactly one profile") + } + + viper.Set(config.MachineProfile, "") +} + +func TestDeleteAllProfiles(t *testing.T) { + const numberOfTotalProfileDirs = 8 + const numberOfTotalMachineDirs = 7 + + testMinikubeDir := "../../../pkg/minikube/config/testdata/delete-all/.minikube" + miniDir, err := filepath.Abs(testMinikubeDir) + + if err != nil { + t.Errorf("error getting dir path for %s : %v", testMinikubeDir, err) + } + + err = os.Setenv(localpath.MinikubeHome, miniDir) + if err != nil { + t.Errorf("error setting up test environment. could not set %s", localpath.MinikubeHome) + } + + files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "profiles")) + numberOfProfileDirs := len(files) + + files, _ = ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "machines")) + numberOfMachineDirs := len(files) + + if numberOfTotalProfileDirs != numberOfProfileDirs { + t.Error("invalid testdata") + } + + if numberOfTotalMachineDirs != numberOfMachineDirs { + t.Error("invalid testdata") + } + + validProfiles, inValidProfiles, err := config.ListProfiles() + + if err != nil { + t.Error(err) + } + + if numberOfTotalProfileDirs != len(validProfiles)+len(inValidProfiles) { + t.Error("invalid testdata") + } + + profiles := append(validProfiles, inValidProfiles...) + errs := DeleteProfiles(profiles) + + if errs != nil { + t.Errorf("errors while deleting all profiles: %v", errs) + } + + files, _ = ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "profiles")) + numberOfProfileDirs = len(files) + + files, _ = ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "machines")) + numberOfMachineDirs = len(files) + + if numberOfProfileDirs != 0 { + t.Errorf("Did not delete all profiles: still %d profiles left", numberOfProfileDirs) + } + + if numberOfMachineDirs != 0 { + t.Errorf("Did not delete all profiles: still %d machines left", numberOfMachineDirs) + } + + viper.Set(config.MachineProfile, "") +} diff --git a/hack/jenkins/common.sh b/hack/jenkins/common.sh index 4baa6f5326ad..96a6658b3776 100755 --- a/hack/jenkins/common.sh +++ b/hack/jenkins/common.sh @@ -109,6 +109,8 @@ for entry in $(ls ${TEST_ROOT}); do sudo rm -Rf "${home}" done + ${MINIKUBE_BIN} delete --all || true + for kconfig in $(find ${entry} -name kubeconfig -type f); do sudo rm -f "${kconfig}" done diff --git a/pkg/minikube/cluster/machine.go b/pkg/minikube/cluster/machine.go new file mode 100644 index 000000000000..8a24b04e3c66 --- /dev/null +++ b/pkg/minikube/cluster/machine.go @@ -0,0 +1,127 @@ +/* +Copyright 2019 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package cluster + +import ( + "io/ioutil" + "path/filepath" + + "github.com/docker/machine/libmachine/host" + "github.com/pkg/errors" + "k8s.io/minikube/pkg/minikube/localpath" + "k8s.io/minikube/pkg/minikube/machine" +) + +type Machine struct { + *host.Host +} + +// IsValid checks if the machine has the essential info needed for a machine +func (h *Machine) IsValid() bool { + if h == nil { + return false + } + + if h.Host == nil { + return false + } + + if h.Host.Name == "" { + return false + } + + if h.Host.Driver == nil { + return false + } + + if h.Host.HostOptions == nil { + return false + } + + if h.Host.RawDriver == nil { + return false + } + return true +} + +// ListsMachines return all valid and invalid machines +// If a machine is valid or invalid is determined by the cluster.IsValid function +func ListMachines(miniHome ...string) (validMachines []*Machine, inValidMachines []*Machine, err error) { + pDirs, err := machineDirs(miniHome...) + if err != nil { + return nil, nil, err + } + for _, n := range pDirs { + p, err := LoadMachine(n) + if err != nil { + inValidMachines = append(inValidMachines, p) + continue + } + if !p.IsValid() { + inValidMachines = append(inValidMachines, p) + continue + } + validMachines = append(validMachines, p) + } + return validMachines, inValidMachines, nil +} + +// Loads a machine or throws an error if the machine could not be loadedG +func LoadMachine(name string) (*Machine, error) { + api, err := machine.NewAPIClient() + if err != nil { + return nil, err + } + + h, err := CheckIfHostExistsAndLoad(api, name) + if err != nil { + return nil, err + } + + var mm Machine + if h != nil { + mm.Host = h + } else { + return nil, errors.New("host is nil") + } + + return &mm, nil +} + +func machineDirs(miniHome ...string) (dirs []string, err error) { + miniPath := localpath.MiniPath() + if len(miniHome) > 0 { + miniPath = miniHome[0] + } + mRootDir := filepath.Join(miniPath, "machines") + items, err := ioutil.ReadDir(mRootDir) + for _, f := range items { + if f.IsDir() { + dirs = append(dirs, f.Name()) + } + } + return dirs, err +} + +// MachinePath returns the Minikube machine path of a machine +func MachinePath(machine string, miniHome ...string) string { + miniPath := localpath.MiniPath() + if len(miniHome) > 0 { + miniPath = miniHome[0] + } + return filepath.Join(miniPath, "machines", machine) +} diff --git a/pkg/minikube/cluster/machine_test.go b/pkg/minikube/cluster/machine_test.go new file mode 100644 index 000000000000..a04f40aa8b78 --- /dev/null +++ b/pkg/minikube/cluster/machine_test.go @@ -0,0 +1,75 @@ +/* +Copyright 2019 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package cluster + +import ( + "io/ioutil" + "os" + "path/filepath" + "testing" + + "github.com/spf13/viper" + "k8s.io/minikube/pkg/minikube/config" + "k8s.io/minikube/pkg/minikube/localpath" +) + +func TestListMachines(t *testing.T) { + const ( + numberOfValidMachines = 2 + numberOfInValidMachines = 3 + totalNumberOfMachines = numberOfValidMachines + numberOfInValidMachines + ) + + viper.Set(config.MachineProfile, "") + + testMinikubeDir := "./testdata/list-machines/.minikube" + miniDir, err := filepath.Abs(testMinikubeDir) + + if err != nil { + t.Errorf("error getting dir path for %s : %v", testMinikubeDir, err) + } + + err = os.Setenv(localpath.MinikubeHome, miniDir) + if err != nil { + t.Errorf("error setting up test environment. could not set %s", localpath.MinikubeHome) + } + + files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "machines")) + numberOfMachineDirs := len(files) + + validMachines, inValidMachines, err := ListMachines() + + if err != nil { + t.Error(err) + } + + if numberOfValidMachines != len(validMachines) { + t.Errorf("expected %d valid machines, got %d", numberOfValidMachines, len(validMachines)) + } + + if numberOfInValidMachines != len(inValidMachines) { + t.Errorf("expected %d invalid machines, got %d", numberOfInValidMachines, len(inValidMachines)) + } + + if totalNumberOfMachines != len(validMachines)+len(inValidMachines) { + t.Errorf("expected %d total machines, got %d", totalNumberOfMachines, len(validMachines)+len(inValidMachines)) + } + + if numberOfMachineDirs != len(validMachines)+len(inValidMachines) { + t.Error("expected number of machine directories to be equal to the number of total machines") + } +} diff --git a/pkg/minikube/cluster/testdata/list-machines/.minikube/machines/p1/config.json b/pkg/minikube/cluster/testdata/list-machines/.minikube/machines/p1/config.json new file mode 100644 index 000000000000..83a27c78b244 --- /dev/null +++ b/pkg/minikube/cluster/testdata/list-machines/.minikube/machines/p1/config.json @@ -0,0 +1,80 @@ +{ + "ConfigVersion": 3, + "Driver": { + "IPAddress": "192.168.64.50", + "MachineName": "p1", + "SSHUser": "docker", + "SSHPort": 22, + "SSHKeyPath": "/Users/someuser/.minikube/machines/p1/id_rsa", + "StorePath": "/Users/someuser/.minikube", + "SwarmMaster": false, + "SwarmHost": "", + "SwarmDiscovery": "", + "Boot2DockerURL": "file:///Users/someuser/.minikube/cache/iso/minikube-v1.2.0.iso", + "DiskSize": 20000, + "CPU": 2, + "Memory": 2000, + "Cmdline": "loglevel=3 user=docker console=ttyS0 console=tty0 noembed nomodeset norestore waitusb=10 systemd.legacy_systemd_cgroup_controller=yes base host=p1", + "NFSShares": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "5e6787b6-aecb-11e9-81cf-8c8590c3b8b4", + "BootKernel": "/Users/someuser/.minikube/machines/p1/b2d-image/boot/bzImage", + "BootInitrd": "/Users/someuser/.minikube/machines/p1/b2d-image/boot/initrd", + "Initrd": "initrd", + "Vmlinuz": "bzImage" + }, + "DriverName": "virtualbox", + "HostOptions": { + "Driver": "", + "Memory": 0, + "Disk": 0, + "EngineOptions": { + "ArbitraryFlags": null, + "Dns": null, + "GraphDir": "", + "Env": null, + "Ipv6": false, + "InsecureRegistry": [ + "10.96.0.0/12" + ], + "Labels": null, + "LogLevel": "", + "StorageDriver": "", + "SelinuxEnabled": false, + "TlsVerify": false, + "RegistryMirror": null, + "InstallURL": "" + }, + "SwarmOptions": { + "IsSwarm": false, + "Address": "", + "Discovery": "", + "Agent": false, + "Master": false, + "Host": "tcp://0.0.0.0:3376", + "Image": "swarm:latest", + "Strategy": "spread", + "Heartbeat": 0, + "Overcommit": 0, + "ArbitraryFlags": null, + "ArbitraryJoinFlags": null, + "Env": null, + "IsExperimental": false + }, + "AuthOptions": { + "CertDir": "/Users/someuser/.minikube", + "CaCertPath": "/Users/someuser/.minikube/certs/ca.pem", + "CaPrivateKeyPath": "/Users/someuser/.minikube/certs/ca-key.pem", + "CaCertRemotePath": "", + "ServerCertPath": "/Users/someuser/.minikube/machines/server.pem", + "ServerKeyPath": "/Users/someuser/.minikube/machines/server-key.pem", + "ClientKeyPath": "/Users/someuser/.minikube/certs/key.pem", + "ServerCertRemotePath": "", + "ServerKeyRemotePath": "", + "ClientCertPath": "/Users/someuser/.minikube/certs/cert.pem", + "ServerCertSANs": null, + "StorePath": "/Users/someuser/.minikube" + } + }, + "Name": "p1" +} diff --git a/pkg/minikube/cluster/testdata/list-machines/.minikube/machines/p2/config.json b/pkg/minikube/cluster/testdata/list-machines/.minikube/machines/p2/config.json new file mode 100644 index 000000000000..4bb1814211cc --- /dev/null +++ b/pkg/minikube/cluster/testdata/list-machines/.minikube/machines/p2/config.json @@ -0,0 +1,80 @@ +{ + "ConfigVersion": 3, + "Driver": { + "IPAddress": "192.168.64.50", + "MachineName": "p2", + "SSHUser": "docker", + "SSHPort": 22, + "SSHKeyPath": "/Users/someuser/.minikube/machines/p2/id_rsa", + "StorePath": "/Users/someuser/.minikube", + "SwarmMaster": false, + "SwarmHost": "", + "SwarmDiscovery": "", + "Boot2DockerURL": "file:///Users/someuser/.minikube/cache/iso/minikube-v1.2.0.iso", + "DiskSize": 20000, + "CPU": 2, + "Memory": 2000, + "Cmdline": "loglevel=3 user=docker console=ttyS0 console=tty0 noembed nomodeset norestore waitusb=10 systemd.legacy_systemd_cgroup_controller=yes base host=p2", + "NFSShares": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "5e6787b6-aecb-11e9-81cf-8c8590c3b8b4", + "BootKernel": "/Users/someuser/.minikube/machines/p2/b2d-image/boot/bzImage", + "BootInitrd": "/Users/someuser/.minikube/machines/p2/b2d-image/boot/initrd", + "Initrd": "initrd", + "Vmlinuz": "bzImage" + }, + "DriverName": "virtualbox", + "HostOptions": { + "Driver": "", + "Memory": 0, + "Disk": 0, + "EngineOptions": { + "ArbitraryFlags": null, + "Dns": null, + "GraphDir": "", + "Env": null, + "Ipv6": false, + "InsecureRegistry": [ + "10.96.0.0/12" + ], + "Labels": null, + "LogLevel": "", + "StorageDriver": "", + "SelinuxEnabled": false, + "TlsVerify": false, + "RegistryMirror": null, + "InstallURL": "" + }, + "SwarmOptions": { + "IsSwarm": false, + "Address": "", + "Discovery": "", + "Agent": false, + "Master": false, + "Host": "tcp://0.0.0.0:3376", + "Image": "swarm:latest", + "Strategy": "spread", + "Heartbeat": 0, + "Overcommit": 0, + "ArbitraryFlags": null, + "ArbitraryJoinFlags": null, + "Env": null, + "IsExperimental": false + }, + "AuthOptions": { + "CertDir": "/Users/someuser/.minikube", + "CaCertPath": "/Users/someuser/.minikube/certs/ca.pem", + "CaPrivateKeyPath": "/Users/someuser/.minikube/certs/ca-key.pem", + "CaCertRemotePath": "", + "ServerCertPath": "/Users/someuser/.minikube/machines/server.pem", + "ServerKeyPath": "/Users/someuser/.minikube/machines/server-key.pem", + "ClientKeyPath": "/Users/someuser/.minikube/certs/key.pem", + "ServerCertRemotePath": "", + "ServerKeyRemotePath": "", + "ClientCertPath": "/Users/someuser/.minikube/certs/cert.pem", + "ServerCertSANs": null, + "StorePath": "/Users/someuser/.minikube" + } + }, + "Name": "p2" +} diff --git a/pkg/minikube/config/testdata/.minikube/profiles/p3_empty/config.json b/pkg/minikube/cluster/testdata/list-machines/.minikube/machines/p3_empty_config/config.json similarity index 100% rename from pkg/minikube/config/testdata/.minikube/profiles/p3_empty/config.json rename to pkg/minikube/cluster/testdata/list-machines/.minikube/machines/p3_empty_config/config.json diff --git a/pkg/minikube/cluster/testdata/list-machines/.minikube/machines/p4_invalid_machine_config/config.json b/pkg/minikube/cluster/testdata/list-machines/.minikube/machines/p4_invalid_machine_config/config.json new file mode 100644 index 000000000000..581f9e648f6b --- /dev/null +++ b/pkg/minikube/cluster/testdata/list-machines/.minikube/machines/p4_invalid_machine_config/config.json @@ -0,0 +1 @@ +invalid json file :) diff --git a/pkg/minikube/cluster/testdata/list-machines/.minikube/machines/p5_partial_config/config.json b/pkg/minikube/cluster/testdata/list-machines/.minikube/machines/p5_partial_config/config.json new file mode 100644 index 000000000000..d7b7092761f3 --- /dev/null +++ b/pkg/minikube/cluster/testdata/list-machines/.minikube/machines/p5_partial_config/config.json @@ -0,0 +1,72 @@ +{ + "ConfigVersion": 3, + "Driver": { + "SSHUser": "docker", + "SSHPort": 22, + "SSHKeyPath": "/Users/someuser/.minikube/machines/p5_partial_config/id_rsa", + "StorePath": "/Users/someuser/.minikube", + "SwarmMaster": false, + "SwarmHost": "", + "SwarmDiscovery": "", + "DiskSize": 20000, + "CPU": 2, + "Memory": 2000, + "Cmdline": "loglevel=3 user=docker console=ttyS0 console=tty0 noembed nomodeset norestore waitusb=10 systemd.legacy_systemd_cgroup_controller=yes base host=p5_partial_config", + "NFSShares": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "4f16872c-aee8-11e9-8815-8c8590c3b8b4", + "BootKernel": "/Users/someuser/.minikube/machines/p5_partial_config/b2d-image/boot/bzImage", + "BootInitrd": "/Users/someuser/.minikube/machines/p5_partial_config/b2d-image/boot/initrd", + "Initrd": "initrd", + "Vmlinuz": "bzImage" + }, + "HostOptions": { + "Driver": "", + "Memory": 0, + "Disk": 0, + "EngineOptions": { + "ArbitraryFlags": null, + "Dns": null, + "GraphDir": "", + "Env": null, + "Ipv6": false, + "InsecureRegistry": [ + "10.96.0.0/12" + ], + "Labels": null, + "LogLevel": "", + "StorageDriver": "", + "SelinuxEnabled": false, + "TlsVerify": false, + "RegistryMirror": null, + "InstallURL": "" + }, + "SwarmOptions": { + "IsSwarm": false, + "Address": "", + "Discovery": "", + "Agent": false, + "Master": false, + "Host": "tcp://0.0.0.0:3376", + "Image": "swarm:latest", + "Strategy": "spread", + "Heartbeat": 0, + "Overcommit": 0, + "ArbitraryFlags": null, + "ArbitraryJoinFlags": null, + "Env": null, + "IsExperimental": false + }, + "AuthOptions": { + "CertDir": "/Users/someuser/.minikube", + "CaCertPath": "/Users/someuser/.minikube/certs/ca.pem", + "CaPrivateKeyPath": "/Users/someuser/.minikube/certs/ca-key.pem", + "CaCertRemotePath": "", + "ServerCertRemotePath": "", + "ServerKeyRemotePath": "", + "ClientCertPath": "/Users/someuser/.minikube/certs/cert.pem", + "ServerCertSANs": null, + "StorePath": "/Users/someuser/.minikube" + } + }, +} diff --git a/pkg/minikube/config/profile.go b/pkg/minikube/config/profile.go index 9280c6de9afa..2c09f4b44620 100644 --- a/pkg/minikube/config/profile.go +++ b/pkg/minikube/config/profile.go @@ -27,8 +27,12 @@ import ( "k8s.io/minikube/pkg/util/lock" ) -// isValid checks if the profile has the essential info needed for a profile -func (p *Profile) isValid() bool { +// IsValid checks if the profile has the essential info needed for a profile +func (p *Profile) IsValid() bool { + if p.Config == nil { + return false + } + if p.Config.MachineConfig.VMDriver == "" { return false } @@ -106,7 +110,7 @@ func DeleteProfile(profile string, miniHome ...string) error { if len(miniHome) > 0 { miniPath = miniHome[0] } - return os.RemoveAll(profileFolderPath(profile, miniPath)) + return os.RemoveAll(ProfileFolderPath(profile, miniPath)) } // ListProfiles returns all valid and invalid (if any) minikube profiles @@ -118,12 +122,12 @@ func ListProfiles(miniHome ...string) (validPs []*Profile, inValidPs []*Profile, return nil, nil, err } for _, n := range pDirs { - p, err := loadProfile(n, miniHome...) + p, err := LoadProfile(n, miniHome...) if err != nil { inValidPs = append(inValidPs, p) continue } - if !p.isValid() { + if !p.IsValid() { inValidPs = append(inValidPs, p) continue } @@ -133,7 +137,7 @@ func ListProfiles(miniHome ...string) (validPs []*Profile, inValidPs []*Profile, } // loadProfile loads type Profile based on its name -func loadProfile(name string, miniHome ...string) (*Profile, error) { +func LoadProfile(name string, miniHome ...string) (*Profile, error) { cfg, err := DefaultLoader.LoadConfigFromFile(name, miniHome...) p := &Profile{ Name: name, @@ -168,8 +172,8 @@ func profileFilePath(profile string, miniHome ...string) string { return filepath.Join(miniPath, "profiles", profile, "config.json") } -// profileFolderPath returns path of profile folder -func profileFolderPath(profile string, miniHome ...string) string { +// ProfileFolderPath returns path of profile folder +func ProfileFolderPath(profile string, miniHome ...string) string { miniPath := localpath.MiniPath() if len(miniHome) > 0 { miniPath = miniHome[0] diff --git a/pkg/minikube/config/profile_test.go b/pkg/minikube/config/profile_test.go index 2ef38378ac6c..2cd674a8efc3 100644 --- a/pkg/minikube/config/profile_test.go +++ b/pkg/minikube/config/profile_test.go @@ -23,7 +23,7 @@ import ( // TestListProfiles uses a different uses different MINIKUBE_HOME with rest of tests since it relies on file list index func TestListProfiles(t *testing.T) { - miniDir, err := filepath.Abs("./testdata/.minikube") + miniDir, err := filepath.Abs("./testdata/profile/.minikube") if err != nil { t.Errorf("error getting dir path for ./testdata/.minikube : %v", err) } diff --git a/pkg/minikube/config/testdata/delete-all/.minikube/machines/p1/config.json b/pkg/minikube/config/testdata/delete-all/.minikube/machines/p1/config.json new file mode 100644 index 000000000000..90a026a01c51 --- /dev/null +++ b/pkg/minikube/config/testdata/delete-all/.minikube/machines/p1/config.json @@ -0,0 +1,80 @@ +{ + "ConfigVersion": 3, + "Driver": { + "IPAddress": "192.168.64.50", + "MachineName": "p1", + "SSHUser": "docker", + "SSHPort": 22, + "SSHKeyPath": "/Users/someuser/.minikube/machines/p1/id_rsa", + "StorePath": "/Users/someuser/.minikube", + "SwarmMaster": false, + "SwarmHost": "", + "SwarmDiscovery": "", + "Boot2DockerURL": "file:///Users/someuser/.minikube/cache/iso/minikube-v1.2.0.iso", + "DiskSize": 20000, + "CPU": 2, + "Memory": 2000, + "Cmdline": "loglevel=3 user=docker console=ttyS0 console=tty0 noembed nomodeset norestore waitusb=10 systemd.legacy_systemd_cgroup_controller=yes base host=p1", + "NFSShares": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "5e6787b6-aecb-11e9-81cf-8c8590c3b8b4", + "BootKernel": "/Users/someuser/.minikube/machines/p1/b2d-image/boot/bzImage", + "BootInitrd": "/Users/someuser/.minikube/machines/p1/b2d-image/boot/initrd", + "Initrd": "initrd", + "Vmlinuz": "bzImage" + }, + "DriverName": "hyperkit", + "HostOptions": { + "Driver": "", + "Memory": 0, + "Disk": 0, + "EngineOptions": { + "ArbitraryFlags": null, + "Dns": null, + "GraphDir": "", + "Env": null, + "Ipv6": false, + "InsecureRegistry": [ + "10.96.0.0/12" + ], + "Labels": null, + "LogLevel": "", + "StorageDriver": "", + "SelinuxEnabled": false, + "TlsVerify": false, + "RegistryMirror": null, + "InstallURL": "" + }, + "SwarmOptions": { + "IsSwarm": false, + "Address": "", + "Discovery": "", + "Agent": false, + "Master": false, + "Host": "tcp://0.0.0.0:3376", + "Image": "swarm:latest", + "Strategy": "spread", + "Heartbeat": 0, + "Overcommit": 0, + "ArbitraryFlags": null, + "ArbitraryJoinFlags": null, + "Env": null, + "IsExperimental": false + }, + "AuthOptions": { + "CertDir": "/Users/someuser/.minikube", + "CaCertPath": "/Users/someuser/.minikube/certs/ca.pem", + "CaPrivateKeyPath": "/Users/someuser/.minikube/certs/ca-key.pem", + "CaCertRemotePath": "", + "ServerCertPath": "/Users/someuser/.minikube/machines/server.pem", + "ServerKeyPath": "/Users/someuser/.minikube/machines/server-key.pem", + "ClientKeyPath": "/Users/someuser/.minikube/certs/key.pem", + "ServerCertRemotePath": "", + "ServerKeyRemotePath": "", + "ClientCertPath": "/Users/someuser/.minikube/certs/cert.pem", + "ServerCertSANs": null, + "StorePath": "/Users/someuser/.minikube" + } + }, + "Name": "p1" +} diff --git a/pkg/minikube/config/testdata/delete-all/.minikube/machines/p2_empty_profile_config/config.json b/pkg/minikube/config/testdata/delete-all/.minikube/machines/p2_empty_profile_config/config.json new file mode 100644 index 000000000000..a9e6592c7afd --- /dev/null +++ b/pkg/minikube/config/testdata/delete-all/.minikube/machines/p2_empty_profile_config/config.json @@ -0,0 +1,80 @@ +{ + "ConfigVersion": 3, + "Driver": { + "IPAddress": "192.168.64.52", + "MachineName": "p2_empty_profile_config", + "SSHUser": "docker", + "SSHPort": 22, + "SSHKeyPath": "/Users/someuser/.minikube/machines/p2_empty_profile_config/id_rsa", + "StorePath": "/Users/someuser/.minikube", + "SwarmMaster": false, + "SwarmHost": "", + "SwarmDiscovery": "", + "Boot2DockerURL": "file:///Users/someuser/.minikube/cache/iso/minikube-v1.2.0.iso", + "DiskSize": 20000, + "CPU": 2, + "Memory": 2000, + "Cmdline": "loglevel=3 user=docker console=ttyS0 console=tty0 noembed nomodeset norestore waitusb=10 systemd.legacy_systemd_cgroup_controller=yes base host=p2_empty_profile_config", + "NFSShares": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "ddd37c1c-aedf-11e9-afa7-8c8590c3b8b4", + "BootKernel": "/Users/someuser/.minikube/machines/p2_empty_profile_config/b2d-image/boot/bzImage", + "BootInitrd": "/Users/someuser/.minikube/machines/p2_empty_profile_config/b2d-image/boot/initrd", + "Initrd": "initrd", + "Vmlinuz": "bzImage" + }, + "DriverName": "hyperkit", + "HostOptions": { + "Driver": "", + "Memory": 0, + "Disk": 0, + "EngineOptions": { + "ArbitraryFlags": null, + "Dns": null, + "GraphDir": "", + "Env": null, + "Ipv6": false, + "InsecureRegistry": [ + "10.96.0.0/12" + ], + "Labels": null, + "LogLevel": "", + "StorageDriver": "", + "SelinuxEnabled": false, + "TlsVerify": false, + "RegistryMirror": null, + "InstallURL": "" + }, + "SwarmOptions": { + "IsSwarm": false, + "Address": "", + "Discovery": "", + "Agent": false, + "Master": false, + "Host": "tcp://0.0.0.0:3376", + "Image": "swarm:latest", + "Strategy": "spread", + "Heartbeat": 0, + "Overcommit": 0, + "ArbitraryFlags": null, + "ArbitraryJoinFlags": null, + "Env": null, + "IsExperimental": false + }, + "AuthOptions": { + "CertDir": "/Users/someuser/.minikube", + "CaCertPath": "/Users/someuser/.minikube/certs/ca.pem", + "CaPrivateKeyPath": "/Users/someuser/.minikube/certs/ca-key.pem", + "CaCertRemotePath": "", + "ServerCertPath": "/Users/someuser/.minikube/machines/server.pem", + "ServerKeyPath": "/Users/someuser/.minikube/machines/server-key.pem", + "ClientKeyPath": "/Users/someuser/.minikube/certs/key.pem", + "ServerCertRemotePath": "", + "ServerKeyRemotePath": "", + "ClientCertPath": "/Users/someuser/.minikube/certs/cert.pem", + "ServerCertSANs": null, + "StorePath": "/Users/someuser/.minikube" + } + }, + "Name": "p2_empty_profile_config" +} diff --git a/pkg/minikube/config/testdata/delete-all/.minikube/machines/p3_invalid_profile_config/config.json b/pkg/minikube/config/testdata/delete-all/.minikube/machines/p3_invalid_profile_config/config.json new file mode 100644 index 000000000000..8d23c98dc6b9 --- /dev/null +++ b/pkg/minikube/config/testdata/delete-all/.minikube/machines/p3_invalid_profile_config/config.json @@ -0,0 +1,80 @@ +{ + "ConfigVersion": 3, + "Driver": { + "IPAddress": "192.168.64.53", + "MachineName": "p3_invalid_profile_config", + "SSHUser": "docker", + "SSHPort": 22, + "SSHKeyPath": "/Users/someuser/.minikube/machines/p3_invalid_profile_config/id_rsa", + "StorePath": "/Users/someuser/.minikube", + "SwarmMaster": false, + "SwarmHost": "", + "SwarmDiscovery": "", + "Boot2DockerURL": "file:///Users/someuser/.minikube/cache/iso/minikube-v1.2.0.iso", + "DiskSize": 20000, + "CPU": 2, + "Memory": 2000, + "Cmdline": "loglevel=3 user=docker console=ttyS0 console=tty0 noembed nomodeset norestore waitusb=10 systemd.legacy_systemd_cgroup_controller=yes base host=p3_invalid_profile_config", + "NFSShares": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "759044c8-aee4-11e9-bd0a-8c8590c3b8b4", + "BootKernel": "/Users/someuser/.minikube/machines/p3_invalid_profile_config/b2d-image/boot/bzImage", + "BootInitrd": "/Users/someuser/.minikube/machines/p3_invalid_profile_config/b2d-image/boot/initrd", + "Initrd": "initrd", + "Vmlinuz": "bzImage" + }, + "DriverName": "hyperkit", + "HostOptions": { + "Driver": "", + "Memory": 0, + "Disk": 0, + "EngineOptions": { + "ArbitraryFlags": null, + "Dns": null, + "GraphDir": "", + "Env": null, + "Ipv6": false, + "InsecureRegistry": [ + "10.96.0.0/12" + ], + "Labels": null, + "LogLevel": "", + "StorageDriver": "", + "SelinuxEnabled": false, + "TlsVerify": false, + "RegistryMirror": null, + "InstallURL": "" + }, + "SwarmOptions": { + "IsSwarm": false, + "Address": "", + "Discovery": "", + "Agent": false, + "Master": false, + "Host": "tcp://0.0.0.0:3376", + "Image": "swarm:latest", + "Strategy": "spread", + "Heartbeat": 0, + "Overcommit": 0, + "ArbitraryFlags": null, + "ArbitraryJoinFlags": null, + "Env": null, + "IsExperimental": false + }, + "AuthOptions": { + "CertDir": "/Users/someuser/.minikube", + "CaCertPath": "/Users/someuser/.minikube/certs/ca.pem", + "CaPrivateKeyPath": "/Users/someuser/.minikube/certs/ca-key.pem", + "CaCertRemotePath": "", + "ServerCertPath": "/Users/someuser/.minikube/machines/server.pem", + "ServerKeyPath": "/Users/someuser/.minikube/machines/server-key.pem", + "ClientKeyPath": "/Users/someuser/.minikube/certs/key.pem", + "ServerCertRemotePath": "", + "ServerKeyRemotePath": "", + "ClientCertPath": "/Users/someuser/.minikube/certs/cert.pem", + "ServerCertSANs": null, + "StorePath": "/Users/someuser/.minikube" + } + }, + "Name": "p3_invalid_profile_config" +} diff --git a/pkg/minikube/config/testdata/delete-all/.minikube/machines/p4_partial_profile_config/config.json b/pkg/minikube/config/testdata/delete-all/.minikube/machines/p4_partial_profile_config/config.json new file mode 100644 index 000000000000..14b416d3c2cf --- /dev/null +++ b/pkg/minikube/config/testdata/delete-all/.minikube/machines/p4_partial_profile_config/config.json @@ -0,0 +1,80 @@ +{ + "ConfigVersion": 3, + "Driver": { + "IPAddress": "192.168.64.54", + "MachineName": "p4_partial_profile_config", + "SSHUser": "docker", + "SSHPort": 22, + "SSHKeyPath": "/Users/someuser/.minikube/machines/p4_partial_profile_config/id_rsa", + "StorePath": "/Users/someuser/.minikube", + "SwarmMaster": false, + "SwarmHost": "", + "SwarmDiscovery": "", + "Boot2DockerURL": "file:///Users/someuser/.minikube/cache/iso/minikube-v1.2.0.iso", + "DiskSize": 20000, + "CPU": 2, + "Memory": 2000, + "Cmdline": "loglevel=3 user=docker console=ttyS0 console=tty0 noembed nomodeset norestore waitusb=10 systemd.legacy_systemd_cgroup_controller=yes base host=p4_partial_profile_config", + "NFSShares": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "faf8face-aee4-11e9-9ba1-8c8590c3b8b4", + "BootKernel": "/Users/someuser/.minikube/machines/p4_partial_profile_config/b2d-image/boot/bzImage", + "BootInitrd": "/Users/someuser/.minikube/machines/p4_partial_profile_config/b2d-image/boot/initrd", + "Initrd": "initrd", + "Vmlinuz": "bzImage" + }, + "DriverName": "hyperkit", + "HostOptions": { + "Driver": "", + "Memory": 0, + "Disk": 0, + "EngineOptions": { + "ArbitraryFlags": null, + "Dns": null, + "GraphDir": "", + "Env": null, + "Ipv6": false, + "InsecureRegistry": [ + "10.96.0.0/12" + ], + "Labels": null, + "LogLevel": "", + "StorageDriver": "", + "SelinuxEnabled": false, + "TlsVerify": false, + "RegistryMirror": null, + "InstallURL": "" + }, + "SwarmOptions": { + "IsSwarm": false, + "Address": "", + "Discovery": "", + "Agent": false, + "Master": false, + "Host": "tcp://0.0.0.0:3376", + "Image": "swarm:latest", + "Strategy": "spread", + "Heartbeat": 0, + "Overcommit": 0, + "ArbitraryFlags": null, + "ArbitraryJoinFlags": null, + "Env": null, + "IsExperimental": false + }, + "AuthOptions": { + "CertDir": "/Users/someuser/.minikube", + "CaCertPath": "/Users/someuser/.minikube/certs/ca.pem", + "CaPrivateKeyPath": "/Users/someuser/.minikube/certs/ca-key.pem", + "CaCertRemotePath": "", + "ServerCertPath": "/Users/someuser/.minikube/machines/server.pem", + "ServerKeyPath": "/Users/someuser/.minikube/machines/server-key.pem", + "ClientKeyPath": "/Users/someuser/.minikube/certs/key.pem", + "ServerCertRemotePath": "", + "ServerKeyRemotePath": "", + "ClientCertPath": "/Users/someuser/.minikube/certs/cert.pem", + "ServerCertSANs": null, + "StorePath": "/Users/someuser/.minikube" + } + }, + "Name": "p4_partial_profile_config" +} diff --git a/pkg/minikube/config/testdata/delete-all/.minikube/machines/p6_empty_machine_config/config.json b/pkg/minikube/config/testdata/delete-all/.minikube/machines/p6_empty_machine_config/config.json new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/pkg/minikube/config/testdata/delete-all/.minikube/machines/p7_invalid_machine_config/config.json b/pkg/minikube/config/testdata/delete-all/.minikube/machines/p7_invalid_machine_config/config.json new file mode 100644 index 000000000000..581f9e648f6b --- /dev/null +++ b/pkg/minikube/config/testdata/delete-all/.minikube/machines/p7_invalid_machine_config/config.json @@ -0,0 +1 @@ +invalid json file :) diff --git a/pkg/minikube/config/testdata/delete-all/.minikube/machines/p8_partial_machine_config/config.json b/pkg/minikube/config/testdata/delete-all/.minikube/machines/p8_partial_machine_config/config.json new file mode 100644 index 000000000000..d4525a7861ff --- /dev/null +++ b/pkg/minikube/config/testdata/delete-all/.minikube/machines/p8_partial_machine_config/config.json @@ -0,0 +1,72 @@ +{ + "ConfigVersion": 3, + "Driver": { + "SSHUser": "docker", + "SSHPort": 22, + "SSHKeyPath": "/Users/someuser/.minikube/machines/p8_partial_machine_config/id_rsa", + "StorePath": "/Users/someuser/.minikube", + "SwarmMaster": false, + "SwarmHost": "", + "SwarmDiscovery": "", + "DiskSize": 20000, + "CPU": 2, + "Memory": 2000, + "Cmdline": "loglevel=3 user=docker console=ttyS0 console=tty0 noembed nomodeset norestore waitusb=10 systemd.legacy_systemd_cgroup_controller=yes base host=p8_partial_machine_config", + "NFSShares": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "4f16872c-aee8-11e9-8815-8c8590c3b8b4", + "BootKernel": "/Users/someuser/.minikube/machines/p8_partial_machine_config/b2d-image/boot/bzImage", + "BootInitrd": "/Users/someuser/.minikube/machines/p8_partial_machine_config/b2d-image/boot/initrd", + "Initrd": "initrd", + "Vmlinuz": "bzImage" + }, + "HostOptions": { + "Driver": "", + "Memory": 0, + "Disk": 0, + "EngineOptions": { + "ArbitraryFlags": null, + "Dns": null, + "GraphDir": "", + "Env": null, + "Ipv6": false, + "InsecureRegistry": [ + "10.96.0.0/12" + ], + "Labels": null, + "LogLevel": "", + "StorageDriver": "", + "SelinuxEnabled": false, + "TlsVerify": false, + "RegistryMirror": null, + "InstallURL": "" + }, + "SwarmOptions": { + "IsSwarm": false, + "Address": "", + "Discovery": "", + "Agent": false, + "Master": false, + "Host": "tcp://0.0.0.0:3376", + "Image": "swarm:latest", + "Strategy": "spread", + "Heartbeat": 0, + "Overcommit": 0, + "ArbitraryFlags": null, + "ArbitraryJoinFlags": null, + "Env": null, + "IsExperimental": false + }, + "AuthOptions": { + "CertDir": "/Users/someuser/.minikube", + "CaCertPath": "/Users/someuser/.minikube/certs/ca.pem", + "CaPrivateKeyPath": "/Users/someuser/.minikube/certs/ca-key.pem", + "CaCertRemotePath": "", + "ServerCertRemotePath": "", + "ServerKeyRemotePath": "", + "ClientCertPath": "/Users/someuser/.minikube/certs/cert.pem", + "ServerCertSANs": null, + "StorePath": "/Users/someuser/.minikube" + } + }, +} diff --git a/pkg/minikube/config/testdata/delete-all/.minikube/profiles/p1/config.json b/pkg/minikube/config/testdata/delete-all/.minikube/profiles/p1/config.json new file mode 100644 index 000000000000..00655266e652 --- /dev/null +++ b/pkg/minikube/config/testdata/delete-all/.minikube/profiles/p1/config.json @@ -0,0 +1,49 @@ +{ + "MachineConfig": { + "KeepContext": false, + "MinikubeISO": "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso", + "Memory": 2000, + "CPUs": 2, + "DiskSize": 20000, + "VMDriver": "hyperkit", + "ContainerRuntime": "docker", + "HyperkitVpnKitSock": "", + "HyperkitVSockPorts": [], + "DockerEnv": null, + "InsecureRegistry": null, + "RegistryMirror": null, + "HostOnlyCIDR": "192.168.99.1/24", + "HypervVirtualSwitch": "", + "KVMNetwork": "default", + "KVMQemuURI": "qemu:///system", + "KVMGPU": false, + "KVMHidden": false, + "DockerOpt": null, + "DisableDriverMounts": false, + "NFSShare": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "", + "NoVTXCheck": false, + "DNSProxy": false, + "HostDNSResolver": true + }, + "KubernetesConfig": { + "KubernetesVersion": "v1.15.0", + "NodeIP": "192.168.64.50", + "NodePort": 8443, + "NodeName": "minikube", + "APIServerName": "minikubeCA", + "APIServerNames": null, + "APIServerIPs": null, + "DNSDomain": "cluster.local", + "ContainerRuntime": "docker", + "CRISocket": "", + "NetworkPlugin": "", + "FeatureGates": "", + "ServiceCIDR": "10.96.0.0/12", + "ImageRepository": "", + "ExtraOptions": null, + "ShouldLoadCachedImages": true, + "EnableDefaultCNI": false + } +} \ No newline at end of file diff --git a/pkg/minikube/config/testdata/delete-all/.minikube/profiles/p2_empty_profile_config/config.json b/pkg/minikube/config/testdata/delete-all/.minikube/profiles/p2_empty_profile_config/config.json new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/pkg/minikube/config/testdata/.minikube/profiles/p4_invalid_file/config.json b/pkg/minikube/config/testdata/delete-all/.minikube/profiles/p3_invalid_profile_config/config.json similarity index 100% rename from pkg/minikube/config/testdata/.minikube/profiles/p4_invalid_file/config.json rename to pkg/minikube/config/testdata/delete-all/.minikube/profiles/p3_invalid_profile_config/config.json diff --git a/pkg/minikube/config/testdata/.minikube/profiles/p5_partial_config/config.json b/pkg/minikube/config/testdata/delete-all/.minikube/profiles/p4_partial_profile_config/config.json similarity index 100% rename from pkg/minikube/config/testdata/.minikube/profiles/p5_partial_config/config.json rename to pkg/minikube/config/testdata/delete-all/.minikube/profiles/p4_partial_profile_config/config.json diff --git a/pkg/minikube/config/testdata/delete-all/.minikube/profiles/p5_missing_machine_config/config.json b/pkg/minikube/config/testdata/delete-all/.minikube/profiles/p5_missing_machine_config/config.json new file mode 100644 index 000000000000..1e0980752aa7 --- /dev/null +++ b/pkg/minikube/config/testdata/delete-all/.minikube/profiles/p5_missing_machine_config/config.json @@ -0,0 +1,49 @@ +{ + "MachineConfig": { + "KeepContext": false, + "MinikubeISO": "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso", + "Memory": 2000, + "CPUs": 2, + "DiskSize": 20000, + "VMDriver": "hyperkit", + "ContainerRuntime": "docker", + "HyperkitVpnKitSock": "", + "HyperkitVSockPorts": [], + "DockerEnv": null, + "InsecureRegistry": null, + "RegistryMirror": null, + "HostOnlyCIDR": "192.168.99.1/24", + "HypervVirtualSwitch": "", + "KVMNetwork": "default", + "KVMQemuURI": "qemu:///system", + "KVMGPU": false, + "KVMHidden": false, + "DockerOpt": null, + "DisableDriverMounts": false, + "NFSShare": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "", + "NoVTXCheck": false, + "DNSProxy": false, + "HostDNSResolver": true + }, + "KubernetesConfig": { + "KubernetesVersion": "v1.15.0", + "NodeIP": "192.168.64.55", + "NodePort": 8443, + "NodeName": "minikube", + "APIServerName": "minikubeCA", + "APIServerNames": null, + "APIServerIPs": null, + "DNSDomain": "cluster.local", + "ContainerRuntime": "docker", + "CRISocket": "", + "NetworkPlugin": "", + "FeatureGates": "", + "ServiceCIDR": "10.96.0.0/12", + "ImageRepository": "", + "ExtraOptions": null, + "ShouldLoadCachedImages": true, + "EnableDefaultCNI": false + } +} \ No newline at end of file diff --git a/pkg/minikube/config/testdata/delete-all/.minikube/profiles/p6_empty_machine_config/config.json b/pkg/minikube/config/testdata/delete-all/.minikube/profiles/p6_empty_machine_config/config.json new file mode 100644 index 000000000000..a1557f6df1b4 --- /dev/null +++ b/pkg/minikube/config/testdata/delete-all/.minikube/profiles/p6_empty_machine_config/config.json @@ -0,0 +1,49 @@ +{ + "MachineConfig": { + "KeepContext": false, + "MinikubeISO": "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso", + "Memory": 2000, + "CPUs": 2, + "DiskSize": 20000, + "VMDriver": "hyperkit", + "ContainerRuntime": "docker", + "HyperkitVpnKitSock": "", + "HyperkitVSockPorts": [], + "DockerEnv": null, + "InsecureRegistry": null, + "RegistryMirror": null, + "HostOnlyCIDR": "192.168.99.1/24", + "HypervVirtualSwitch": "", + "KVMNetwork": "default", + "KVMQemuURI": "qemu:///system", + "KVMGPU": false, + "KVMHidden": false, + "DockerOpt": null, + "DisableDriverMounts": false, + "NFSShare": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "", + "NoVTXCheck": false, + "DNSProxy": false, + "HostDNSResolver": true + }, + "KubernetesConfig": { + "KubernetesVersion": "v1.15.0", + "NodeIP": "192.168.64.57", + "NodePort": 8443, + "NodeName": "minikube", + "APIServerName": "minikubeCA", + "APIServerNames": null, + "APIServerIPs": null, + "DNSDomain": "cluster.local", + "ContainerRuntime": "docker", + "CRISocket": "", + "NetworkPlugin": "", + "FeatureGates": "", + "ServiceCIDR": "10.96.0.0/12", + "ImageRepository": "", + "ExtraOptions": null, + "ShouldLoadCachedImages": true, + "EnableDefaultCNI": false + } +} \ No newline at end of file diff --git a/pkg/minikube/config/testdata/delete-all/.minikube/profiles/p7_invalid_machine_config/config.json b/pkg/minikube/config/testdata/delete-all/.minikube/profiles/p7_invalid_machine_config/config.json new file mode 100644 index 000000000000..ea47981d2928 --- /dev/null +++ b/pkg/minikube/config/testdata/delete-all/.minikube/profiles/p7_invalid_machine_config/config.json @@ -0,0 +1,49 @@ +{ + "MachineConfig": { + "KeepContext": false, + "MinikubeISO": "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso", + "Memory": 2000, + "CPUs": 2, + "DiskSize": 20000, + "VMDriver": "hyperkit", + "ContainerRuntime": "docker", + "HyperkitVpnKitSock": "", + "HyperkitVSockPorts": [], + "DockerEnv": null, + "InsecureRegistry": null, + "RegistryMirror": null, + "HostOnlyCIDR": "192.168.99.1/24", + "HypervVirtualSwitch": "", + "KVMNetwork": "default", + "KVMQemuURI": "qemu:///system", + "KVMGPU": false, + "KVMHidden": false, + "DockerOpt": null, + "DisableDriverMounts": false, + "NFSShare": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "", + "NoVTXCheck": false, + "DNSProxy": false, + "HostDNSResolver": true + }, + "KubernetesConfig": { + "KubernetesVersion": "v1.15.0", + "NodeIP": "192.168.64.59", + "NodePort": 8443, + "NodeName": "minikube", + "APIServerName": "minikubeCA", + "APIServerNames": null, + "APIServerIPs": null, + "DNSDomain": "cluster.local", + "ContainerRuntime": "docker", + "CRISocket": "", + "NetworkPlugin": "", + "FeatureGates": "", + "ServiceCIDR": "10.96.0.0/12", + "ImageRepository": "", + "ExtraOptions": null, + "ShouldLoadCachedImages": true, + "EnableDefaultCNI": false + } +} \ No newline at end of file diff --git a/pkg/minikube/config/testdata/delete-all/.minikube/profiles/p8_partial_machine_config/config.json b/pkg/minikube/config/testdata/delete-all/.minikube/profiles/p8_partial_machine_config/config.json new file mode 100644 index 000000000000..789b9b55576f --- /dev/null +++ b/pkg/minikube/config/testdata/delete-all/.minikube/profiles/p8_partial_machine_config/config.json @@ -0,0 +1,49 @@ +{ + "MachineConfig": { + "KeepContext": false, + "MinikubeISO": "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso", + "Memory": 2000, + "CPUs": 2, + "DiskSize": 20000, + "VMDriver": "hyperkit", + "ContainerRuntime": "docker", + "HyperkitVpnKitSock": "", + "HyperkitVSockPorts": [], + "DockerEnv": null, + "InsecureRegistry": null, + "RegistryMirror": null, + "HostOnlyCIDR": "192.168.99.1/24", + "HypervVirtualSwitch": "", + "KVMNetwork": "default", + "KVMQemuURI": "qemu:///system", + "KVMGPU": false, + "KVMHidden": false, + "DockerOpt": null, + "DisableDriverMounts": false, + "NFSShare": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "", + "NoVTXCheck": false, + "DNSProxy": false, + "HostDNSResolver": true + }, + "KubernetesConfig": { + "KubernetesVersion": "v1.15.0", + "NodeIP": "192.168.64.60", + "NodePort": 8443, + "NodeName": "minikube", + "APIServerName": "minikubeCA", + "APIServerNames": null, + "APIServerIPs": null, + "DNSDomain": "cluster.local", + "ContainerRuntime": "docker", + "CRISocket": "", + "NetworkPlugin": "", + "FeatureGates": "", + "ServiceCIDR": "10.96.0.0/12", + "ImageRepository": "", + "ExtraOptions": null, + "ShouldLoadCachedImages": true, + "EnableDefaultCNI": false + } +} diff --git a/pkg/minikube/config/testdata/delete-single/.minikube/machines/p1/config.json b/pkg/minikube/config/testdata/delete-single/.minikube/machines/p1/config.json new file mode 100644 index 000000000000..90a026a01c51 --- /dev/null +++ b/pkg/minikube/config/testdata/delete-single/.minikube/machines/p1/config.json @@ -0,0 +1,80 @@ +{ + "ConfigVersion": 3, + "Driver": { + "IPAddress": "192.168.64.50", + "MachineName": "p1", + "SSHUser": "docker", + "SSHPort": 22, + "SSHKeyPath": "/Users/someuser/.minikube/machines/p1/id_rsa", + "StorePath": "/Users/someuser/.minikube", + "SwarmMaster": false, + "SwarmHost": "", + "SwarmDiscovery": "", + "Boot2DockerURL": "file:///Users/someuser/.minikube/cache/iso/minikube-v1.2.0.iso", + "DiskSize": 20000, + "CPU": 2, + "Memory": 2000, + "Cmdline": "loglevel=3 user=docker console=ttyS0 console=tty0 noembed nomodeset norestore waitusb=10 systemd.legacy_systemd_cgroup_controller=yes base host=p1", + "NFSShares": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "5e6787b6-aecb-11e9-81cf-8c8590c3b8b4", + "BootKernel": "/Users/someuser/.minikube/machines/p1/b2d-image/boot/bzImage", + "BootInitrd": "/Users/someuser/.minikube/machines/p1/b2d-image/boot/initrd", + "Initrd": "initrd", + "Vmlinuz": "bzImage" + }, + "DriverName": "hyperkit", + "HostOptions": { + "Driver": "", + "Memory": 0, + "Disk": 0, + "EngineOptions": { + "ArbitraryFlags": null, + "Dns": null, + "GraphDir": "", + "Env": null, + "Ipv6": false, + "InsecureRegistry": [ + "10.96.0.0/12" + ], + "Labels": null, + "LogLevel": "", + "StorageDriver": "", + "SelinuxEnabled": false, + "TlsVerify": false, + "RegistryMirror": null, + "InstallURL": "" + }, + "SwarmOptions": { + "IsSwarm": false, + "Address": "", + "Discovery": "", + "Agent": false, + "Master": false, + "Host": "tcp://0.0.0.0:3376", + "Image": "swarm:latest", + "Strategy": "spread", + "Heartbeat": 0, + "Overcommit": 0, + "ArbitraryFlags": null, + "ArbitraryJoinFlags": null, + "Env": null, + "IsExperimental": false + }, + "AuthOptions": { + "CertDir": "/Users/someuser/.minikube", + "CaCertPath": "/Users/someuser/.minikube/certs/ca.pem", + "CaPrivateKeyPath": "/Users/someuser/.minikube/certs/ca-key.pem", + "CaCertRemotePath": "", + "ServerCertPath": "/Users/someuser/.minikube/machines/server.pem", + "ServerKeyPath": "/Users/someuser/.minikube/machines/server-key.pem", + "ClientKeyPath": "/Users/someuser/.minikube/certs/key.pem", + "ServerCertRemotePath": "", + "ServerKeyRemotePath": "", + "ClientCertPath": "/Users/someuser/.minikube/certs/cert.pem", + "ServerCertSANs": null, + "StorePath": "/Users/someuser/.minikube" + } + }, + "Name": "p1" +} diff --git a/pkg/minikube/config/testdata/delete-single/.minikube/machines/p2_empty_profile_config/config.json b/pkg/minikube/config/testdata/delete-single/.minikube/machines/p2_empty_profile_config/config.json new file mode 100644 index 000000000000..a9e6592c7afd --- /dev/null +++ b/pkg/minikube/config/testdata/delete-single/.minikube/machines/p2_empty_profile_config/config.json @@ -0,0 +1,80 @@ +{ + "ConfigVersion": 3, + "Driver": { + "IPAddress": "192.168.64.52", + "MachineName": "p2_empty_profile_config", + "SSHUser": "docker", + "SSHPort": 22, + "SSHKeyPath": "/Users/someuser/.minikube/machines/p2_empty_profile_config/id_rsa", + "StorePath": "/Users/someuser/.minikube", + "SwarmMaster": false, + "SwarmHost": "", + "SwarmDiscovery": "", + "Boot2DockerURL": "file:///Users/someuser/.minikube/cache/iso/minikube-v1.2.0.iso", + "DiskSize": 20000, + "CPU": 2, + "Memory": 2000, + "Cmdline": "loglevel=3 user=docker console=ttyS0 console=tty0 noembed nomodeset norestore waitusb=10 systemd.legacy_systemd_cgroup_controller=yes base host=p2_empty_profile_config", + "NFSShares": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "ddd37c1c-aedf-11e9-afa7-8c8590c3b8b4", + "BootKernel": "/Users/someuser/.minikube/machines/p2_empty_profile_config/b2d-image/boot/bzImage", + "BootInitrd": "/Users/someuser/.minikube/machines/p2_empty_profile_config/b2d-image/boot/initrd", + "Initrd": "initrd", + "Vmlinuz": "bzImage" + }, + "DriverName": "hyperkit", + "HostOptions": { + "Driver": "", + "Memory": 0, + "Disk": 0, + "EngineOptions": { + "ArbitraryFlags": null, + "Dns": null, + "GraphDir": "", + "Env": null, + "Ipv6": false, + "InsecureRegistry": [ + "10.96.0.0/12" + ], + "Labels": null, + "LogLevel": "", + "StorageDriver": "", + "SelinuxEnabled": false, + "TlsVerify": false, + "RegistryMirror": null, + "InstallURL": "" + }, + "SwarmOptions": { + "IsSwarm": false, + "Address": "", + "Discovery": "", + "Agent": false, + "Master": false, + "Host": "tcp://0.0.0.0:3376", + "Image": "swarm:latest", + "Strategy": "spread", + "Heartbeat": 0, + "Overcommit": 0, + "ArbitraryFlags": null, + "ArbitraryJoinFlags": null, + "Env": null, + "IsExperimental": false + }, + "AuthOptions": { + "CertDir": "/Users/someuser/.minikube", + "CaCertPath": "/Users/someuser/.minikube/certs/ca.pem", + "CaPrivateKeyPath": "/Users/someuser/.minikube/certs/ca-key.pem", + "CaCertRemotePath": "", + "ServerCertPath": "/Users/someuser/.minikube/machines/server.pem", + "ServerKeyPath": "/Users/someuser/.minikube/machines/server-key.pem", + "ClientKeyPath": "/Users/someuser/.minikube/certs/key.pem", + "ServerCertRemotePath": "", + "ServerKeyRemotePath": "", + "ClientCertPath": "/Users/someuser/.minikube/certs/cert.pem", + "ServerCertSANs": null, + "StorePath": "/Users/someuser/.minikube" + } + }, + "Name": "p2_empty_profile_config" +} diff --git a/pkg/minikube/config/testdata/delete-single/.minikube/machines/p3_invalid_profile_config/config.json b/pkg/minikube/config/testdata/delete-single/.minikube/machines/p3_invalid_profile_config/config.json new file mode 100644 index 000000000000..8d23c98dc6b9 --- /dev/null +++ b/pkg/minikube/config/testdata/delete-single/.minikube/machines/p3_invalid_profile_config/config.json @@ -0,0 +1,80 @@ +{ + "ConfigVersion": 3, + "Driver": { + "IPAddress": "192.168.64.53", + "MachineName": "p3_invalid_profile_config", + "SSHUser": "docker", + "SSHPort": 22, + "SSHKeyPath": "/Users/someuser/.minikube/machines/p3_invalid_profile_config/id_rsa", + "StorePath": "/Users/someuser/.minikube", + "SwarmMaster": false, + "SwarmHost": "", + "SwarmDiscovery": "", + "Boot2DockerURL": "file:///Users/someuser/.minikube/cache/iso/minikube-v1.2.0.iso", + "DiskSize": 20000, + "CPU": 2, + "Memory": 2000, + "Cmdline": "loglevel=3 user=docker console=ttyS0 console=tty0 noembed nomodeset norestore waitusb=10 systemd.legacy_systemd_cgroup_controller=yes base host=p3_invalid_profile_config", + "NFSShares": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "759044c8-aee4-11e9-bd0a-8c8590c3b8b4", + "BootKernel": "/Users/someuser/.minikube/machines/p3_invalid_profile_config/b2d-image/boot/bzImage", + "BootInitrd": "/Users/someuser/.minikube/machines/p3_invalid_profile_config/b2d-image/boot/initrd", + "Initrd": "initrd", + "Vmlinuz": "bzImage" + }, + "DriverName": "hyperkit", + "HostOptions": { + "Driver": "", + "Memory": 0, + "Disk": 0, + "EngineOptions": { + "ArbitraryFlags": null, + "Dns": null, + "GraphDir": "", + "Env": null, + "Ipv6": false, + "InsecureRegistry": [ + "10.96.0.0/12" + ], + "Labels": null, + "LogLevel": "", + "StorageDriver": "", + "SelinuxEnabled": false, + "TlsVerify": false, + "RegistryMirror": null, + "InstallURL": "" + }, + "SwarmOptions": { + "IsSwarm": false, + "Address": "", + "Discovery": "", + "Agent": false, + "Master": false, + "Host": "tcp://0.0.0.0:3376", + "Image": "swarm:latest", + "Strategy": "spread", + "Heartbeat": 0, + "Overcommit": 0, + "ArbitraryFlags": null, + "ArbitraryJoinFlags": null, + "Env": null, + "IsExperimental": false + }, + "AuthOptions": { + "CertDir": "/Users/someuser/.minikube", + "CaCertPath": "/Users/someuser/.minikube/certs/ca.pem", + "CaPrivateKeyPath": "/Users/someuser/.minikube/certs/ca-key.pem", + "CaCertRemotePath": "", + "ServerCertPath": "/Users/someuser/.minikube/machines/server.pem", + "ServerKeyPath": "/Users/someuser/.minikube/machines/server-key.pem", + "ClientKeyPath": "/Users/someuser/.minikube/certs/key.pem", + "ServerCertRemotePath": "", + "ServerKeyRemotePath": "", + "ClientCertPath": "/Users/someuser/.minikube/certs/cert.pem", + "ServerCertSANs": null, + "StorePath": "/Users/someuser/.minikube" + } + }, + "Name": "p3_invalid_profile_config" +} diff --git a/pkg/minikube/config/testdata/delete-single/.minikube/machines/p4_partial_profile_config/config.json b/pkg/minikube/config/testdata/delete-single/.minikube/machines/p4_partial_profile_config/config.json new file mode 100644 index 000000000000..14b416d3c2cf --- /dev/null +++ b/pkg/minikube/config/testdata/delete-single/.minikube/machines/p4_partial_profile_config/config.json @@ -0,0 +1,80 @@ +{ + "ConfigVersion": 3, + "Driver": { + "IPAddress": "192.168.64.54", + "MachineName": "p4_partial_profile_config", + "SSHUser": "docker", + "SSHPort": 22, + "SSHKeyPath": "/Users/someuser/.minikube/machines/p4_partial_profile_config/id_rsa", + "StorePath": "/Users/someuser/.minikube", + "SwarmMaster": false, + "SwarmHost": "", + "SwarmDiscovery": "", + "Boot2DockerURL": "file:///Users/someuser/.minikube/cache/iso/minikube-v1.2.0.iso", + "DiskSize": 20000, + "CPU": 2, + "Memory": 2000, + "Cmdline": "loglevel=3 user=docker console=ttyS0 console=tty0 noembed nomodeset norestore waitusb=10 systemd.legacy_systemd_cgroup_controller=yes base host=p4_partial_profile_config", + "NFSShares": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "faf8face-aee4-11e9-9ba1-8c8590c3b8b4", + "BootKernel": "/Users/someuser/.minikube/machines/p4_partial_profile_config/b2d-image/boot/bzImage", + "BootInitrd": "/Users/someuser/.minikube/machines/p4_partial_profile_config/b2d-image/boot/initrd", + "Initrd": "initrd", + "Vmlinuz": "bzImage" + }, + "DriverName": "hyperkit", + "HostOptions": { + "Driver": "", + "Memory": 0, + "Disk": 0, + "EngineOptions": { + "ArbitraryFlags": null, + "Dns": null, + "GraphDir": "", + "Env": null, + "Ipv6": false, + "InsecureRegistry": [ + "10.96.0.0/12" + ], + "Labels": null, + "LogLevel": "", + "StorageDriver": "", + "SelinuxEnabled": false, + "TlsVerify": false, + "RegistryMirror": null, + "InstallURL": "" + }, + "SwarmOptions": { + "IsSwarm": false, + "Address": "", + "Discovery": "", + "Agent": false, + "Master": false, + "Host": "tcp://0.0.0.0:3376", + "Image": "swarm:latest", + "Strategy": "spread", + "Heartbeat": 0, + "Overcommit": 0, + "ArbitraryFlags": null, + "ArbitraryJoinFlags": null, + "Env": null, + "IsExperimental": false + }, + "AuthOptions": { + "CertDir": "/Users/someuser/.minikube", + "CaCertPath": "/Users/someuser/.minikube/certs/ca.pem", + "CaPrivateKeyPath": "/Users/someuser/.minikube/certs/ca-key.pem", + "CaCertRemotePath": "", + "ServerCertPath": "/Users/someuser/.minikube/machines/server.pem", + "ServerKeyPath": "/Users/someuser/.minikube/machines/server-key.pem", + "ClientKeyPath": "/Users/someuser/.minikube/certs/key.pem", + "ServerCertRemotePath": "", + "ServerKeyRemotePath": "", + "ClientCertPath": "/Users/someuser/.minikube/certs/cert.pem", + "ServerCertSANs": null, + "StorePath": "/Users/someuser/.minikube" + } + }, + "Name": "p4_partial_profile_config" +} diff --git a/pkg/minikube/config/testdata/delete-single/.minikube/machines/p6_empty_machine_config/config.json b/pkg/minikube/config/testdata/delete-single/.minikube/machines/p6_empty_machine_config/config.json new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/pkg/minikube/config/testdata/delete-single/.minikube/machines/p7_invalid_machine_config/config.json b/pkg/minikube/config/testdata/delete-single/.minikube/machines/p7_invalid_machine_config/config.json new file mode 100644 index 000000000000..581f9e648f6b --- /dev/null +++ b/pkg/minikube/config/testdata/delete-single/.minikube/machines/p7_invalid_machine_config/config.json @@ -0,0 +1 @@ +invalid json file :) diff --git a/pkg/minikube/config/testdata/delete-single/.minikube/machines/p8_partial_machine_config/config.json b/pkg/minikube/config/testdata/delete-single/.minikube/machines/p8_partial_machine_config/config.json new file mode 100644 index 000000000000..d4525a7861ff --- /dev/null +++ b/pkg/minikube/config/testdata/delete-single/.minikube/machines/p8_partial_machine_config/config.json @@ -0,0 +1,72 @@ +{ + "ConfigVersion": 3, + "Driver": { + "SSHUser": "docker", + "SSHPort": 22, + "SSHKeyPath": "/Users/someuser/.minikube/machines/p8_partial_machine_config/id_rsa", + "StorePath": "/Users/someuser/.minikube", + "SwarmMaster": false, + "SwarmHost": "", + "SwarmDiscovery": "", + "DiskSize": 20000, + "CPU": 2, + "Memory": 2000, + "Cmdline": "loglevel=3 user=docker console=ttyS0 console=tty0 noembed nomodeset norestore waitusb=10 systemd.legacy_systemd_cgroup_controller=yes base host=p8_partial_machine_config", + "NFSShares": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "4f16872c-aee8-11e9-8815-8c8590c3b8b4", + "BootKernel": "/Users/someuser/.minikube/machines/p8_partial_machine_config/b2d-image/boot/bzImage", + "BootInitrd": "/Users/someuser/.minikube/machines/p8_partial_machine_config/b2d-image/boot/initrd", + "Initrd": "initrd", + "Vmlinuz": "bzImage" + }, + "HostOptions": { + "Driver": "", + "Memory": 0, + "Disk": 0, + "EngineOptions": { + "ArbitraryFlags": null, + "Dns": null, + "GraphDir": "", + "Env": null, + "Ipv6": false, + "InsecureRegistry": [ + "10.96.0.0/12" + ], + "Labels": null, + "LogLevel": "", + "StorageDriver": "", + "SelinuxEnabled": false, + "TlsVerify": false, + "RegistryMirror": null, + "InstallURL": "" + }, + "SwarmOptions": { + "IsSwarm": false, + "Address": "", + "Discovery": "", + "Agent": false, + "Master": false, + "Host": "tcp://0.0.0.0:3376", + "Image": "swarm:latest", + "Strategy": "spread", + "Heartbeat": 0, + "Overcommit": 0, + "ArbitraryFlags": null, + "ArbitraryJoinFlags": null, + "Env": null, + "IsExperimental": false + }, + "AuthOptions": { + "CertDir": "/Users/someuser/.minikube", + "CaCertPath": "/Users/someuser/.minikube/certs/ca.pem", + "CaPrivateKeyPath": "/Users/someuser/.minikube/certs/ca-key.pem", + "CaCertRemotePath": "", + "ServerCertRemotePath": "", + "ServerKeyRemotePath": "", + "ClientCertPath": "/Users/someuser/.minikube/certs/cert.pem", + "ServerCertSANs": null, + "StorePath": "/Users/someuser/.minikube" + } + }, +} diff --git a/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p1/config.json b/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p1/config.json new file mode 100644 index 000000000000..00655266e652 --- /dev/null +++ b/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p1/config.json @@ -0,0 +1,49 @@ +{ + "MachineConfig": { + "KeepContext": false, + "MinikubeISO": "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso", + "Memory": 2000, + "CPUs": 2, + "DiskSize": 20000, + "VMDriver": "hyperkit", + "ContainerRuntime": "docker", + "HyperkitVpnKitSock": "", + "HyperkitVSockPorts": [], + "DockerEnv": null, + "InsecureRegistry": null, + "RegistryMirror": null, + "HostOnlyCIDR": "192.168.99.1/24", + "HypervVirtualSwitch": "", + "KVMNetwork": "default", + "KVMQemuURI": "qemu:///system", + "KVMGPU": false, + "KVMHidden": false, + "DockerOpt": null, + "DisableDriverMounts": false, + "NFSShare": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "", + "NoVTXCheck": false, + "DNSProxy": false, + "HostDNSResolver": true + }, + "KubernetesConfig": { + "KubernetesVersion": "v1.15.0", + "NodeIP": "192.168.64.50", + "NodePort": 8443, + "NodeName": "minikube", + "APIServerName": "minikubeCA", + "APIServerNames": null, + "APIServerIPs": null, + "DNSDomain": "cluster.local", + "ContainerRuntime": "docker", + "CRISocket": "", + "NetworkPlugin": "", + "FeatureGates": "", + "ServiceCIDR": "10.96.0.0/12", + "ImageRepository": "", + "ExtraOptions": null, + "ShouldLoadCachedImages": true, + "EnableDefaultCNI": false + } +} \ No newline at end of file diff --git a/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p2_empty_profile_config/config.json b/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p2_empty_profile_config/config.json new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p3_invalid_profile_config/config.json b/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p3_invalid_profile_config/config.json new file mode 100644 index 000000000000..9e2e347718f9 --- /dev/null +++ b/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p3_invalid_profile_config/config.json @@ -0,0 +1 @@ +invalid json file :) \ No newline at end of file diff --git a/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p4_partial_profile_config/config.json b/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p4_partial_profile_config/config.json new file mode 100644 index 000000000000..29f62c014986 --- /dev/null +++ b/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p4_partial_profile_config/config.json @@ -0,0 +1,47 @@ +{ + "MachineConfig": { + "KeepContext": false, + "MinikubeISO": "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso", + "Memory": 2000, + "CPUs": 2, + "DiskSize": 20000, + "ContainerRuntime": "docker", + "HyperkitVpnKitSock": "", + "HyperkitVSockPorts": [], + "XhyveDiskDriver": "ahci-hd", + "DockerEnv": null, + "InsecureRegistry": null, + "RegistryMirror": null, + "HostOnlyCIDR": "192.168.99.1/24", + "HypervVirtualSwitch": "", + "KVMNetwork": "default", + "KVMQemuURI": "qemu:///system", + "KVMGPU": false, + "KVMHidden": false, + "DockerOpt": null, + "DisableDriverMounts": false, + "NFSShare": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "", + "NoVTXCheck": false, + "DNSProxy": false, + "HostDNSResolver": true + }, + "KubernetesConfig": { + "NodePort": 8443, + "NodeName": "minikube", + "APIServerName": "minikubeCA", + "APIServerNames": null, + "APIServerIPs": null, + "DNSDomain": "cluster.local", + "ContainerRuntime": "docker", + "CRISocket": "", + "NetworkPlugin": "", + "FeatureGates": "", + "ServiceCIDR": "10.96.0.0/12", + "ImageRepository": "", + "ExtraOptions": null, + "ShouldLoadCachedImages": true, + "EnableDefaultCNI": false + } +} \ No newline at end of file diff --git a/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p5_missing_machine_config/config.json b/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p5_missing_machine_config/config.json new file mode 100644 index 000000000000..1e0980752aa7 --- /dev/null +++ b/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p5_missing_machine_config/config.json @@ -0,0 +1,49 @@ +{ + "MachineConfig": { + "KeepContext": false, + "MinikubeISO": "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso", + "Memory": 2000, + "CPUs": 2, + "DiskSize": 20000, + "VMDriver": "hyperkit", + "ContainerRuntime": "docker", + "HyperkitVpnKitSock": "", + "HyperkitVSockPorts": [], + "DockerEnv": null, + "InsecureRegistry": null, + "RegistryMirror": null, + "HostOnlyCIDR": "192.168.99.1/24", + "HypervVirtualSwitch": "", + "KVMNetwork": "default", + "KVMQemuURI": "qemu:///system", + "KVMGPU": false, + "KVMHidden": false, + "DockerOpt": null, + "DisableDriverMounts": false, + "NFSShare": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "", + "NoVTXCheck": false, + "DNSProxy": false, + "HostDNSResolver": true + }, + "KubernetesConfig": { + "KubernetesVersion": "v1.15.0", + "NodeIP": "192.168.64.55", + "NodePort": 8443, + "NodeName": "minikube", + "APIServerName": "minikubeCA", + "APIServerNames": null, + "APIServerIPs": null, + "DNSDomain": "cluster.local", + "ContainerRuntime": "docker", + "CRISocket": "", + "NetworkPlugin": "", + "FeatureGates": "", + "ServiceCIDR": "10.96.0.0/12", + "ImageRepository": "", + "ExtraOptions": null, + "ShouldLoadCachedImages": true, + "EnableDefaultCNI": false + } +} \ No newline at end of file diff --git a/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p6_empty_machine_config/config.json b/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p6_empty_machine_config/config.json new file mode 100644 index 000000000000..a1557f6df1b4 --- /dev/null +++ b/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p6_empty_machine_config/config.json @@ -0,0 +1,49 @@ +{ + "MachineConfig": { + "KeepContext": false, + "MinikubeISO": "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso", + "Memory": 2000, + "CPUs": 2, + "DiskSize": 20000, + "VMDriver": "hyperkit", + "ContainerRuntime": "docker", + "HyperkitVpnKitSock": "", + "HyperkitVSockPorts": [], + "DockerEnv": null, + "InsecureRegistry": null, + "RegistryMirror": null, + "HostOnlyCIDR": "192.168.99.1/24", + "HypervVirtualSwitch": "", + "KVMNetwork": "default", + "KVMQemuURI": "qemu:///system", + "KVMGPU": false, + "KVMHidden": false, + "DockerOpt": null, + "DisableDriverMounts": false, + "NFSShare": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "", + "NoVTXCheck": false, + "DNSProxy": false, + "HostDNSResolver": true + }, + "KubernetesConfig": { + "KubernetesVersion": "v1.15.0", + "NodeIP": "192.168.64.57", + "NodePort": 8443, + "NodeName": "minikube", + "APIServerName": "minikubeCA", + "APIServerNames": null, + "APIServerIPs": null, + "DNSDomain": "cluster.local", + "ContainerRuntime": "docker", + "CRISocket": "", + "NetworkPlugin": "", + "FeatureGates": "", + "ServiceCIDR": "10.96.0.0/12", + "ImageRepository": "", + "ExtraOptions": null, + "ShouldLoadCachedImages": true, + "EnableDefaultCNI": false + } +} \ No newline at end of file diff --git a/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p7_invalid_machine_config/config.json b/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p7_invalid_machine_config/config.json new file mode 100644 index 000000000000..ea47981d2928 --- /dev/null +++ b/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p7_invalid_machine_config/config.json @@ -0,0 +1,49 @@ +{ + "MachineConfig": { + "KeepContext": false, + "MinikubeISO": "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso", + "Memory": 2000, + "CPUs": 2, + "DiskSize": 20000, + "VMDriver": "hyperkit", + "ContainerRuntime": "docker", + "HyperkitVpnKitSock": "", + "HyperkitVSockPorts": [], + "DockerEnv": null, + "InsecureRegistry": null, + "RegistryMirror": null, + "HostOnlyCIDR": "192.168.99.1/24", + "HypervVirtualSwitch": "", + "KVMNetwork": "default", + "KVMQemuURI": "qemu:///system", + "KVMGPU": false, + "KVMHidden": false, + "DockerOpt": null, + "DisableDriverMounts": false, + "NFSShare": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "", + "NoVTXCheck": false, + "DNSProxy": false, + "HostDNSResolver": true + }, + "KubernetesConfig": { + "KubernetesVersion": "v1.15.0", + "NodeIP": "192.168.64.59", + "NodePort": 8443, + "NodeName": "minikube", + "APIServerName": "minikubeCA", + "APIServerNames": null, + "APIServerIPs": null, + "DNSDomain": "cluster.local", + "ContainerRuntime": "docker", + "CRISocket": "", + "NetworkPlugin": "", + "FeatureGates": "", + "ServiceCIDR": "10.96.0.0/12", + "ImageRepository": "", + "ExtraOptions": null, + "ShouldLoadCachedImages": true, + "EnableDefaultCNI": false + } +} \ No newline at end of file diff --git a/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p8_partial_machine_config/config.json b/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p8_partial_machine_config/config.json new file mode 100644 index 000000000000..789b9b55576f --- /dev/null +++ b/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p8_partial_machine_config/config.json @@ -0,0 +1,49 @@ +{ + "MachineConfig": { + "KeepContext": false, + "MinikubeISO": "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso", + "Memory": 2000, + "CPUs": 2, + "DiskSize": 20000, + "VMDriver": "hyperkit", + "ContainerRuntime": "docker", + "HyperkitVpnKitSock": "", + "HyperkitVSockPorts": [], + "DockerEnv": null, + "InsecureRegistry": null, + "RegistryMirror": null, + "HostOnlyCIDR": "192.168.99.1/24", + "HypervVirtualSwitch": "", + "KVMNetwork": "default", + "KVMQemuURI": "qemu:///system", + "KVMGPU": false, + "KVMHidden": false, + "DockerOpt": null, + "DisableDriverMounts": false, + "NFSShare": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "", + "NoVTXCheck": false, + "DNSProxy": false, + "HostDNSResolver": true + }, + "KubernetesConfig": { + "KubernetesVersion": "v1.15.0", + "NodeIP": "192.168.64.60", + "NodePort": 8443, + "NodeName": "minikube", + "APIServerName": "minikubeCA", + "APIServerNames": null, + "APIServerIPs": null, + "DNSDomain": "cluster.local", + "ContainerRuntime": "docker", + "CRISocket": "", + "NetworkPlugin": "", + "FeatureGates": "", + "ServiceCIDR": "10.96.0.0/12", + "ImageRepository": "", + "ExtraOptions": null, + "ShouldLoadCachedImages": true, + "EnableDefaultCNI": false + } +} diff --git a/pkg/minikube/config/testdata/.minikube/profiles/p1/config.json b/pkg/minikube/config/testdata/profile/.minikube/profiles/p1/config.json similarity index 100% rename from pkg/minikube/config/testdata/.minikube/profiles/p1/config.json rename to pkg/minikube/config/testdata/profile/.minikube/profiles/p1/config.json diff --git a/pkg/minikube/config/testdata/.minikube/profiles/p2/config.json b/pkg/minikube/config/testdata/profile/.minikube/profiles/p2/config.json similarity index 100% rename from pkg/minikube/config/testdata/.minikube/profiles/p2/config.json rename to pkg/minikube/config/testdata/profile/.minikube/profiles/p2/config.json diff --git a/pkg/minikube/config/testdata/profile/.minikube/profiles/p3_empty/config.json b/pkg/minikube/config/testdata/profile/.minikube/profiles/p3_empty/config.json new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/pkg/minikube/config/testdata/profile/.minikube/profiles/p4_invalid_file/config.json b/pkg/minikube/config/testdata/profile/.minikube/profiles/p4_invalid_file/config.json new file mode 100644 index 000000000000..9e2e347718f9 --- /dev/null +++ b/pkg/minikube/config/testdata/profile/.minikube/profiles/p4_invalid_file/config.json @@ -0,0 +1 @@ +invalid json file :) \ No newline at end of file diff --git a/pkg/minikube/config/testdata/profile/.minikube/profiles/p5_partial_config/config.json b/pkg/minikube/config/testdata/profile/.minikube/profiles/p5_partial_config/config.json new file mode 100644 index 000000000000..29f62c014986 --- /dev/null +++ b/pkg/minikube/config/testdata/profile/.minikube/profiles/p5_partial_config/config.json @@ -0,0 +1,47 @@ +{ + "MachineConfig": { + "KeepContext": false, + "MinikubeISO": "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso", + "Memory": 2000, + "CPUs": 2, + "DiskSize": 20000, + "ContainerRuntime": "docker", + "HyperkitVpnKitSock": "", + "HyperkitVSockPorts": [], + "XhyveDiskDriver": "ahci-hd", + "DockerEnv": null, + "InsecureRegistry": null, + "RegistryMirror": null, + "HostOnlyCIDR": "192.168.99.1/24", + "HypervVirtualSwitch": "", + "KVMNetwork": "default", + "KVMQemuURI": "qemu:///system", + "KVMGPU": false, + "KVMHidden": false, + "DockerOpt": null, + "DisableDriverMounts": false, + "NFSShare": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "", + "NoVTXCheck": false, + "DNSProxy": false, + "HostDNSResolver": true + }, + "KubernetesConfig": { + "NodePort": 8443, + "NodeName": "minikube", + "APIServerName": "minikubeCA", + "APIServerNames": null, + "APIServerIPs": null, + "DNSDomain": "cluster.local", + "ContainerRuntime": "docker", + "CRISocket": "", + "NetworkPlugin": "", + "FeatureGates": "", + "ServiceCIDR": "10.96.0.0/12", + "ImageRepository": "", + "ExtraOptions": null, + "ShouldLoadCachedImages": true, + "EnableDefaultCNI": false + } +} \ No newline at end of file diff --git a/test/integration/start_stop_delete_test.go b/test/integration/start_stop_delete_test.go index bf575baeee7f..1ed1f6b676fe 100644 --- a/test/integration/start_stop_delete_test.go +++ b/test/integration/start_stop_delete_test.go @@ -139,6 +139,11 @@ func TestStartStop(t *testing.T) { if err != nil { t.Errorf("%s failed: %v", rr.Args, err) } + + rr, err = Run(t, exec.CommandContext(ctx, Target(), "delete", "--all")) + if err != nil { + t.Errorf("%s failed: %v", rr.Args, err) + } }) } }) diff --git a/translations/fr.json b/translations/fr.json index 90805f63d251..83c5a9ec0c7a 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -111,6 +111,7 @@ "Error getting host status": "", "Error getting machine logs": "", "Error getting machine status": "", + "Error getting profiles to delete": "", "Error getting service status": "", "Error getting service with namespace: {{.namespace}} and labels {{.labelName}}:{{.addonName}}: {{.error}}": "", "Error getting the host IP address to use from within the VM": "", @@ -504,6 +505,8 @@ "usage: minikube addons list": "", "usage: minikube addons open ADDON_NAME": "", "usage: minikube config unset PROPERTY_NAME": "", + "usage: minikube delete": "", + "usage: minikube delete --all": "", "usage: minikube profile [MINIKUBE_PROFILE_NAME]": "", "zsh completion failed": "", "{{.addonName}} was successfully enabled": "", @@ -516,4 +519,4 @@ "{{.prefix}}minikube {{.version}} on {{.platform}}": "{{.prefix}}minikube {{.version}} sur {{.platform}}", "{{.type}} is not yet a supported filesystem. We will try anyways!": "", "{{.url}} is not accessible: {{.error}}": "" -} \ No newline at end of file +} diff --git a/translations/zh-CN.json b/translations/zh-CN.json index 6af65586d7e4..d71540137490 100644 --- a/translations/zh-CN.json +++ b/translations/zh-CN.json @@ -111,6 +111,7 @@ "Error getting host status": "", "Error getting machine logs": "", "Error getting machine status": "", + "Error getting profiles to delete": "", "Error getting service status": "", "Error getting service with namespace: {{.namespace}} and labels {{.labelName}}:{{.addonName}}: {{.error}}": "", "Error getting the host IP address to use from within the VM": "", @@ -505,6 +506,8 @@ "usage: minikube addons list": "", "usage: minikube addons open ADDON_NAME": "", "usage: minikube config unset PROPERTY_NAME": "", + "usage: minikube delete": "", + "usage: minikube delete --all": "", "usage: minikube profile [MINIKUBE_PROFILE_NAME]": "", "zsh completion failed": "", "{{.addonName}} was successfully enabled": "", @@ -517,4 +520,4 @@ "{{.prefix}}minikube {{.version}} on {{.platform}}": "{{.platform}} 上的 {{.prefix}}minikube {{.version}}", "{{.type}} is not yet a supported filesystem. We will try anyways!": "", "{{.url}} is not accessible: {{.error}}": "" -} \ No newline at end of file +}