@@ -286,63 +286,63 @@ func (r *filesystemResource) Update(ctx context.Context, req resource.UpdateRequ
286
286
// Detect changes in the "spec" field
287
287
if ! plan .Spec .Size .Equal (state .Spec .Size ) {
288
288
tflog .Info (ctx , "Detected change in filesystem spec, updating resource" )
289
- }
290
289
291
- inArg := itacservices.FilesystemUpdateRequest {
292
- Metadata : struct {
293
- Name string "json:\" name\" "
294
- }{
295
- Name : plan .Name .ValueString (),
296
- },
297
- Spec : struct {
298
- Request struct {
299
- Size string "json:\" storage\" "
300
- } "json:\" request\" "
301
- }{
302
- Request : struct {
303
- Size string "json:\" storage\" "
290
+ inArg := itacservices.FilesystemUpdateRequest {
291
+ Metadata : struct {
292
+ Name string "json:\" name\" "
304
293
}{
305
- Size : fmt . Sprintf ( "%dTB" , plan .Spec . Size . ValueInt64 () ),
294
+ Name : plan .Name . ValueString ( ),
306
295
},
307
- },
308
- }
309
-
310
- tflog .Info (ctx , "making a call to IDC Service for update filesystem" )
311
- err := r .client .UpdateFilesystem (ctx , & inArg )
312
- if err != nil {
313
- resp .Diagnostics .AddError (
314
- "Error creating order" ,
315
- "Could not create order, unexpected error: " + err .Error (),
316
- )
317
- return
318
- }
319
-
320
- // Get refreshed order value from IDC Service
321
- filesystem , err := r .client .GetFilesystemByResourceId (ctx , state .ID .ValueString ())
322
- if err != nil {
323
- resp .Diagnostics .AddError (
324
- "Error Reading IDC Filesystem resource" ,
325
- "Could not read IDC Filesystem resource ID " + state .ID .ValueString ()+ ": " + err .Error (),
326
- )
327
- return
328
- }
329
-
330
- currState , err := refreshFilesystemResourceModel (ctx , filesystem )
331
- if err != nil {
332
- resp .Diagnostics .AddError (
333
- "Error Reading IDC Filesystem resource" ,
334
- "Could not read IDC Filesystem resource ID " + plan .ID .ValueString ()+ ": " + err .Error (),
335
- )
336
- return
337
- }
338
- currState .Spec .Size = plan .Spec .Size
339
- // Set refreshed state
340
- diags = resp .State .Set (ctx , currState )
341
- resp .Diagnostics .Append (diags ... )
342
- if resp .Diagnostics .HasError () {
343
- return
296
+ Spec : struct {
297
+ Request struct {
298
+ Size string "json:\" storage\" "
299
+ } "json:\" request\" "
300
+ }{
301
+ Request : struct {
302
+ Size string "json:\" storage\" "
303
+ }{
304
+ Size : fmt .Sprintf ("%dTB" , plan .Spec .Size .ValueInt64 ()),
305
+ },
306
+ },
307
+ }
308
+
309
+ tflog .Info (ctx , "making a call to IDC Service for update filesystem" )
310
+ err := r .client .UpdateFilesystem (ctx , & inArg )
311
+ if err != nil {
312
+ resp .Diagnostics .AddError (
313
+ "Error creating order" ,
314
+ "Could not create order, unexpected error: " + err .Error (),
315
+ )
316
+ return
317
+ }
318
+
319
+ // Get refreshed order value from IDC Service
320
+ filesystem , err := r .client .GetFilesystemByResourceId (ctx , state .ID .ValueString ())
321
+ if err != nil {
322
+ resp .Diagnostics .AddError (
323
+ "Error Reading IDC Filesystem resource" ,
324
+ "Could not read IDC Filesystem resource ID " + state .ID .ValueString ()+ ": " + err .Error (),
325
+ )
326
+ return
327
+ }
328
+
329
+ currState , err := refreshFilesystemResourceModel (ctx , filesystem )
330
+ if err != nil {
331
+ resp .Diagnostics .AddError (
332
+ "Error Reading IDC Filesystem resource" ,
333
+ "Could not read IDC Filesystem resource ID " + plan .ID .ValueString ()+ ": " + err .Error (),
334
+ )
335
+ return
336
+ }
337
+ currState .Spec .Size = plan .Spec .Size
338
+ // Set refreshed state
339
+ diags = resp .State .Set (ctx , currState )
340
+ resp .Diagnostics .Append (diags ... )
341
+ if resp .Diagnostics .HasError () {
342
+ return
343
+ }
344
344
}
345
-
345
+ tflog . Info ( ctx , "no change detected change in filesystem spec, skipping update" )
346
346
}
347
347
348
348
func (r * filesystemResource ) ImportState (ctx context.Context , req resource.ImportStateRequest , resp * resource.ImportStateResponse ) {
@@ -391,6 +391,8 @@ func mapFilesystemStatus(fsStatus string) string {
391
391
func refreshFilesystemResourceModel (ctx context.Context , filesystem * itacservices.Filesystem ) (* filesystemResourceModel , error ) {
392
392
393
393
state := & filesystemResourceModel {}
394
+ diags := diag.Diagnostics {}
395
+
394
396
sizeStr := strings .Split (filesystem .Spec .Request .Size , "TB" )[0 ]
395
397
size , _ := strconv .ParseInt (sizeStr , 10 , 64 )
396
398
@@ -421,7 +423,6 @@ func refreshFilesystemResourceModel(ctx context.Context, filesystem *itacservice
421
423
Password : types .StringValue (filesystem .Status .Mount .Password ),
422
424
}
423
425
424
- diags := diag.Diagnostics {}
425
426
state .ClusterInfo , diags = types .ObjectValueFrom (ctx , clusterInfoMap .AttributeTypes (), clusterInfoMap )
426
427
if diags .HasError () {
427
428
return state , fmt .Errorf ("error parsing values" )
0 commit comments