Skip to content

Commit

Permalink
minor cleanup
Browse files Browse the repository at this point in the history
1. Rename Migration#CleanUp to change its visibility and fix a typo
2. Replace if-else with a single if-statement

Signed-off-by: Arik Hadas <[email protected]>
  • Loading branch information
ahadas committed Sep 26, 2023
1 parent 48a9a08 commit 00db291
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 1 addition & 3 deletions pkg/controller/plan/adapter/openstack/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -1039,9 +1039,7 @@ func (r *Builder) getStorageClassName(workload *model.Workload, volumeTypeName s
return
}
for _, storageMap := range r.Context.Map.Storage.Spec.Map {
if storageMap.Source.ID == volumeTypeID {
storageClassName = storageMap.Destination.StorageClass
} else if storageMap.Source.Name == volumeTypeName {
if storageMap.Source.ID == volumeTypeID || storageMap.Source.Name == volumeTypeName {
storageClassName = storageMap.Destination.StorageClass
}
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/controller/plan/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ func (r *Migration) Archive() {
}

for _, vm := range r.Plan.Status.Migration.VMs {
err = r.CleanUp(vm)
err = r.cleanup(vm)
if err != nil {
r.Log.Error(err,
"Couldn't clean up VM while archiving plan.",
Expand Down Expand Up @@ -384,7 +384,7 @@ func (r *Migration) Cancel() (err error) {

for _, vm := range r.Plan.Status.Migration.VMs {
if vm.HasCondition(Canceled) {
err = r.CleanUp(vm)
err = r.cleanup(vm)
if err != nil {
r.Log.Error(err,
"Couldn't clean up after canceled VM migration.",
Expand Down Expand Up @@ -415,7 +415,7 @@ func (r *Migration) Cancel() (err error) {
}

// Delete left over migration resources associated with a VM.
func (r *Migration) CleanUp(vm *plan.VMStatus) (err error) {
func (r *Migration) cleanup(vm *plan.VMStatus) (err error) {
if !vm.HasCondition(Succeeded) {
err = r.kubevirt.DeleteVM(vm)
if err != nil {
Expand Down Expand Up @@ -609,7 +609,7 @@ func (r *Migration) execute(vm *plan.VMStatus) (err error) {
vm.MarkStarted()
step.MarkStarted()
step.Phase = Running
err = r.CleanUp(vm)
err = r.cleanup(vm)
if err != nil {
step.AddError(err.Error())
err = nil
Expand Down

0 comments on commit 00db291

Please sign in to comment.