This commit is contained in:
2023-05-26 17:12:03 +03:00
parent 9cf150437d
commit caf7213bca
140 changed files with 1610 additions and 291 deletions

View File

@@ -33,6 +33,8 @@ Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/w
package k8s
import (
"strings"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/k8s"
@@ -168,6 +170,14 @@ func flattenMasterGroup(mastersGroup k8s.MasterGroup, masters []compute.RecordCo
func flattenK8sGroup(k8SGroupList k8s.ListK8SGroups, workers []compute.RecordCompute) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
for _, k8sGroup := range k8SGroupList {
labels := make([]string, 0)
for _, label := range k8sGroup.Labels {
if strings.HasPrefix(label, "workersGroupName") {
continue
}
labels = append(labels, label)
}
temp := map[string]interface{}{
"annotations": k8sGroup.Annotations,
"cpu": k8sGroup.CPU,
@@ -175,7 +185,7 @@ func flattenK8sGroup(k8SGroupList k8s.ListK8SGroups, workers []compute.RecordCom
"disk": k8sGroup.Disk,
"guid": k8sGroup.GUID,
"id": k8sGroup.ID,
"labels": k8sGroup.Labels,
"labels": labels,
"name": k8sGroup.Name,
"num": k8sGroup.Num,
"ram": k8sGroup.RAM,
@@ -323,12 +333,21 @@ func flattenResourceK8s(d *schema.ResourceData, k8s k8s.RecordK8S, masters []com
}
func flattenWg(d *schema.ResourceData, wg k8s.ItemK8SGroup, computes []compute.RecordCompute) {
labels := make([]string, 0)
for _, label := range wg.Labels {
if strings.HasPrefix(label, "workerGroupName") {
continue
}
labels = append(labels, label)
}
d.Set("annotations", wg.Annotations)
d.Set("cpu", wg.CPU)
d.Set("detailed_info", flattenDetailedInfo(wg.DetailedInfo, computes))
d.Set("disk", wg.Disk)
d.Set("guid", wg.GUID)
d.Set("labels", wg.Labels)
d.Set("labels", labels)
d.Set("name", wg.Name)
d.Set("num", wg.Num)
d.Set("ram", wg.RAM)

View File

@@ -32,7 +32,9 @@ Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/w
package k8s
import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func nodeMasterDefault() K8sNodeRecord {
return K8sNodeRecord{

View File

@@ -123,7 +123,9 @@ func resourceK8sCreate(ctx context.Context, d *schema.ResourceData, m interface{
if labels, ok := d.GetOk("labels"); ok {
labels := labels.([]interface{})
for _, label := range labels {
createReq.Labels = append(createReq.Labels, label.(string))
if !strings.HasPrefix(label.(string), "workersGroupName") {
createReq.Labels = append(createReq.Labels, label.(string))
}
}
}

View File

@@ -55,7 +55,7 @@ func resourceK8sWgCreate(ctx context.Context, d *schema.ResourceData, m interfac
}
if !haveK8sID {
return diag.Errorf("resourceK8sCreate: can't create k8s cluster because K8sID %d is not allowed or does not exist", d.Get("k8s_id").(int))
return diag.Errorf("resourceK8sWgCreate: can't create k8s cluster because K8sID %d is not allowed or does not exist", d.Get("k8s_id").(int))
}
c := m.(*controller.ControllerCfg)
@@ -71,7 +71,9 @@ func resourceK8sWgCreate(ctx context.Context, d *schema.ResourceData, m interfac
labels, _ := d.Get("labels").([]interface{})
for _, label := range labels {
req.Labels = append(req.Labels, label.(string))
if !strings.HasPrefix(label.(string), "workersGroupName") {
req.Labels = append(req.Labels, label.(string))
}
}
annotations, _ := d.Get("annotations").([]interface{})
@@ -317,11 +319,11 @@ func ResourceK8sWg() *schema.Resource {
},
Timeouts: &schema.ResourceTimeout{
Create: &constants.Timeout600s,
Read: &constants.Timeout600s,
Update: &constants.Timeout600s,
Delete: &constants.Timeout300s,
Default: &constants.Timeout300s,
Create: &constants.Timeout20m,
Read: &constants.Timeout20m,
Update: &constants.Timeout20m,
Delete: &constants.Timeout20m,
Default: &constants.Timeout20m,
},
Schema: resourceK8sWgSchemaMake(),

View File

@@ -35,6 +35,7 @@ package k8s
import (
"context"
"strconv"
"strings"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
@@ -148,7 +149,9 @@ func addWGs(ctx context.Context, c *controller.ControllerCfg, cluster *k8s.Recor
labels, _ := found_wg["labels"].([]interface{})
for _, label := range labels {
req.Labels = append(req.Labels, label.(string))
if !strings.HasPrefix(label.(string), "workersGroupName") {
req.Labels = append(req.Labels, label.(string))
}
}
annotations, _ := found_wg["annotations"].([]interface{})