move machine path to localpath package

pull/5987/head
Medya Gh 2019-12-09 14:51:10 -08:00
parent 35ad8e2915
commit 60346821d6
4 changed files with 12 additions and 13 deletions

View File

@ -262,7 +262,7 @@ func deleteInvalidProfile(profile *pkg_config.Profile) []error {
}
}
pathToMachine := machine.Path(profile.Name, localpath.MiniPath())
pathToMachine := localpath.MachinePath(profile.Name, localpath.MiniPath())
if _, err := os.Stat(pathToMachine); !os.IsNotExist(err) {
err := os.RemoveAll(pathToMachine)
if err != nil {

View File

@ -28,7 +28,6 @@ import (
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/localpath"
"k8s.io/minikube/pkg/minikube/machine"
)
// except returns a list of strings, minus the excluded ones
@ -117,7 +116,7 @@ func TestDeleteProfile(t *testing.T) {
t.Errorf("Profile folder of profile \"%s\" was not deleted", profile.Name)
}
pathToMachine := machine.Path(profile.Name, localpath.MiniPath())
pathToMachine := localpath.MachinePath(profile.Name, localpath.MiniPath())
if _, err := os.Stat(pathToMachine); !os.IsNotExist(err) {
t.Errorf("Profile folder of profile \"%s\" was not deleted", profile.Name)
}

View File

@ -23,7 +23,7 @@ import (
"k8s.io/client-go/util/homedir"
)
// MinikubeHome is the name of the minikube home directory variable.
// MinikubeHome is the name of the minikube home directory environment variable.
const MinikubeHome = "MINIKUBE_HOME"
// ConfigFile is the path of the config file
@ -46,3 +46,12 @@ func MakeMiniPath(fileName ...string) string {
args = append(args, fileName...)
return filepath.Join(args...)
}
// MachinePath returns the Minikube machine path of a machine
func MachinePath(machine string, miniHome ...string) string {
miniPath := MiniPath()
if len(miniHome) > 0 {
miniPath = miniHome[0]
}
return filepath.Join(miniPath, "machines", machine)
}

View File

@ -119,12 +119,3 @@ func machineDirs(miniHome ...string) (dirs []string, err error) {
}
return dirs, err
}
// Path returns the Minikube machine path of a machine
func Path(machine string, miniHome ...string) string {
miniPath := localpath.MiniPath()
if len(miniHome) > 0 {
miniPath = miniHome[0]
}
return filepath.Join(miniPath, "machines", machine)
}