This commit is contained in:
asteam
2025-07-01 13:44:09 +03:00
parent 5382579a5f
commit ddbb12996d
1041 changed files with 2842 additions and 96448 deletions

View File

@@ -23,7 +23,7 @@ func DiskResource(ctx context.Context, plan *models.ResourceDiskModel, c *client
diags := diag.Diagnostics{}
diskId, err := strconv.ParseUint(plan.Id.ValueString(), 10, 64)
diskId, err := strconv.ParseUint(plan.ID.ValueString(), 10, 64)
if err != nil {
diags.AddError("flattens.DiskResource: Cannot parse disk ID from state", err.Error())
return diags
@@ -43,13 +43,11 @@ func DiskResource(ctx context.Context, plan *models.ResourceDiskModel, c *client
AccountID: types.Int64Value(int64(recordDisk.AccountID)),
DiskName: types.StringValue(recordDisk.Name),
SizeMax: types.Int64Value(int64(recordDisk.SizeMax)),
GID: types.Int64Value(int64(recordDisk.GID)),
// optional fields
Description: plan.Description,
Pool: plan.Pool,
SEPID: plan.SEPID,
Type: plan.Type,
Description: types.StringValue(recordDisk.Description),
Pool: types.StringValue(recordDisk.Pool),
SEPID: types.Int64Value(int64(recordDisk.SepID)),
Detach: plan.Detach,
Permanently: plan.Permanently,
Shareable: plan.Shareable,
@@ -57,16 +55,21 @@ func DiskResource(ctx context.Context, plan *models.ResourceDiskModel, c *client
// computed fields
LastUpdated: plan.LastUpdated,
Id: types.StringValue(strconv.Itoa(int(recordDisk.ID))),
DiskId: types.Int64Value(int64(recordDisk.ID)),
ID: types.StringValue(strconv.Itoa(int(recordDisk.ID))),
DiskID: types.Int64Value(int64(recordDisk.ID)),
AccountName: types.StringValue(recordDisk.AccountName),
ACL: types.StringValue(string(diskAcl)),
Computes: flattenComputes(ctx, recordDisk.Computes),
CreatedBy: types.StringValue(recordDisk.CreatedBy),
CreatedTime: types.Int64Value(int64(recordDisk.CreatedTime)),
DeletedBy: types.StringValue(recordDisk.DeletedBy),
DeletedTime: types.Int64Value(int64(recordDisk.DeletedTime)),
DestructionTime: types.Int64Value(int64(recordDisk.DestructionTime)),
DeviceName: types.StringValue(recordDisk.DeviceName),
ImageID: types.Int64Value(int64(recordDisk.ImageID)),
MachineID: types.Int64Value(int64(recordDisk.MachineID)),
MachineName: types.StringValue(recordDisk.MachineName),
GID: types.Int64Value(int64(recordDisk.GID)),
Order: types.Int64Value(int64(recordDisk.Order)),
Params: types.StringValue(recordDisk.Params),
ParentID: types.Int64Value(int64(recordDisk.ParentID)),
@@ -80,14 +83,17 @@ func DiskResource(ctx context.Context, plan *models.ResourceDiskModel, c *client
Snapshots: flattenSnapshots(ctx, recordDisk.Snapshots),
Status: types.StringValue(recordDisk.Status),
TechStatus: types.StringValue(recordDisk.TechStatus),
Type: types.StringValue(recordDisk.Type),
UpdatedBy: types.StringValue(recordDisk.UpdatedBy),
UpdatedTime: types.Int64Value(int64(recordDisk.UpdatedTime)),
VMID: types.Int64Value(int64(recordDisk.VMID)),
}
plan.Images, diags = types.ListValueFrom(ctx, types.StringType, recordDisk.Images)
plan.Images, diags = types.ListValueFrom(ctx, types.Int64Type, recordDisk.Images)
if diags != nil {
tflog.Error(ctx, fmt.Sprint("flattens.DiskResource: cannot flatten recordDisk.Images to plan.Images", diags))
}
plan.PresentTo, diags = types.ListValueFrom(ctx, types.Int64Type, recordDisk.PresentTo)
plan.PresentTo, diags = types.MapValueFrom(ctx, types.Int64Type, recordDisk.PresentTo)
if diags != nil {
tflog.Error(ctx, fmt.Sprint("flattens.DiskResource: cannot flatten recordDisk.PresentTo to plan.PresentTo", diags))
}
@@ -129,7 +135,7 @@ func DiskResource(ctx context.Context, plan *models.ResourceDiskModel, c *client
}
plan.IOTune = obj
tflog.Info(ctx, "flattens.DiskResource: after flatten", map[string]any{"disk_id": plan.Id.ValueString()})
tflog.Info(ctx, "flattens.DiskResource: after flatten", map[string]any{"disk_id": plan.ID.ValueString()})
tflog.Info(ctx, "End flattens.DiskResource")
return nil