Skip to content

Commit 8326be8

Browse files
committed
resource(instance): fix provider crash when boot_disk_id is empty
Added a nil pointer check to prevent a nil pointer dereference causing the provider to crash when `boot_disk_id` is empty and `disk_attachments` is non-empty. The following configuration now successfully applies. ```hcl resource "oxide_instance" "example" { project_id = data.oxide_project.example.id description = "example" name = "example" host_name = "example" memory = 1024 * 1024 * 1024 ncpus = 2 disk_attachments = [oxide_disk.example.id] } ``` Fixes #466.
1 parent 0bfc1e7 commit 8326be8

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

internal/provider/resource_instance.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,6 +1216,10 @@ func newDiskAttachmentsOnCreate(ctx context.Context, client *oxide.Client, diskI
12161216
}
12171217

12181218
func filterBootDiskFromDisks(disks []oxide.InstanceDiskAttachment, boot_disk *oxide.InstanceDiskAttachment) []oxide.InstanceDiskAttachment {
1219+
if boot_disk == nil {
1220+
return disks
1221+
}
1222+
12191223
var filtered_disks = []oxide.InstanceDiskAttachment{}
12201224
for _, disk := range disks {
12211225
if disk == *boot_disk {

0 commit comments

Comments
 (0)