6
6
"strings"
7
7
8
8
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
9
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource "
9
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry "
10
10
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
11
11
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
12
12
documentdb "github.com/scaleway/scaleway-sdk-go/api/documentdb/v1beta1"
@@ -90,17 +90,17 @@ func resourceScalewayDocumentDBPrivilegeCreate(ctx context.Context, d *schema.Re
90
90
}
91
91
92
92
// wrapper around StateChangeConf that will just retry write on database
93
- err = resource .RetryContext (ctx , d .Timeout (schema .TimeoutCreate ), func () * resource .RetryError {
93
+ err = retry .RetryContext (ctx , d .Timeout (schema .TimeoutCreate ), func () * retry .RetryError {
94
94
_ , errSetPrivilege := api .SetPrivilege (createReq , scw .WithContext (ctx ))
95
95
if errSetPrivilege != nil {
96
96
if is409Error (errSetPrivilege ) {
97
97
_ , errWait := waitForDocumentDBInstance (ctx , api , region , instanceID , d .Timeout (schema .TimeoutCreate ))
98
98
if errWait != nil {
99
- return resource .NonRetryableError (errWait )
99
+ return retry .NonRetryableError (errWait )
100
100
}
101
- return resource .RetryableError (errSetPrivilege )
101
+ return retry .RetryableError (errSetPrivilege )
102
102
}
103
- return resource .NonRetryableError (errSetPrivilege )
103
+ return retry .NonRetryableError (errSetPrivilege )
104
104
}
105
105
return nil
106
106
})
@@ -221,17 +221,17 @@ func resourceScalewayDocumentDBPrivilegeUpdate(ctx context.Context, d *schema.Re
221
221
}
222
222
223
223
// wrapper around StateChangeConf that will just retry the database creation
224
- err = resource .RetryContext (ctx , d .Timeout (schema .TimeoutUpdate ), func () * resource .RetryError {
224
+ err = retry .RetryContext (ctx , d .Timeout (schema .TimeoutUpdate ), func () * retry .RetryError {
225
225
_ , errSet := api .SetPrivilege (updateReq , scw .WithContext (ctx ))
226
226
if errSet != nil {
227
227
if is409Error (errSet ) {
228
228
_ , errWait := waitForDocumentDBInstance (ctx , api , region , instanceID , d .Timeout (schema .TimeoutUpdate ))
229
229
if errWait != nil {
230
- return resource .NonRetryableError (errWait )
230
+ return retry .NonRetryableError (errWait )
231
231
}
232
- return resource .RetryableError (errSet )
232
+ return retry .RetryableError (errSet )
233
233
}
234
- return resource .NonRetryableError (errSet )
234
+ return retry .NonRetryableError (errSet )
235
235
}
236
236
return nil
237
237
})
@@ -292,7 +292,7 @@ func resourceScalewayDocumentDBPrivilegeDelete(ctx context.Context, d *schema.Re
292
292
}
293
293
294
294
// wrapper around StateChangeConf that will just retry the database creation
295
- err = resource .RetryContext (ctx , defaultRdbInstanceTimeout , func () * resource .RetryError {
295
+ err = retry .RetryContext (ctx , defaultRdbInstanceTimeout , func () * retry .RetryError {
296
296
// check if user exist on retry
297
297
listUsers , errUserExist := api .ListUsers (& documentdb.ListUsersRequest {
298
298
Region : region ,
@@ -304,7 +304,7 @@ func resourceScalewayDocumentDBPrivilegeDelete(ctx context.Context, d *schema.Re
304
304
d .SetId ("" )
305
305
return nil
306
306
}
307
- return resource .NonRetryableError (errUserExist )
307
+ return retry .NonRetryableError (errUserExist )
308
308
}
309
309
310
310
if listUsers != nil && len (listUsers .Users ) == 0 {
@@ -316,11 +316,11 @@ func resourceScalewayDocumentDBPrivilegeDelete(ctx context.Context, d *schema.Re
316
316
if is409Error (errSet ) {
317
317
_ , errWait := waitForDocumentDBInstance (ctx , api , region , instanceID , d .Timeout (schema .TimeoutDelete ))
318
318
if errWait != nil {
319
- return resource .NonRetryableError (errWait )
319
+ return retry .NonRetryableError (errWait )
320
320
}
321
- return resource .RetryableError (errSet )
321
+ return retry .RetryableError (errSet )
322
322
}
323
- return resource .NonRetryableError (errSet )
323
+ return retry .NonRetryableError (errSet )
324
324
}
325
325
return nil
326
326
})
0 commit comments