@@ -41,9 +41,7 @@ import (
41
41
vmwareutil "sigs.k8s.io/cluster-api-provider-vsphere/pkg/util/vmware"
42
42
)
43
43
44
- type VmopMachineService struct {
45
- deleteFunc func (vm * vmoprv1.VirtualMachine ) error
46
- }
44
+ type VmopMachineService struct {}
47
45
48
46
func (v * VmopMachineService ) FetchVSphereMachine (client client.Client , name types.NamespacedName ) (context.MachineContext , error ) {
49
47
vsphereMachine := & vmwarev1.VSphereMachine {}
@@ -85,13 +83,6 @@ func (v *VmopMachineService) ReconcileDelete(c context.MachineContext) error {
85
83
}()
86
84
}
87
85
88
- // Allow deleteFunc to be swappable for unit testing
89
- if v .deleteFunc == nil {
90
- v .deleteFunc = func (vm * vmoprv1.VirtualMachine ) error {
91
- return ctx .Client .Delete (ctx , vm )
92
- }
93
- }
94
-
95
86
// First, check to see if it's already deleted
96
87
vmopVM := vmoprv1.VirtualMachine {}
97
88
if err := ctx .Client .Get (ctx , types.NamespacedName {Namespace : ctx .Machine .Namespace , Name : ctx .Machine .Name }, & vmopVM ); err != nil {
@@ -110,7 +101,7 @@ func (v *VmopMachineService) ReconcileDelete(c context.MachineContext) error {
110
101
}
111
102
112
103
// If none of the above are true, Delete the VM
113
- if err := v . deleteFunc ( & vmopVM ); err != nil {
104
+ if err := ctx . Client . Delete ( ctx , & vmopVM ); err != nil {
114
105
if apierrors .IsNotFound (err ) {
115
106
ctx .VSphereMachine .Status .VMStatus = vmwarev1 .VirtualMachineStateNotFound
116
107
return err
0 commit comments