This commit is contained in:
2023-05-19 17:14:55 +03:00
parent 8ca233dd32
commit 523d96189f
10 changed files with 77 additions and 69 deletions

View File

@@ -217,7 +217,7 @@ func resourceK8sRead(ctx context.Context, d *schema.ResourceData, m interface{})
return diag.FromErr(err)
}
enableReq := k8s.DisabelEnableRequest{
enableReq := k8s.DisableEnableRequest{
K8SID: id,
}
@@ -374,7 +374,7 @@ func resourceK8sUpdate(ctx context.Context, d *schema.ResourceData, m interface{
return diag.FromErr(err)
}
enableReq := k8s.DisabelEnableRequest{
enableReq := k8s.DisableEnableRequest{
K8SID: id,
}

View File

@@ -60,11 +60,28 @@ func resourceK8sWgCreate(ctx context.Context, d *schema.ResourceData, m interfac
c := m.(*controller.ControllerCfg)
req := k8s.WorkersGroupAddRequest{
K8SID: uint64(d.Get("k8s_id").(int)),
Name: d.Get("name").(string),
WorkerNum: uint64(d.Get("num").(int)),
WorkerCPU: uint64(d.Get("cpu").(int)),
WorkerRAM: uint64(d.Get("ram").(int)),
K8SID: uint64(d.Get("k8s_id").(int)),
Name: d.Get("name").(string),
WorkerNum: uint64(d.Get("num").(int)),
WorkerCPU: uint64(d.Get("cpu").(int)),
WorkerRAM: uint64(d.Get("ram").(int)),
WorkerSEPID: uint64(d.Get("worker_sep_id").(int)),
WorkerSEPPool: d.Get("worker_sep_pool").(string),
}
labels, _ := d.Get("labels").([]interface{})
for _, label := range labels {
req.Labels = append(req.Labels, label.(string))
}
annotations, _ := d.Get("annotations").([]interface{})
for _, annotation := range annotations {
req.Annotations = append(req.Annotations, annotation.(string))
}
taints, _ := d.Get("taints").([]interface{})
for _, taint := range taints {
req.Taints = append(req.Taints, taint.(string))
}
if d.Get("disk") == nil {
@@ -111,6 +128,7 @@ func resourceK8sWgRead(ctx context.Context, d *schema.ResourceData, m interface{
} else {
d.Set("k8s_id", d.Get("k8s_id"))
}
d.SetId(strings.Split(d.Id(), "#")[0])
flattenWg(d, *wg, workersComputeList)
@@ -234,6 +252,38 @@ func resourceK8sWgSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "Worker node boot disk size. If unspecified or 0, size is defined by OS image size.",
},
"labels": {
Type: schema.TypeList,
Computed: true,
Optional: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"annotations": {
Type: schema.TypeList,
Computed: true,
Optional: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"taints": {
Type: schema.TypeList,
Computed: true,
Optional: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"worker_sep_id": {
Type: schema.TypeInt,
Optional: true,
},
"worker_sep_pool": {
Type: schema.TypeString,
Optional: true,
},
"wg_id": {
Type: schema.TypeInt,
Computed: true,
@@ -246,31 +296,10 @@ func resourceK8sWgSchemaMake() map[string]*schema.Schema {
Schema: detailedInfoSchemaMake(),
},
},
"labels": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"guid": {
Type: schema.TypeString,
Computed: true,
},
"annotations": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"taints": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
}
}
@@ -289,8 +318,8 @@ func ResourceK8sWg() *schema.Resource {
Timeouts: &schema.ResourceTimeout{
Create: &constants.Timeout600s,
Read: &constants.Timeout300s,
Update: &constants.Timeout300s,
Read: &constants.Timeout600s,
Update: &constants.Timeout600s,
Delete: &constants.Timeout300s,
Default: &constants.Timeout300s,
},

View File

@@ -373,7 +373,7 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
req := compute.PFWAddRequest{
ComputeID: computeId,
PublicPortStart: uint64(pfwItem["public_port_start"].(int)),
PublicPortEnd: uint64(pfwItem["public_port_end"].(int)),
PublicPortEnd: int64(pfwItem["public_port_end"].(int)),
LocalBasePort: uint64(pfwItem["local_port"].(int)),
Proto: pfwItem["proto"].(string),
}
@@ -630,6 +630,8 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
Force: true,
}
warnings := dc.Warnings{}
oldCpu, newCpu := d.GetChange("cpu")
if oldCpu.(int) != newCpu.(int) {
resizeReq.CPU = uint64(newCpu.(int))
@@ -1059,7 +1061,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
_, err := c.CloudAPI().Compute().PFWDel(ctx, req)
if err != nil {
return diag.FromErr(err)
warnings.Add(err)
}
}
}
@@ -1071,7 +1073,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
req := compute.PFWAddRequest{
ComputeID: computeRec.ID,
PublicPortStart: uint64(pfwItem["public_port_start"].(int)),
PublicPortEnd: uint64(pfwItem["public_port_end"].(int)),
PublicPortEnd: int64(pfwItem["public_port_end"].(int)),
LocalBasePort: uint64(pfwItem["local_port"].(int)),
Proto: pfwItem["proto"].(string),
}
@@ -1311,7 +1313,8 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
// we may reuse dataSourceComputeRead here as we maintain similarity
// between Compute resource and Compute data source schemas
return resourceComputeRead(ctx, d, m)
defer resourceComputeRead(ctx, d, m)
return warnings.Get()
}
func isChangeDisk(els []interface{}, el interface{}) bool {
@@ -1696,6 +1699,7 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
"network": {
Type: schema.TypeSet,
Computed: true,
Optional: true,
MinItems: 1,
MaxItems: constants.MaxNetworksPerCompute,

View File

@@ -57,7 +57,7 @@ func resourcePfwCreate(ctx context.Context, d *schema.ResourceData, m interface{
}
if portEnd, ok := d.GetOk("public_port_end"); ok {
req.PublicPortEnd = uint64(portEnd.(int))
req.PublicPortEnd = int64(portEnd.(int))
}
pfwId, err := c.CloudAPI().Compute().PFWAdd(ctx, req)