@@ -91,6 +91,7 @@ func (vc *vcenterClient) Datacenters(ctx context.Context) ([]mo.Datacenter, erro
91
91
if err != nil {
92
92
return nil , fmt .Errorf ("unable to retrieve Datacenters: %w" , err )
93
93
}
94
+ defer func () { _ = v .Destroy (ctx ) }()
94
95
95
96
var datacenters []mo.Datacenter
96
97
err = v .Retrieve (ctx , []string {"Datacenter" }, []string {
@@ -109,6 +110,7 @@ func (vc *vcenterClient) Datastores(ctx context.Context, containerMoRef vt.Manag
109
110
if err != nil {
110
111
return nil , fmt .Errorf ("unable to retrieve Datastores: %w" , err )
111
112
}
113
+ defer func () { _ = v .Destroy (ctx ) }()
112
114
113
115
var datastores []mo.Datastore
114
116
err = v .Retrieve (ctx , []string {"Datastore" }, []string {
@@ -129,6 +131,7 @@ func (vc *vcenterClient) ComputeResources(ctx context.Context, containerMoRef vt
129
131
if err != nil {
130
132
return nil , fmt .Errorf ("unable to retrieve ComputeResources (& ClusterComputeResources): %w" , err )
131
133
}
134
+ defer func () { _ = v .Destroy (ctx ) }()
132
135
133
136
var computes []mo.ComputeResource
134
137
err = v .Retrieve (ctx , []string {"ComputeResource" }, []string {
@@ -150,6 +153,7 @@ func (vc *vcenterClient) HostSystems(ctx context.Context, containerMoRef vt.Mana
150
153
if err != nil {
151
154
return nil , fmt .Errorf ("unable to retrieve HostSystems: %w" , err )
152
155
}
156
+ defer func () { _ = v .Destroy (ctx ) }()
153
157
154
158
var hosts []mo.HostSystem
155
159
err = v .Retrieve (ctx , []string {"HostSystem" }, []string {
@@ -177,6 +181,7 @@ func (vc *vcenterClient) ResourcePools(ctx context.Context, containerMoRef vt.Ma
177
181
if err != nil {
178
182
return nil , fmt .Errorf ("unable to retrieve ResourcePools (&VirtualApps): %w" , err )
179
183
}
184
+ defer func () { _ = v .Destroy (ctx ) }()
180
185
181
186
var rps []mo.ResourcePool
182
187
err = v .Retrieve (ctx , []string {"ResourcePool" }, []string {
@@ -198,6 +203,7 @@ func (vc *vcenterClient) VMs(ctx context.Context, containerMoRef vt.ManagedObjec
198
203
if err != nil {
199
204
return nil , fmt .Errorf ("unable to retrieve VMs: %w" , err )
200
205
}
206
+ defer func () { _ = v .Destroy (ctx ) }()
201
207
202
208
var vms []mo.VirtualMachine
203
209
err = v .Retrieve (ctx , []string {"VirtualMachine" }, []string {
0 commit comments