Compare commits

...

3 Commits

Author SHA1 Message Date
Petr Krutov
44ad5e4fe2 Merge branch 'dev-old' into 'main'
Dev old

See merge request rudecs/terraform-provider-decort!30
2022-07-15 18:23:59 +03:00
Petr Krutov
628ce3b75c Merge branch '2.4.1/fix_compute-boot-disk' into 'dev-old'
2.4.1/fix compute boot disk

See merge request rudecs/terraform-provider-decort!29
2022-07-15 18:23:11 +03:00
kjubybot
020845b48f fixed compute boot disk reading 2022-07-15 18:21:24 +03:00

View File

@@ -26,7 +26,6 @@ package decort
import (
"encoding/json"
"errors"
"fmt"
// "net/url"
@@ -97,14 +96,15 @@ func parseBootDiskId(disks []DiskRecord) uint {
return 0
}
func findBootDisk(disks []DiskRecord) (*DiskRecord, error) {
func findBootDisk(disks []DiskRecord) *DiskRecord {
for _, d := range disks {
if d.Type == "B" {
return &d, nil
return &d
}
}
return nil, errors.New("boot disk not found")
// some computes don't have a boot disk, so...
return &DiskRecord{}
}
// Parse the list of interfaces from compute/get response into a list of networks
@@ -171,10 +171,7 @@ func flattenCompute(d *schema.ResourceData, compFacts string) error {
d.Set("started", false)
}
bootDisk, err := findBootDisk(model.Disks)
if err != nil {
return err
}
bootDisk := findBootDisk(model.Disks)
d.Set("boot_disk_size", bootDisk.SizeMax)
d.Set("boot_disk_id", bootDisk.ID) // we may need boot disk ID in resize operations