Refactor
pull/4780/head
Marek Schwarz 2019-08-18 19:44:09 +02:00
parent 229c9b7ee9
commit 4835945839
1 changed files with 8 additions and 11 deletions

View File

@ -115,20 +115,17 @@ func DeleteProfiles(profiles []*pkg_config.Profile) []error {
for _, profile := range profiles {
err := deleteProfile(profile)
var mm *cluster.Machine
var loadErr error
if err != nil {
mm, loadErr = cluster.LoadMachine(profile.Name)
}
mm, loadErr := cluster.LoadMachine(profile.Name)
if (err != nil && !profile.IsValid()) || (loadErr != nil || !mm.IsValid()) {
invalidProfileDeletionErrs := deleteInvalidProfile(profile)
if len(invalidProfileDeletionErrs) > 0 {
errs = append(errs, invalidProfileDeletionErrs...)
if !profile.IsValid() || (loadErr != nil || !mm.IsValid()) {
invalidProfileDeletionErrs := deleteInvalidProfile(profile)
if len(invalidProfileDeletionErrs) > 0 {
errs = append(errs, invalidProfileDeletionErrs...)
}
} else {
errs = append(errs, err)
}
} else if err != nil {
errs = append(errs, err)
}
}
return errs