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

@@ -62,6 +62,7 @@ func DataSourceImage(ctx context.Context, state *models.RecordImageModel, c *cli
ResID: types.StringValue(image.ResID),
RescueCD: types.BoolValue(image.RescueCD),
SepID: types.Int64Value(int64(image.SepID)),
SnapshotID: types.StringValue(image.SnapshotID),
Size: types.Int64Value(int64(image.Size)),
Status: types.StringValue(image.Status),
TechStatus: types.StringValue(image.TechStatus),
@@ -77,7 +78,7 @@ func DataSourceImage(ctx context.Context, state *models.RecordImageModel, c *cli
if diags != nil {
tflog.Error(ctx, fmt.Sprint("Error flattenDrivers", diags))
}
state.PresentTo, diags = types.ListValueFrom(ctx, types.Int64Type, image.PresentTo)
state.PresentTo, diags = types.MapValueFrom(ctx, types.Int64Type, image.PresentTo)
if diags != nil {
tflog.Error(ctx, fmt.Sprint("Error flattenPresentTo", diags))
}

View File

@@ -71,6 +71,7 @@ func ResourceImage(ctx context.Context, plan *models.ImageResourceModel, c *clie
ResID: types.StringValue(image.ResID),
RescueCD: types.BoolValue(image.RescueCD),
Size: types.Int64Value(int64(image.Size)),
SnapshotID: types.StringValue(image.SnapshotID),
Status: types.StringValue(image.Status),
TechStatus: types.StringValue(image.TechStatus),
Version: types.StringValue(image.Version),
@@ -84,7 +85,7 @@ func ResourceImage(ctx context.Context, plan *models.ImageResourceModel, c *clie
if diags != nil {
tflog.Error(ctx, fmt.Sprint("Error flattenDrivers", diags))
}
plan.PresentTo, diags = types.ListValueFrom(ctx, types.Int64Type, image.PresentTo)
plan.PresentTo, diags = types.MapValueFrom(ctx, types.Int64Type, image.PresentTo)
if diags != nil {
tflog.Error(ctx, fmt.Sprint("Error flattenPresentTo", diags))
}

View File

@@ -2,6 +2,7 @@ package flattens
import (
"context"
"encoding/json"
"fmt"
"strconv"
@@ -30,42 +31,46 @@ func ResourceImageVirtual(ctx context.Context, plan *models.ImageVirtualResource
return diags
}
cdPresentedTo, _ := json.Marshal(image.CdPresentedTo)
*plan = models.ImageVirtualResourceModel{
ImageName: types.StringValue(image.Name),
LinkTo: types.Int64Value(int64(image.LinkTo)),
Timeouts: plan.Timeouts,
Id: types.StringValue(strconv.Itoa(int(image.ID))),
LastUpdated: plan.LastUpdated,
UNCPath: types.StringValue(image.UNCPath),
CKey: types.StringValue(image.CKey),
AccountID: types.Int64Value(int64(image.AccountID)),
Architecture: types.StringValue(image.Architecture),
BootType: types.StringValue(image.BootType),
Bootable: types.BoolValue(image.Bootable),
ComputeCIID: types.Int64Value(int64(image.ComputeCIID)),
DeletedTime: types.Int64Value(int64(image.DeletedTime)),
Description: types.StringValue(image.Description),
Enabled: types.BoolValue(image.Enabled),
GID: types.Int64Value(int64(image.GID)),
GUID: types.Int64Value(int64(image.GUID)),
History: flattenHistoryInResource(ctx, &image.History),
HotResize: types.BoolValue(image.HotResize),
LastModified: types.Int64Value(int64(image.LastModified)),
Milestones: types.Int64Value(int64(image.Milestones)),
ImageId: types.Int64Value(int64(image.ID)),
ImageType: types.StringValue(image.Type),
Password: types.StringValue(image.Password),
PoolName: types.StringValue(image.Pool),
ProviderName: types.StringValue(image.ProviderName),
PurgeAttempts: types.Int64Value(int64(image.PurgeAttempts)),
ResID: types.StringValue(image.ResID),
RescueCD: types.BoolValue(image.RescueCD),
SepID: types.Int64Value(int64(image.SepID)),
Size: types.Int64Value(int64(image.Size)),
Status: types.StringValue(image.Status),
TechStatus: types.StringValue(image.TechStatus),
Username: types.StringValue(image.Username),
Version: types.StringValue(image.Version),
ImageName: types.StringValue(image.Name),
LinkTo: types.Int64Value(int64(image.LinkTo)),
Timeouts: plan.Timeouts,
Id: types.StringValue(strconv.Itoa(int(image.ID))),
LastUpdated: plan.LastUpdated,
UNCPath: types.StringValue(image.UNCPath),
CKey: types.StringValue(image.CKey),
AccountID: types.Int64Value(int64(image.AccountID)),
Architecture: types.StringValue(image.Architecture),
BootType: types.StringValue(image.BootType),
Bootable: types.BoolValue(image.Bootable),
CdPresentedTo: types.StringValue(string(cdPresentedTo)),
ComputeCIID: types.Int64Value(int64(image.ComputeCIID)),
DeletedTime: types.Int64Value(int64(image.DeletedTime)),
Description: types.StringValue(image.Description),
Enabled: types.BoolValue(image.Enabled),
GID: types.Int64Value(int64(image.GID)),
GUID: types.Int64Value(int64(image.GUID)),
History: flattenHistoryInResource(ctx, &image.History),
HotResize: types.BoolValue(image.HotResize),
LastModified: types.Int64Value(int64(image.LastModified)),
Milestones: types.Int64Value(int64(image.Milestones)),
NetworkInterfaceNaming: types.StringValue(image.NetworkInterfaceNaming),
ImageId: types.Int64Value(int64(image.ID)),
ImageType: types.StringValue(image.Type),
Password: types.StringValue(image.Password),
PoolName: types.StringValue(image.Pool),
ProviderName: types.StringValue(image.ProviderName),
PurgeAttempts: types.Int64Value(int64(image.PurgeAttempts)),
ResID: types.StringValue(image.ResID),
RescueCD: types.BoolValue(image.RescueCD),
SepID: types.Int64Value(int64(image.SepID)),
Size: types.Int64Value(int64(image.Size)),
SnapshotID: types.StringValue(image.SnapshotID),
Status: types.StringValue(image.Status),
TechStatus: types.StringValue(image.TechStatus),
Username: types.StringValue(image.Username),
Version: types.StringValue(image.Version),
}
plan.ACL, diags = types.ListValueFrom(ctx, types.StringType, image.ACL)
@@ -76,7 +81,7 @@ func ResourceImageVirtual(ctx context.Context, plan *models.ImageVirtualResource
if diags != nil {
tflog.Error(ctx, fmt.Sprint("Error flattenDrivers", diags))
}
plan.PresentTo, diags = types.ListValueFrom(ctx, types.Int64Type, image.PresentTo)
plan.PresentTo, diags = types.MapValueFrom(ctx, types.Int64Type, image.PresentTo)
if diags != nil {
tflog.Error(ctx, fmt.Sprint("Error flattenPresentTo", diags))
}

View File

@@ -37,12 +37,13 @@ type RecordImageModel struct {
Password types.String `tfsdk:"password"`
NetworkInterfaceNaming types.String `tfsdk:"network_interface_naming"`
PoolName types.String `tfsdk:"pool_name"`
PresentTo types.List `tfsdk:"present_to"`
PresentTo types.Map `tfsdk:"present_to"`
ProviderName types.String `tfsdk:"provider_name"`
PurgeAttempts types.Int64 `tfsdk:"purge_attempts"`
ResID types.String `tfsdk:"res_id"`
RescueCD types.Bool `tfsdk:"rescuecd"`
SepID types.Int64 `tfsdk:"sep_id"`
SnapshotID types.String `tfsdk:"snapshot_id"`
SharedWith types.List `tfsdk:"shared_with"`
Size types.Int64 `tfsdk:"size"`
Status types.String `tfsdk:"status"`

View File

@@ -43,12 +43,13 @@ type ImageResourceModel struct {
LinkTo types.Int64 `tfsdk:"link_to"`
Milestones types.Int64 `tfsdk:"milestones"`
ImageId types.Int64 `tfsdk:"image_id"`
PresentTo types.List `tfsdk:"present_to"`
PresentTo types.Map `tfsdk:"present_to"`
ProviderName types.String `tfsdk:"provider_name"`
PurgeAttempts types.Int64 `tfsdk:"purge_attempts"`
ResID types.String `tfsdk:"res_id"`
RescueCD types.Bool `tfsdk:"rescuecd"`
SharedWith types.List `tfsdk:"shared_with"`
SnapshotID types.String `tfsdk:"snapshot_id"`
Size types.Int64 `tfsdk:"size"`
Status types.String `tfsdk:"status"`
TechStatus types.String `tfsdk:"tech_status"`

View File

@@ -11,42 +11,45 @@ type ImageVirtualResourceModel struct {
LinkTo types.Int64 `tfsdk:"link_to"`
Timeouts timeouts.Value `tfsdk:"timeouts"`
// responce fields
Id types.String `tfsdk:"id"`
LastUpdated types.String `tfsdk:"last_updated"`
UNCPath types.String `tfsdk:"unc_path"`
CKey types.String `tfsdk:"ckey"`
AccountID types.Int64 `tfsdk:"account_id"`
ACL types.List `tfsdk:"acl"`
Architecture types.String `tfsdk:"architecture"`
BootType types.String `tfsdk:"boot_type"`
Bootable types.Bool `tfsdk:"bootable"`
ComputeCIID types.Int64 `tfsdk:"compute_ci_id"`
DeletedTime types.Int64 `tfsdk:"deleted_time"`
Description types.String `tfsdk:"desc"`
Drivers types.List `tfsdk:"drivers"`
Enabled types.Bool `tfsdk:"enabled"`
GID types.Int64 `tfsdk:"gid"`
GUID types.Int64 `tfsdk:"guid"`
History types.List `tfsdk:"history"`
HotResize types.Bool `tfsdk:"hot_resize"`
LastModified types.Int64 `tfsdk:"last_modified"`
Milestones types.Int64 `tfsdk:"milestones"`
ImageId types.Int64 `tfsdk:"image_id"`
ImageType types.String `tfsdk:"image_type"`
Password types.String `tfsdk:"password"`
PoolName types.String `tfsdk:"pool_name"`
PresentTo types.List `tfsdk:"present_to"`
ProviderName types.String `tfsdk:"provider_name"`
PurgeAttempts types.Int64 `tfsdk:"purge_attempts"`
ResID types.String `tfsdk:"res_id"`
RescueCD types.Bool `tfsdk:"rescuecd"`
SepID types.Int64 `tfsdk:"sep_id"`
SharedWith types.List `tfsdk:"shared_with"`
Size types.Int64 `tfsdk:"size"`
Status types.String `tfsdk:"status"`
TechStatus types.String `tfsdk:"tech_status"`
Username types.String `tfsdk:"username"`
Version types.String `tfsdk:"version"`
Id types.String `tfsdk:"id"`
LastUpdated types.String `tfsdk:"last_updated"`
UNCPath types.String `tfsdk:"unc_path"`
CKey types.String `tfsdk:"ckey"`
AccountID types.Int64 `tfsdk:"account_id"`
ACL types.List `tfsdk:"acl"`
Architecture types.String `tfsdk:"architecture"`
BootType types.String `tfsdk:"boot_type"`
Bootable types.Bool `tfsdk:"bootable"`
CdPresentedTo types.String `tfsdk:"cd_presented_to"`
ComputeCIID types.Int64 `tfsdk:"compute_ci_id"`
DeletedTime types.Int64 `tfsdk:"deleted_time"`
Description types.String `tfsdk:"desc"`
Drivers types.List `tfsdk:"drivers"`
Enabled types.Bool `tfsdk:"enabled"`
GID types.Int64 `tfsdk:"gid"`
GUID types.Int64 `tfsdk:"guid"`
History types.List `tfsdk:"history"`
HotResize types.Bool `tfsdk:"hot_resize"`
LastModified types.Int64 `tfsdk:"last_modified"`
Milestones types.Int64 `tfsdk:"milestones"`
ImageId types.Int64 `tfsdk:"image_id"`
ImageType types.String `tfsdk:"image_type"`
NetworkInterfaceNaming types.String `tfsdk:"network_interface_naming"`
Password types.String `tfsdk:"password"`
PoolName types.String `tfsdk:"pool_name"`
PresentTo types.Map `tfsdk:"present_to"`
ProviderName types.String `tfsdk:"provider_name"`
PurgeAttempts types.Int64 `tfsdk:"purge_attempts"`
ResID types.String `tfsdk:"res_id"`
RescueCD types.Bool `tfsdk:"rescuecd"`
SepID types.Int64 `tfsdk:"sep_id"`
SharedWith types.List `tfsdk:"shared_with"`
Size types.Int64 `tfsdk:"size"`
SnapshotID types.String `tfsdk:"snapshot_id"`
Status types.String `tfsdk:"status"`
TechStatus types.String `tfsdk:"tech_status"`
Username types.String `tfsdk:"username"`
Version types.String `tfsdk:"version"`
}
type HistoryInImageVirtualResourceModel struct {

View File

@@ -115,7 +115,7 @@ func MakeSchemaDataSourceImage() map[string]schema.Attribute {
"purge_attempts": schema.Int64Attribute{
Computed: true,
},
"present_to": schema.ListAttribute{
"present_to": schema.MapAttribute{
Computed: true,
ElementType: types.Int64Type,
},
@@ -128,6 +128,9 @@ func MakeSchemaDataSourceImage() map[string]schema.Attribute {
"sep_id": schema.Int64Attribute{
Computed: true,
},
"snapshot_id": schema.StringAttribute{
Computed: true,
},
"shared_with": schema.ListAttribute{
Computed: true,
ElementType: types.Int64Type,

View File

@@ -30,9 +30,9 @@ func MakeSchemaResourceImage() map[string]schema.Attribute {
"image_type": schema.StringAttribute{
Required: true,
Validators: []validator.String{
stringvalidator.OneOf("linux", "windows", "other"),
stringvalidator.OneOf("linux", "windows", "unknown"),
},
Description: "Image type linux, windows or other",
Description: "Image type linux, windows or unknown",
},
"drivers": schema.ListAttribute{
Required: true,
@@ -167,7 +167,7 @@ func MakeSchemaResourceImage() map[string]schema.Attribute {
"purge_attempts": schema.Int64Attribute{
Computed: true,
},
"present_to": schema.ListAttribute{
"present_to": schema.MapAttribute{
Computed: true,
ElementType: types.Int64Type,
},
@@ -184,6 +184,9 @@ func MakeSchemaResourceImage() map[string]schema.Attribute {
"size": schema.Int64Attribute{
Computed: true,
},
"snapshot_id": schema.StringAttribute{
Computed: true,
},
"status": schema.StringAttribute{
Computed: true,
},

View File

@@ -54,6 +54,9 @@ func MakeSchemaResourceImageVirtual() map[string]schema.Attribute {
"compute_ci_id": schema.Int64Attribute{
Computed: true,
},
"cd_presented_to": schema.StringAttribute{
Computed: true,
},
"deleted_time": schema.Int64Attribute{
Computed: true,
},
@@ -98,6 +101,9 @@ func MakeSchemaResourceImageVirtual() map[string]schema.Attribute {
"milestones": schema.Int64Attribute{
Computed: true,
},
"network_interface_naming": schema.StringAttribute{
Computed: true,
},
"image_id": schema.Int64Attribute{
Computed: true,
},
@@ -116,7 +122,7 @@ func MakeSchemaResourceImageVirtual() map[string]schema.Attribute {
"purge_attempts": schema.Int64Attribute{
Computed: true,
},
"present_to": schema.ListAttribute{
"present_to": schema.MapAttribute{
Computed: true,
ElementType: types.Int64Type,
},
@@ -136,6 +142,9 @@ func MakeSchemaResourceImageVirtual() map[string]schema.Attribute {
"size": schema.Int64Attribute{
Computed: true,
},
"snapshot_id": schema.StringAttribute{
Computed: true,
},
"status": schema.StringAttribute{
Computed: true,
},