This commit is contained in:
asteam
2024-12-04 13:18:58 +03:00
parent 003e4d656e
commit 76ea459b3d
417 changed files with 30051 additions and 975 deletions

View File

@@ -60,31 +60,34 @@ func DataSourceK8s(ctx context.Context, state *models.RecordK8SDataSourceModel,
id := uuid.New()
*state = models.RecordK8SDataSourceModel{
K8SID: state.K8SID,
Timeouts: state.Timeouts,
Id: types.StringValue(id.String()),
ACL: flattenACLDataSource(ctx, &cluster.ACL),
AccountID: types.Int64Value(int64(cluster.AccountID)),
AccountName: types.StringValue(cluster.AccountName),
BServiceID: types.Int64Value(int64(cluster.BServiceID)),
K8CI: types.Int64Value(int64(cluster.CIID)),
CreatedBy: types.StringValue(cluster.CreatedBy),
CreatedTime: types.Int64Value(int64(cluster.CreatedTime)),
DeletedBy: types.StringValue(cluster.DeletedBy),
DeletedTime: types.Int64Value(int64(cluster.DeletedTime)),
K8CIName: types.StringValue(cluster.K8CIName),
Masters: flattenMasterGroup(ctx, &cluster.K8SGroups.Masters, masterComputeList),
Workers: flattenK8sGroup(ctx, &cluster.K8SGroups.Workers, workersComputeList),
LBID: types.Int64Value(int64(cluster.LBID)),
Name: types.StringValue(cluster.Name),
NetworkPlugin: types.StringValue(cluster.NetworkPlugin),
RGID: types.Int64Value(int64(cluster.RGID)),
RGName: types.StringValue(cluster.RGName),
Status: types.StringValue(cluster.Status),
TechStatus: types.StringValue(cluster.TechStatus),
UpdatedBy: types.StringValue(cluster.UpdatedBy),
UpdatedTime: types.Int64Value(int64(cluster.UpdatedTime)),
VinsId: types.Int64Value(int64(k8sList.Data[0].VINSID)),
K8SID: state.K8SID,
Timeouts: state.Timeouts,
Id: types.StringValue(id.String()),
ACL: flattenACLDataSource(ctx, &cluster.ACL),
AccountID: types.Int64Value(int64(cluster.AccountID)),
AccountName: types.StringValue(cluster.AccountName),
K8SAddressVIP: flattenAddressVIP(ctx, cluster.AddressVIP),
BServiceID: types.Int64Value(int64(cluster.BServiceID)),
K8CI: types.Int64Value(int64(cluster.CIID)),
CreatedBy: types.StringValue(cluster.CreatedBy),
CreatedTime: types.Int64Value(int64(cluster.CreatedTime)),
DeletedBy: types.StringValue(cluster.DeletedBy),
DeletedTime: types.Int64Value(int64(cluster.DeletedTime)),
ExtnetOnly: types.BoolValue(cluster.ExtnetOnly),
HighlyAvailableLB: types.BoolValue(cluster.HighlyAvailableLB),
K8CIName: types.StringValue(cluster.K8CIName),
Masters: flattenMasterGroup(ctx, &cluster.K8SGroups.Masters, masterComputeList),
Workers: flattenK8sGroup(ctx, &cluster.K8SGroups.Workers, workersComputeList),
LBID: types.Int64Value(int64(cluster.LBID)),
Name: types.StringValue(cluster.Name),
NetworkPlugin: types.StringValue(cluster.NetworkPlugin),
RGID: types.Int64Value(int64(cluster.RGID)),
RGName: types.StringValue(cluster.RGName),
Status: types.StringValue(cluster.Status),
TechStatus: types.StringValue(cluster.TechStatus),
UpdatedBy: types.StringValue(cluster.UpdatedBy),
UpdatedTime: types.Int64Value(int64(cluster.UpdatedTime)),
VinsId: types.Int64Value(int64(k8sList.Data[0].VINSID)),
}
if cluster.LBID != 0 {
@@ -106,6 +109,18 @@ func DataSourceK8s(ctx context.Context, state *models.RecordK8SDataSourceModel,
return nil
}
func flattenAddressVIP(ctx context.Context, addressedVip k8s.K8SAddressVIP) *models.K8SAddressVIP {
tflog.Info(ctx, "Start flattenAddressVIP")
res := models.K8SAddressVIP{
BackendIP: types.StringValue(addressedVip.BackendIP),
FrontendIP: types.StringValue(addressedVip.FrontendIP),
}
tflog.Info(ctx, "End flattenAddressVIP")
return &res
}
func flattenMasterGroup(ctx context.Context, mastersGroup *k8s.MasterGroup, masters []*compute.RecordCompute) *models.MasterGroupDataSourceModel {
tflog.Info(ctx, "Start flattenMasterGroup")

View File

@@ -7,6 +7,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
@@ -67,6 +68,7 @@ func K8SCPResource(ctx context.Context, plan *models.ResourceK8SCPModel, c *deco
Description: plan.Description,
ExtNetOnly: plan.ExtNetOnly,
OidcCertificate: plan.OidcCertificate,
Chipset: plan.Chipset,
Start: plan.Start,
Enabled: plan.Enabled,
Permanently: plan.Permanently,
@@ -90,6 +92,7 @@ func K8SCPResource(ctx context.Context, plan *models.ResourceK8SCPModel, c *deco
CreatedTime: types.Int64Value(int64(cluster.CreatedTime)),
DeletedBy: types.StringValue(cluster.DeletedBy),
DeletedTime: types.Int64Value(int64(cluster.DeletedTime)),
K8SAddressVIP: flattenK8SAddressVIP(ctx, cluster.AddressVIP),
K8SID: types.Int64Value(int64(cluster.ID)),
K8CIName: types.StringValue(cluster.K8CIName),
LBID: types.Int64Value(int64(cluster.LBID)),
@@ -126,6 +129,23 @@ func K8SCPResource(ctx context.Context, plan *models.ResourceK8SCPModel, c *deco
return nil
}
func flattenK8SAddressVIP(ctx context.Context, addressedVip k8s.K8SAddressVIP) basetypes.ObjectValue {
tflog.Info(ctx, "Start flattenAddressVIP")
temp := models.AddressVIPModel{
BackendIP: types.StringValue(addressedVip.BackendIP),
FrontendIP: types.StringValue(addressedVip.FrontendIP),
}
res, err := types.ObjectValueFrom(ctx, models.AddressVIP, temp)
if err != nil {
tflog.Error(ctx, fmt.Sprint("Error flattenK8SAddressVIP struct to obj", err))
}
tflog.Info(ctx, "End flattenAddressVIP")
return res
}
func flattenDetailedInfo(ctx context.Context, di *k8s.ListDetailedInfo, computes []*compute.RecordCompute) types.List {
tflog.Info(ctx, "Start flattenDetailedInfo")

View File

@@ -48,6 +48,8 @@ func K8SWGResource(ctx context.Context, plan *models.ResourceK8SWGModel, c *deco
WorkerSEPPool: plan.WorkerSEPPool,
CloudInit: plan.CloudInit,
Timeouts: plan.Timeouts,
Chipset: plan.Chipset,
WorkerChipset: plan.WorkerChipset,
Id: types.StringValue(strconv.Itoa(int(wg.ID))),
WorkerGroupId: types.Int64Value(int64(wg.ID)),
LastUpdated: plan.LastUpdated,