Skip to content

Commit 17c6072

Browse files
committed
reordered logic to update
1 parent 0948582 commit 17c6072

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

ibm/service/vpc/resource_ibm_is_instance_boot_volume_manager.go

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -455,10 +455,6 @@ func instancebootvolUpdate(d *schema.ResourceData, meta interface{}) error {
455455
delete = true
456456
}
457457

458-
if d.HasChange(isVolumeName) {
459-
name = d.Get(isVolumeName).(string)
460-
hasNameChanged = true
461-
}
462458
var capacity int64
463459
if delete {
464460
deleteAllInstanceBootSnapshots(sess, id)
@@ -498,26 +494,6 @@ func instancebootvolUpdate(d *schema.ResourceData, meta interface{}) error {
498494
}
499495
options.IfMatch = &eTag
500496

501-
//name update
502-
volumeNamePatchModel := &vpcv1.VolumePatch{}
503-
if hasNameChanged {
504-
volumeNamePatchModel.Name = &name
505-
volumeNamePatch, err := volumeNamePatchModel.AsPatch()
506-
if err != nil {
507-
return fmt.Errorf("[ERROR] Error calling asPatch for volumeNamePatch in Instance boot volume : %s", err)
508-
}
509-
options.VolumePatch = volumeNamePatch
510-
_, response, err = sess.UpdateVolume(options)
511-
eTag = response.Headers.Get("ETag")
512-
if err != nil {
513-
return err
514-
}
515-
_, err = isWaitForInstanceBootVolumeManagerAvailable(sess, d.Id(), d.Timeout(schema.TimeoutCreate), &eTag)
516-
if err != nil {
517-
return err
518-
}
519-
}
520-
521497
// profile/ iops update
522498
if d.HasChange(isVolumeProfileName) || d.HasChange(isVolumeIops) {
523499
volumeProfilePatchModel := &vpcv1.VolumePatch{}
@@ -678,6 +654,30 @@ func instancebootvolUpdate(d *schema.ResourceData, meta interface{}) error {
678654
}
679655
}
680656

657+
//name update
658+
if d.HasChange(isVolumeName) {
659+
name = d.Get(isVolumeName).(string)
660+
hasNameChanged = true
661+
}
662+
volumeNamePatchModel := &vpcv1.VolumePatch{}
663+
if hasNameChanged {
664+
volumeNamePatchModel.Name = &name
665+
volumeNamePatch, err := volumeNamePatchModel.AsPatch()
666+
if err != nil {
667+
return fmt.Errorf("[ERROR] Error calling asPatch for volumeNamePatch in Instance boot volume : %s", err)
668+
}
669+
options.VolumePatch = volumeNamePatch
670+
_, response, err = sess.UpdateVolume(options)
671+
eTag = response.Headers.Get("ETag")
672+
if err != nil {
673+
return err
674+
}
675+
_, err = isWaitForInstanceBootVolumeManagerAvailable(sess, d.Id(), d.Timeout(schema.TimeoutCreate), &eTag)
676+
if err != nil {
677+
return err
678+
}
679+
}
680+
681681
return nil
682682
}
683683

0 commit comments

Comments
 (0)