fix unit tests and improve naming
parent
d8d7849d21
commit
d7b6e66038
|
@ -163,7 +163,7 @@ func DeleteProfiles(profiles []*pkg_config.Profile) []error {
|
||||||
err := deleteProfile(profile)
|
err := deleteProfile(profile)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
mm, loadErr := machine.LoadMachine(profile.Name)
|
mm, loadErr := machine.Load(profile.Name)
|
||||||
|
|
||||||
if !profile.IsValid() || (loadErr != nil || !mm.IsValid()) {
|
if !profile.IsValid() || (loadErr != nil || !mm.IsValid()) {
|
||||||
invalidProfileDeletionErrs := deleteInvalidProfile(profile)
|
invalidProfileDeletionErrs := deleteInvalidProfile(profile)
|
||||||
|
@ -263,7 +263,7 @@ func deleteInvalidProfile(profile *pkg_config.Profile) []error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pathToMachine := machine.MachinePath(profile.Name, localpath.MiniPath())
|
pathToMachine := machine.Path(profile.Name, localpath.MiniPath())
|
||||||
if _, err := os.Stat(pathToMachine); !os.IsNotExist(err) {
|
if _, err := os.Stat(pathToMachine); !os.IsNotExist(err) {
|
||||||
err := os.RemoveAll(pathToMachine)
|
err := os.RemoveAll(pathToMachine)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -117,7 +117,7 @@ func TestDeleteProfile(t *testing.T) {
|
||||||
t.Errorf("Profile folder of profile \"%s\" was not deleted", profile.Name)
|
t.Errorf("Profile folder of profile \"%s\" was not deleted", profile.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
pathToMachine := machine.MachinePath(profile.Name, localpath.MiniPath())
|
pathToMachine := machine.Path(profile.Name, localpath.MiniPath())
|
||||||
if _, err := os.Stat(pathToMachine); !os.IsNotExist(err) {
|
if _, err := os.Stat(pathToMachine); !os.IsNotExist(err) {
|
||||||
t.Errorf("Profile folder of profile \"%s\" was not deleted", profile.Name)
|
t.Errorf("Profile folder of profile \"%s\" was not deleted", profile.Name)
|
||||||
}
|
}
|
||||||
|
|
|
@ -655,7 +655,7 @@ func (k *Bootstrapper) UpdateCluster(cfg config.MachineConfig) error {
|
||||||
return errors.Wrap(err, "generating kubelet service")
|
return errors.Wrap(err, "generating kubelet service")
|
||||||
}
|
}
|
||||||
|
|
||||||
glog.Infof("kubelet %s config:\n%s", cfg.KubernetesConfig, kubeletCfg)
|
glog.Infof("kubelet %s config:\n%+v", kubeletCfg, cfg.KubernetesConfig)
|
||||||
|
|
||||||
stopCmd := exec.Command("/bin/bash", "-c", "pgrep kubelet && sudo systemctl stop kubelet")
|
stopCmd := exec.Command("/bin/bash", "-c", "pgrep kubelet && sudo systemctl stop kubelet")
|
||||||
// stop kubelet to avoid "Text File Busy" error
|
// stop kubelet to avoid "Text File Busy" error
|
||||||
|
|
|
@ -60,15 +60,15 @@ func (h *Machine) IsValid() bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListMachines return all valid and invalid machines
|
// List return all valid and invalid machines
|
||||||
// If a machine is valid or invalid is determined by the cluster.IsValid function
|
// If a machine is valid or invalid is determined by the cluster.IsValid function
|
||||||
func ListMachines(miniHome ...string) (validMachines []*Machine, inValidMachines []*Machine, err error) {
|
func List(miniHome ...string) (validMachines []*Machine, inValidMachines []*Machine, err error) {
|
||||||
pDirs, err := machineDirs(miniHome...)
|
pDirs, err := machineDirs(miniHome...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
for _, n := range pDirs {
|
for _, n := range pDirs {
|
||||||
p, err := LoadMachine(n)
|
p, err := Load(n)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Infof("%s not valid: %v", n, err)
|
glog.Infof("%s not valid: %v", n, err)
|
||||||
inValidMachines = append(inValidMachines, p)
|
inValidMachines = append(inValidMachines, p)
|
||||||
|
@ -83,8 +83,8 @@ func ListMachines(miniHome ...string) (validMachines []*Machine, inValidMachines
|
||||||
return validMachines, inValidMachines, nil
|
return validMachines, inValidMachines, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoadMachine loads a machine or throws an error if the machine could not be loadedG
|
// Load loads a machine or throws an error if the machine could not be loadedG
|
||||||
func LoadMachine(name string) (*Machine, error) {
|
func Load(name string) (*Machine, error) {
|
||||||
api, err := NewAPIClient()
|
api, err := NewAPIClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -120,8 +120,8 @@ func machineDirs(miniHome ...string) (dirs []string, err error) {
|
||||||
return dirs, err
|
return dirs, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// MachinePath returns the Minikube machine path of a machine
|
// Path returns the Minikube machine path of a machine
|
||||||
func MachinePath(machine string, miniHome ...string) string {
|
func Path(machine string, miniHome ...string) string {
|
||||||
miniPath := localpath.MiniPath()
|
miniPath := localpath.MiniPath()
|
||||||
if len(miniHome) > 0 {
|
if len(miniHome) > 0 {
|
||||||
miniPath = miniHome[0]
|
miniPath = miniHome[0]
|
||||||
|
|
|
@ -51,7 +51,7 @@ func TestListMachines(t *testing.T) {
|
||||||
files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "machines"))
|
files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "machines"))
|
||||||
numberOfMachineDirs := len(files)
|
numberOfMachineDirs := len(files)
|
||||||
|
|
||||||
validMachines, inValidMachines, err := ListMachines()
|
validMachines, inValidMachines, err := List()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
|
Loading…
Reference in New Issue