This commit is contained in:
2026-06-02 11:28:16 +03:00
parent af79f6ab3e
commit c734dcfff7
254 changed files with 10439 additions and 3751 deletions

View File

@@ -1,39 +0,0 @@
package disks
import (
"context"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
)
func dataSourceDiskListTypesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
listTypes, err := utilityDiskListTypesCheckPresence(ctx, d, m)
if err != nil {
d.SetId("")
return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String())
d.Set("items", listTypes.Data)
d.Set("entry_count", listTypes.EntryCount)
return nil
}
func DataSourceDiskListTypes() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceDiskListTypesRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceDiskListTypesSchemaMake(),
}
}

View File

@@ -1,38 +0,0 @@
package disks
import (
"context"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
)
func dataSourceDiskListTypesDetailedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
listTypesDetailed, err := utilityDiskListTypesDetailedCheckPresence(ctx, d, m)
if err != nil {
d.SetId("")
return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String())
d.Set("items", flattenDiskListTypesDetailed(listTypesDetailed))
d.Set("entry_count", listTypesDetailed.EntryCount)
return nil
}
func DataSourceDiskListTypesDetailed() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceDiskListTypesDetailedRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceDiskListTypesDetailedSchemaMake(),
}
}

View File

@@ -14,6 +14,7 @@ func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) {
d.Set("account_name", disk.AccountName)
d.Set("acl", string(diskAcl))
d.Set("blk_discard", disk.BLKDiscard)
d.Set("block_size", disk.BlockSize)
d.Set("boot_partition", disk.BootPartition)
d.Set("computes", flattenDiskComputes(disk.Computes))
d.Set("created_by", disk.CreatedBy)
@@ -29,6 +30,7 @@ func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) {
d.Set("disk_id", disk.ID)
d.Set("image_id", disk.ImageID)
d.Set("images", disk.Images)
d.Set("independent", disk.Independent)
d.Set("iotune", flattenIOTune(disk.IOTune))
d.Set("iqn", disk.IQN)
d.Set("login", disk.Login)
@@ -44,6 +46,7 @@ func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) {
d.Set("pool", disk.Pool)
d.Set("purge_attempts", disk.PurgeAttempts)
d.Set("present_to", disk.PresentTo)
d.Set("provision", disk.Provision)
d.Set("purge_time", disk.PurgeTime)
d.Set("replication", flattenDiskReplication(disk.Replication))
d.Set("reality_device_number", disk.RealityDeviceNumber)
@@ -62,7 +65,6 @@ func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) {
d.Set("status", disk.Status)
d.Set("storage_policy_id", disk.StoragePolicyID)
d.Set("tech_status", disk.TechStatus)
d.Set("type", disk.Type)
d.Set("vmid", disk.VMID)
d.Set("updated_by", disk.UpdatedBy)
d.Set("updated_time", disk.UpdatedTime)
@@ -117,7 +119,6 @@ func flattenDiskReplica(d *schema.ResourceData, disk *disks.RecordDisk, statusRe
d.Set("status", disk.Status)
d.Set("status_replication", statusReplication)
d.Set("tech_status", disk.TechStatus)
d.Set("type", disk.Type)
d.Set("vmid", disk.VMID)
}
@@ -187,6 +188,7 @@ func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} {
"account_name": disk.AccountName,
"acl": string(diskAcl),
"blk_discard": disk.BLKDiscard,
"block_size": disk.BlockSize,
"boot_partition": disk.BootPartition,
"computes": flattenDiskComputes(disk.Computes),
"created_by": disk.CreatedBy,
@@ -202,6 +204,7 @@ func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} {
"disk_id": disk.ID,
"image_id": disk.ImageID,
"images": disk.Images,
"independent": disk.Independent,
"iotune": flattenIOTune(disk.IOTune),
"iqn": disk.IQN,
"login": disk.Login,
@@ -217,6 +220,8 @@ func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} {
"pool": disk.Pool,
"purge_attempts": disk.PurgeAttempts,
"purge_time": disk.PurgeTime,
"present_to": disk.PresentTo,
"provision": disk.Provision,
"replication": flattenDiskReplication(disk.Replication),
"reality_device_number": disk.RealityDeviceNumber,
"reference_id": disk.ReferenceID,
@@ -234,7 +239,6 @@ func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} {
"status": disk.Status,
"storage_policy_id": disk.StoragePolicyID,
"tech_status": disk.TechStatus,
"type": disk.Type,
"vmid": disk.VMID,
"updated_by": disk.UpdatedBy,
"updated_time": disk.UpdatedTime,
@@ -243,7 +247,6 @@ func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} {
res = append(res, temp)
}
return res
}
func flattendDiskSnapshotList(sl disks.ListSnapshots) []interface{} {
@@ -261,36 +264,6 @@ func flattendDiskSnapshotList(sl disks.ListSnapshots) []interface{} {
res = append(res, temp)
}
return res
}
func flattenDiskListTypesDetailed(tld *disks.ListTypes) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
for _, typeListDetailed := range tld.Data {
toMap := typeListDetailed.(map[string]interface{})
temp := map[string]interface{}{
"pools": flattenListTypesDetailedPools(toMap["pools"].([]interface{})),
"sep_id": toMap["sepId"].(float64),
"sep_name": toMap["sepName"].(string),
}
res = append(res, temp)
}
return res
}
func flattenListTypesDetailedPools(pools []interface{}) []interface{} {
res := make([]interface{}, 0)
for _, pool := range pools {
toMap := pool.(map[string]interface{})
temp := map[string]interface{}{
"name": toMap["name"].(string),
"system": toMap["system"].(string),
"types": toMap["types"].([]interface{}),
}
res = append(res, temp)
}
return res
}
@@ -304,6 +277,7 @@ func flattenDiskListUnattached(ul *disks.ListUnattachedDisks) []map[string]inter
"account_name": unattachedDisk.AccountName,
"acl": string(unattachedDiskAcl),
"blk_discard": unattachedDisk.BLKDiscard,
"block_size": unattachedDisk.BlockSize,
"boot_partition": unattachedDisk.BootPartition,
"created_time": unattachedDisk.CreatedTime,
"deleted_time": unattachedDisk.DeletedTime,
@@ -327,6 +301,7 @@ func flattenDiskListUnattached(ul *disks.ListUnattachedDisks) []map[string]inter
"pci_slot": unattachedDisk.PCISlot,
"pool": unattachedDisk.Pool,
"present_to": unattachedDisk.PresentTo,
"provision": unattachedDisk.Provision,
"purge_attempts": unattachedDisk.PurgeAttempts,
"purge_time": unattachedDisk.PurgeTime,
"reality_device_number": unattachedDisk.RealityDeviceNumber,
@@ -342,7 +317,7 @@ func flattenDiskListUnattached(ul *disks.ListUnattachedDisks) []map[string]inter
"snapshots": flattenDiskSnapshotList(unattachedDisk.Snapshots),
"status": unattachedDisk.Status,
"tech_status": unattachedDisk.TechStatus,
"type": unattachedDisk.Type,
"to_clean": unattachedDisk.ToClean,
"vmid": unattachedDisk.VMID,
}
res = append(res, tmp)

View File

@@ -102,6 +102,12 @@ func resourceDiskCreate(ctx context.Context, d *schema.ResourceData, m interface
log.Debugf("resourceDiskCreate: finished present for disk %d", d.Get("disk_id"))
}
if _, ok := d.GetOk("block_size"); ok {
if err := resourceDiskChangeBlockSize(ctx, d, m); err != nil {
w.Add(err)
}
}
if _, ok := d.GetOk("iotune"); ok {
if err := resourceDiskChangeIotune(ctx, d, m); err != nil {
w.Add(err)
@@ -244,14 +250,20 @@ func resourceDiskUpdate(ctx context.Context, d *schema.ResourceData, m interface
}
}
if d.HasChange("cache") {
if err := resourceDiskChangeCache(ctx, d, m); err != nil {
return diag.FromErr(err)
if d.HasChanges("cache", "blk_discard", "block_size") {
updateReq := disks.UpdateRequest{
DiskID: uint64(d.Get("disk_id").(int)),
}
}
if d.HasChange("blk_discard") {
if err := resourceDiskChangeBLKDiscard(ctx, d, m); err != nil {
if d.HasChange("cache") {
updateReq.Cache = d.Get("cache").(string)
}
if d.HasChange("blk_discard") {
updateReq.BLKDiscard = d.Get("blk_discard").(bool)
}
if d.HasChange("block_size") {
updateReq.BlockSize = d.Get("block_size").(string)
}
if _, err := c.CloudBroker().Disks().Update(ctx, updateReq); err != nil {
return diag.FromErr(err)
}
}
@@ -382,22 +394,12 @@ func resourceDiskChangeStoragePolicyID(ctx context.Context, d *schema.ResourceDa
return err
}
func resourceDiskChangeCache(ctx context.Context, d *schema.ResourceData, m interface{}) error {
func resourceDiskChangeBlockSize(ctx context.Context, d *schema.ResourceData, m interface{}) error {
c := m.(*controller.ControllerCfg)
_, err := c.CloudBroker().Disks().Update(ctx, disks.UpdateRequest{
DiskID: uint64(d.Get("disk_id").(int)),
Cache: d.Get("cache").(string),
})
return err
}
func resourceDiskChangeBLKDiscard(ctx context.Context, d *schema.ResourceData, m interface{}) error {
c := m.(*controller.ControllerCfg)
_, err := c.CloudBroker().Disks().Update(ctx, disks.UpdateRequest{
DiskID: uint64(d.Get("disk_id").(int)),
BLKDiscard: d.Get("blk_discard").(bool),
DiskID: uint64(d.Get("disk_id").(int)),
BlockSize: d.Get("block_size").(string),
})
return err
}

View File

@@ -2,6 +2,7 @@ package disks
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)
func dataSourceDiskSchemaMake() map[string]*schema.Schema {
@@ -26,6 +27,10 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
Type: schema.TypeBool,
Computed: true,
},
"block_size": {
Type: schema.TypeString,
Computed: true,
},
"boot_partition": {
Type: schema.TypeInt,
Computed: true,
@@ -97,6 +102,10 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
},
},
"independent": {
Type: schema.TypeBool,
Computed: true,
},
"iotune": {
Type: schema.TypeList,
Computed: true,
@@ -212,6 +221,10 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
},
},
"provision": {
Type: schema.TypeString,
Computed: true,
},
"purge_attempts": {
Type: schema.TypeInt,
Computed: true,
@@ -350,10 +363,6 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"type": {
Type: schema.TypeString,
Computed: true,
},
"vmid": {
Type: schema.TypeInt,
Computed: true,
@@ -412,11 +421,6 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
Optional: true,
Description: "ID of the account the disks belong to",
},
"type": {
Type: schema.TypeString,
Optional: true,
Description: "type of the disks",
},
"sep_id": {
Type: schema.TypeInt,
Optional: true,
@@ -447,6 +451,16 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
Optional: true,
Description: "storage policy ID ",
},
"rg_id": {
Type: schema.TypeInt,
Optional: true,
Description: "Find by rg id",
},
"compute_id": {
Type: schema.TypeInt,
Optional: true,
Description: "Find by compute id",
},
"items": {
Type: schema.TypeList,
Computed: true,
@@ -468,6 +482,10 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeBool,
Computed: true,
},
"block_size": {
Type: schema.TypeString,
Computed: true,
},
"boot_partition": {
Type: schema.TypeInt,
Computed: true,
@@ -543,6 +561,10 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
},
},
"independent": {
Type: schema.TypeBool,
Computed: true,
},
"iotune": {
Type: schema.TypeList,
Computed: true,
@@ -658,6 +680,10 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
},
},
"provision": {
Type: schema.TypeString,
Computed: true,
},
"purge_attempts": {
Type: schema.TypeInt,
Computed: true,
@@ -796,10 +822,6 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"type": {
Type: schema.TypeString,
Computed: true,
},
"vmid": {
Type: schema.TypeInt,
Computed: true,
@@ -859,11 +881,6 @@ func dataSourceDiskListDeletedSchemaMake() map[string]*schema.Schema {
Optional: true,
Description: "ID of the account the disks belong to",
},
"type": {
Type: schema.TypeString,
Optional: true,
Description: "type of the disks",
},
"sort_by": {
Type: schema.TypeString,
Optional: true,
@@ -900,6 +917,10 @@ func dataSourceDiskListDeletedSchemaMake() map[string]*schema.Schema {
Type: schema.TypeBool,
Computed: true,
},
"block_size": {
Type: schema.TypeString,
Computed: true,
},
"boot_partition": {
Type: schema.TypeInt,
Computed: true,
@@ -975,6 +996,10 @@ func dataSourceDiskListDeletedSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
},
},
"independent": {
Type: schema.TypeBool,
Computed: true,
},
"iotune": {
Type: schema.TypeList,
Computed: true,
@@ -1090,6 +1115,10 @@ func dataSourceDiskListDeletedSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
},
},
"provision": {
Type: schema.TypeString,
Computed: true,
},
"purge_attempts": {
Type: schema.TypeInt,
Computed: true,
@@ -1228,10 +1257,6 @@ func dataSourceDiskListDeletedSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"type": {
Type: schema.TypeString,
Computed: true,
},
"vmid": {
Type: schema.TypeInt,
Computed: true,
@@ -1259,105 +1284,6 @@ func dataSourceDiskListDeletedSchemaMake() map[string]*schema.Schema {
return res
}
func dataSourceDiskListTypesSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{
"sort_by": {
Type: schema.TypeString,
Optional: true,
Description: "sort by one of supported fields, format +|-(field)",
},
"page": {
Type: schema.TypeInt,
Optional: true,
Description: "page number",
},
"size": {
Type: schema.TypeInt,
Optional: true,
Description: "page size",
},
"items": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
Description: "The types of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp'",
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
return res
}
func dataSourceDiskListTypesDetailedSchemaMake() map[string]*schema.Schema {
return map[string]*schema.Schema{
"sort_by": {
Type: schema.TypeString,
Optional: true,
Description: "sort by one of supported fields, format +|-(field)",
},
"page": {
Type: schema.TypeInt,
Optional: true,
Description: "page number",
},
"size": {
Type: schema.TypeInt,
Optional: true,
Description: "page size",
},
"items": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"pools": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Computed: true,
Description: "Pool name",
},
"system": {
Type: schema.TypeString,
Computed: true,
},
"types": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
Description: "The types of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp'",
},
},
},
},
"sep_id": {
Type: schema.TypeInt,
Computed: true,
Description: "Storage endpoint provider ID to create disk",
},
"sep_name": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
}
func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{
"by_id": {
@@ -1380,11 +1306,6 @@ func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema {
Optional: true,
Description: "Find by status",
},
"type": {
Type: schema.TypeString,
Optional: true,
Description: "type of the disks",
},
"account_id": {
Type: schema.TypeInt,
Optional: true,
@@ -1450,6 +1371,10 @@ func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema {
Type: schema.TypeBool,
Computed: true,
},
"block_size": {
Type: schema.TypeString,
Computed: true,
},
"boot_partition": {
Type: schema.TypeInt,
Computed: true,
@@ -1638,6 +1563,10 @@ func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
},
},
"provision": {
Type: schema.TypeString,
Computed: true,
},
"purge_attempts": {
Type: schema.TypeInt,
Computed: true,
@@ -1748,10 +1677,9 @@ func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "Technical status of the disk",
},
"type": {
Type: schema.TypeString,
Computed: true,
Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp'",
"to_clean": {
Type: schema.TypeBool,
Computed: true,
},
"vmid": {
Type: schema.TypeInt,
@@ -1952,11 +1880,6 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Required: true,
},
"type": {
Type: schema.TypeString,
Computed: true,
Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp'",
},
"sep_id": {
Type: schema.TypeInt,
Optional: true,
@@ -2008,6 +1931,12 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
Optional: true,
Default: false,
},
"block_size": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{"512", "512e", "4k"}, false),
},
"account_name": {
Type: schema.TypeString,
Computed: true,
@@ -2079,6 +2008,10 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
},
},
"independent": {
Type: schema.TypeBool,
Computed: true,
},
"iotune": {
Type: schema.TypeList,
Optional: true,
@@ -2201,6 +2134,10 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
},
},
"provision": {
Type: schema.TypeString,
Computed: true,
},
"purge_attempts": {
Type: schema.TypeInt,
Computed: true,

View File

@@ -33,7 +33,6 @@ package disks
import (
"context"
"strings"
log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/disks"
@@ -67,9 +66,6 @@ func utilityDiskListCheckPresence(ctx context.Context, d *schema.ResourceData, m
if accountId, ok := d.GetOk("account_id"); ok {
req.AccountID = uint64(accountId.(int))
}
if diskType, ok := d.GetOk("type"); ok {
req.Type = strings.ToUpper(diskType.(string))
}
if pool, ok := d.GetOk("pool"); ok {
req.Pool = pool.(string)
}
@@ -88,6 +84,12 @@ func utilityDiskListCheckPresence(ctx context.Context, d *schema.ResourceData, m
if storagePolicyID, ok := d.GetOk("storage_policy_id"); ok {
req.StoragePolicyID = uint64(storagePolicyID.(int))
}
if rgID, ok := d.GetOk("rg_id"); ok {
req.RGID = uint64(rgID.(int))
}
if computeID, ok := d.GetOk("compute_id"); ok {
req.ComputeID = uint64(computeID.(int))
}
log.Debugf("utilityDiskListCheckPresence: load disk list")
diskList, err := c.CloudBroker().Disks().List(ctx, req)

View File

@@ -65,9 +65,6 @@ func utilityDiskListDeletedCheckPresence(ctx context.Context, d *schema.Resource
if account_id, ok := d.GetOk("account_id"); ok {
req.AccountID = uint64(account_id.(int))
}
if typev, ok := d.GetOk("type"); ok {
req.Type = typev.(string)
}
if sortBy, ok := d.GetOk("sort_by"); ok {
req.SortBy = sortBy.(string)
}

View File

@@ -1,35 +0,0 @@
package disks
import (
"context"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/disks"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
)
func utilityDiskListTypesCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*disks.ListTypes, error) {
c := m.(*controller.ControllerCfg)
req := disks.ListTypesRequest{
Detailed: false,
}
if sortBy, ok := d.GetOk("sort_by"); ok {
req.SortBy = sortBy.(string)
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
log.Debugf("utilityDiskListTypesCheckPresence: load disk list Types Detailed")
typesList, err := c.CloudBroker().Disks().ListTypes(ctx, req)
if err != nil {
return nil, err
}
return typesList, nil
}

View File

@@ -1,38 +0,0 @@
package disks
import (
"context"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/disks"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
)
func utilityDiskListTypesDetailedCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*disks.ListTypes, error) {
c := m.(*controller.ControllerCfg)
req := disks.ListTypesRequest{
Detailed: true,
}
if sortBy, ok := d.GetOk("sort_by"); ok {
req.SortBy = sortBy.(string)
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
log.Debugf("utilityDiskListTypesDetailedCheckPresence: load disk list Types Detailed")
listTypesDetailed, err := c.CloudBroker().Disks().ListTypes(ctx, req)
log.Debugf("%+v", listTypesDetailed.Data[0].(map[string]interface{}))
if err != nil {
return nil, err
}
return listTypesDetailed, nil
}

View File

@@ -25,9 +25,6 @@ func utilityDiskListUnattachedCheckPresence(ctx context.Context, d *schema.Resou
if status, ok := d.GetOk("status"); ok {
req.Status = status.(string)
}
if diskType, ok := d.GetOk("type"); ok {
req.Type = diskType.(string)
}
if accountId, ok := d.GetOk("account_id"); ok {
req.AccountID = uint64(accountId.(int))
}