Skip to content

Commit 8bc31d4

Browse files
committed
replace deprecated resource.RetryableError and friends
1 parent 97bbf1c commit 8bc31d4

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

libvirt/resource_libvirt_volume.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77

88
libvirt "github.com/digitalocean/go-libvirt"
99
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
10-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
10+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
1111
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1212
)
1313

@@ -101,9 +101,9 @@ func resourceLibvirtVolumeCreate(ctx context.Context, d *schema.ResourceData, me
101101

102102
// Refresh the pool of the volume so that libvirt knows it is
103103
// not longer in use.
104-
if err := resource.RetryContext(ctx, d.Timeout(schema.TimeoutCreate), func() *resource.RetryError {
104+
if err := retry.RetryContext(ctx, d.Timeout(schema.TimeoutCreate), func() *retry.RetryError {
105105
if err := virConn.StoragePoolRefresh(pool, 0); err != nil {
106-
return resource.RetryableError(err)
106+
return retry.RetryableError(err)
107107
}
108108
return nil
109109
}); err != nil {
@@ -281,39 +281,39 @@ func resourceLibvirtVolumeRead(ctx context.Context, d *schema.ResourceData, meta
281281
poolName := d.Get("pool").(string)
282282

283283
var volume libvirt.StorageVol
284-
err := resource.RetryContext(ctx, d.Timeout(schema.TimeoutRead), func() *resource.RetryError {
284+
err := retry.RetryContext(ctx, d.Timeout(schema.TimeoutRead), func() *retry.RetryError {
285285
var lookupErr error
286286
volume, lookupErr = virConn.StorageVolLookupByKey(d.Id())
287287
if lookupErr == nil {
288288
return nil
289289
}
290290

291291
if !isError(lookupErr, libvirt.ErrNoStorageVol) {
292-
return resource.NonRetryableError(lookupErr)
292+
return retry.NonRetryableError(lookupErr)
293293
}
294294

295295
// volume not found, try to start the pool before retry
296296
volPool, err := virConn.StoragePoolLookupByName(poolName)
297297
if err != nil {
298-
return resource.NonRetryableError(fmt.Errorf("error retrieving pool %s for volume %s: %w", poolName, d.Id(), err))
298+
return retry.NonRetryableError(fmt.Errorf("error retrieving pool %s for volume %s: %w", poolName, d.Id(), err))
299299
}
300300

301301
active, err := virConn.StoragePoolIsActive(volPool)
302302
if err != nil {
303-
return resource.NonRetryableError(fmt.Errorf("error retrieving status of pool %s for volume %s: %w", poolName, d.Id(), err))
303+
return retry.NonRetryableError(fmt.Errorf("error retrieving status of pool %s for volume %s: %w", poolName, d.Id(), err))
304304
}
305305

306306
// pool was already started, nothing else to do
307307
if active == 1 {
308-
return resource.NonRetryableError(lookupErr)
308+
return retry.NonRetryableError(lookupErr)
309309
}
310310

311311
if err := virConn.StoragePoolCreate(volPool, 0); err != nil {
312-
return resource.NonRetryableError(fmt.Errorf("error starting pool %s: %w", poolName, err))
312+
return retry.NonRetryableError(fmt.Errorf("error starting pool %s: %w", poolName, err))
313313
}
314314

315315
// pool started successfully, retry
316-
return resource.RetryableError(lookupErr)
316+
return retry.RetryableError(lookupErr)
317317
})
318318

319319
if isError(err, libvirt.ErrNoStorageVol) {

0 commit comments

Comments
 (0)