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

@@ -73,6 +73,7 @@ func DataSourceK8s(ctx context.Context, state *models.RecordK8SDataSourceModel,
CreatedTime: types.Int64Value(int64(cluster.CreatedTime)),
DeletedBy: types.StringValue(cluster.DeletedBy),
DeletedTime: types.Int64Value(int64(cluster.DeletedTime)),
Desc: types.StringValue(cluster.Description),
ExtnetOnly: types.BoolValue(cluster.ExtnetOnly),
HighlyAvailableLB: types.BoolValue(cluster.HighlyAvailableLB),
K8CIName: types.StringValue(cluster.K8CIName),

View File

@@ -57,20 +57,20 @@ func K8SCPResource(ctx context.Context, plan *models.ResourceK8SCPModel, c *clie
NetworkPlugin: types.StringValue(cluster.NetworkPlugin),
SEPID: plan.SEPID,
SEPPool: plan.SEPPool,
WithLB: plan.WithLB,
HighlyAvailable: plan.HighlyAvailable,
WithLB: types.BoolValue(cluster.WithLB),
HighlyAvailable: types.BoolValue(cluster.HighlyAvailableLB),
AdditionalSANs: plan.AdditionalSANs,
InitConfiguration: plan.InitConfiguration,
ClusterConfiguration: plan.ClusterConfiguration,
KubeletConfiguration: plan.KubeletConfiguration,
KubeProxyConfiguration: plan.KubeProxyConfiguration,
JoinConfiguration: plan.JoinConfiguration,
Description: plan.Description,
ExtNetOnly: plan.ExtNetOnly,
Description: types.StringValue(cluster.Description),
ExtNetOnly: types.BoolValue(cluster.ExtnetOnly),
OidcCertificate: plan.OidcCertificate,
Chipset: plan.Chipset,
Start: plan.Start,
Enabled: plan.Enabled,
Start: types.BoolValue(cluster.TechStatus == "STARTED"),
Enabled: types.BoolValue(cluster.Status == "ENABLED"),
Permanently: plan.Permanently,
Restore: plan.Restore,
Timeouts: plan.Timeouts,

View File

@@ -49,7 +49,6 @@ func K8SWGResource(ctx context.Context, plan *models.ResourceK8SWGModel, c *clie
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,

View File

@@ -23,6 +23,7 @@ type RecordK8SDataSourceModel struct {
HighlyAvailableLB types.Bool `tfsdk:"ha_mode"`
K8SAddressVIP *K8SAddressVIP `tfsdk:"address_vip"`
DeletedTime types.Int64 `tfsdk:"deleted_time"`
Desc types.String `tfsdk:"desc"`
ExtNetID types.Int64 `tfsdk:"extnet_id"`
K8CIName types.String `tfsdk:"k8sci_name"`
Masters *MasterGroupDataSourceModel `tfsdk:"masters"`

View File

@@ -11,7 +11,6 @@ type ResourceK8SWGModel struct {
K8SID types.Int64 `tfsdk:"k8s_id"`
Name types.String `tfsdk:"name"`
Num types.Int64 `tfsdk:"num"`
WorkerChipset types.String `tfsdk:"worker_chipset"`
CPU types.Int64 `tfsdk:"cpu"`
RAM types.Int64 `tfsdk:"ram"`
Chipset types.String `tfsdk:"chipset"`

View File

@@ -185,7 +185,7 @@ func (r *resourceK8SCP) Update(ctx context.Context, req resource.UpdateRequest,
}
// Update Name or/and Description cluster
if !plan.Name.Equal(state.Name) || !plan.Description.Equal(state.Description) {
if !plan.Name.Equal(state.Name) || (!plan.Description.Equal(state.Description) && !plan.Description.IsNull()) {
resp.Diagnostics.Append(utilities.K8SCPUpdateNameOrDescription(ctx, &plan, &state, r.client)...)
if resp.Diagnostics.HasError() {
tflog.Error(ctx, "Error update info")
@@ -221,7 +221,7 @@ func (r *resourceK8SCP) Update(ctx context.Context, req resource.UpdateRequest,
}
//Update LB params
if (state.WithLB.IsNull() || state.WithLB.ValueBool()) && !plan.LBSysctlParams.Equal(state.LBSysctlParams) {
if state.WithLB.ValueBool() && !plan.LBSysctlParams.Equal(state.LBSysctlParams) && !plan.LBSysctlParams.IsNull() {
resp.Diagnostics.Append(utilities.K8CPUpdateSysctlParams(ctx, &plan, &state, r.client)...)
if resp.Diagnostics.HasError() {
tflog.Error(ctx, "Error Update LB params")

View File

@@ -119,6 +119,9 @@ func MakeSchemaDataSourceK8S() map[string]schema.Attribute {
"deleted_time": schema.Int64Attribute{
Computed: true,
},
"desc": schema.StringAttribute{
Computed: true,
},
"extnet_id": schema.Int64Attribute{
Computed: true,
},

View File

@@ -4,6 +4,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework-validators/int64validator"
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/int64planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
@@ -85,10 +86,14 @@ func MakeSchemaResourceK8SCP() map[string]schema.Attribute {
},
"with_lb": schema.BoolAttribute{
Optional: true,
Computed: true,
Default: booldefault.StaticBool(true),
Description: "Create k8s with load balancer if true.",
},
"ha_mode": schema.BoolAttribute{
Optional: true,
Computed: true,
Default: booldefault.StaticBool(false),
Description: "Use Highly Available schema for LB deploy",
},
"additional_sans": schema.ListAttribute{
@@ -118,10 +123,13 @@ func MakeSchemaResourceK8SCP() map[string]schema.Attribute {
},
"desc": schema.StringAttribute{
Optional: true,
Computed: true,
Description: "Text description of this instance.",
},
"extnet_only": schema.BoolAttribute{
Optional: true,
Computed: true,
Default: booldefault.StaticBool(false),
Description: "Use only selected ExtNet for infrastructure connections",
},
"oidc_cert": schema.StringAttribute{
@@ -152,18 +160,26 @@ func MakeSchemaResourceK8SCP() map[string]schema.Attribute {
// optional attributes for update
"start": schema.BoolAttribute{
Optional: true,
Computed: true,
Default: booldefault.StaticBool(false),
Description: "Start k8s cluster.",
},
"enabled": schema.BoolAttribute{
Optional: true,
Computed: true,
Default: booldefault.StaticBool(true),
Description: "Enable k8s cluster",
},
"permanently": schema.BoolAttribute{
Optional: true,
Computed: true,
Default: booldefault.StaticBool(true),
Description: "whether to completely delete the k8s cluster",
},
"restore": schema.BoolAttribute{
Optional: true,
Computed: true,
Default: booldefault.StaticBool(true),
Description: "if true, restore the k8s cluster from Recycle Bin",
},
// computed attributes

View File

@@ -29,13 +29,6 @@ func MakeSchemaResourceK8SWG() map[string]schema.Attribute {
Computed: true,
Description: "Number of worker nodes to create.",
},
"worker_chipset": schema.StringAttribute{
Optional: true,
Description: "Type of the emulated system of worker nodes",
Validators: []validator.String{
stringvalidator.OneOfCaseInsensitive("Q35", "i440fx"),
},
},
"cpu": schema.Int64Attribute{
Optional: true,
Computed: true,

View File

@@ -219,7 +219,7 @@ func K8SWGUpdateNumWorkers(ctx context.Context, plan, state *models.ResourceK8SW
K8SID: k8sId,
WorkersGroupID: wg.ID,
Num: uint64(newNum) - wg.Num,
Chipset: plan.WorkerChipset.ValueString(),
Chipset: plan.Chipset.ValueString(),
}
tflog.Info(ctx, "Add workers in wg with id", map[string]any{"wg_id": state.WorkerGroupId.ValueInt64(), "k8s_id": state.K8SID.ValueInt64()})