4.6.0
This commit is contained in:
@@ -166,6 +166,23 @@ func resourceK8sCPCreate(ctx context.Context, d *schema.ResourceData, m interfac
|
||||
createReq.Description = desc.(string)
|
||||
}
|
||||
|
||||
if lbSysctlParams, ok := d.GetOk("lb_sysctl_params"); ok {
|
||||
syscrlSliceMaps := lbSysctlParams.([]map[string]string)
|
||||
res := make([]map[string]interface{}, 0, len(syscrlSliceMaps))
|
||||
for _, syscrlMap := range syscrlSliceMaps {
|
||||
tempMap := make(map[string]interface{})
|
||||
for k, v := range syscrlMap {
|
||||
if intVal, err := strconv.Atoi(v); err == nil {
|
||||
tempMap[k] = intVal
|
||||
continue
|
||||
}
|
||||
tempMap[k] = v
|
||||
}
|
||||
res = append(res, tempMap)
|
||||
}
|
||||
createReq.LbSysctlParams = res
|
||||
}
|
||||
|
||||
resp, err := c.CloudBroker().K8S().Create(ctx, createReq)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
@@ -188,7 +205,11 @@ func resourceK8sCPCreate(ctx context.Context, d *schema.ResourceData, m interfac
|
||||
return diag.FromErr(fmt.Errorf("cannot create k8s instance: %v", task.Error))
|
||||
}
|
||||
|
||||
d.SetId(strconv.Itoa(int(task.Result)))
|
||||
id, err := task.Result.ID()
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
d.SetId(strconv.Itoa(id))
|
||||
break
|
||||
}
|
||||
|
||||
@@ -387,6 +408,13 @@ func resourceK8sCPUpdate(ctx context.Context, d *schema.ResourceData, m interfac
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("lb_sysctl_params") && d.Get("with_lb").(bool) {
|
||||
err := handleUpdateLbSysctlParams(ctx, d, c, k8sData)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -399,7 +427,9 @@ func resourceK8sCPDelete(ctx context.Context, d *schema.ResourceData, m interfac
|
||||
}
|
||||
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := k8s.DeleteRequest{K8SID: k8sData.ID}
|
||||
req := k8s.DeleteRequest{
|
||||
K8SID: k8sData.ID,
|
||||
}
|
||||
|
||||
if val, ok := d.GetOk("permanently"); ok {
|
||||
req.Permanently = val.(bool)
|
||||
@@ -553,3 +583,28 @@ func handleStart(ctx context.Context, c *controller.ControllerCfg, start bool, k
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func handleUpdateLbSysctlParams(ctx context.Context, d *schema.ResourceData, c *controller.ControllerCfg, k8sData *k8s.RecordK8S) error {
|
||||
|
||||
lbSysctlParams := d.Get("lb_sysctl_params").([]map[string]string)
|
||||
res := make([]map[string]interface{}, 0, len(lbSysctlParams))
|
||||
for _, syscrlMap := range lbSysctlParams {
|
||||
tempMap := make(map[string]interface{})
|
||||
for k, v := range syscrlMap {
|
||||
if intVal, err := strconv.Atoi(v); err == nil {
|
||||
tempMap[k] = intVal
|
||||
continue
|
||||
}
|
||||
tempMap[k] = v
|
||||
}
|
||||
res = append(res, tempMap)
|
||||
}
|
||||
|
||||
req := lb.UpdateSysctParamsRequest{
|
||||
LBID: k8sData.LBID,
|
||||
SysctlParams: res,
|
||||
}
|
||||
|
||||
_, err := c.CloudBroker().LB().UpdateSysctlParams(ctx, req)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -115,7 +115,12 @@ func resourceK8sWgCreate(ctx context.Context, d *schema.ResourceData, m interfac
|
||||
if task.Error != "" {
|
||||
return diag.FromErr(fmt.Errorf("cannot create k8sWg instance: %v", task.Error))
|
||||
}
|
||||
d.SetId(fmt.Sprintf("%d#%d", d.Get("k8s_id").(int), int(task.Result)))
|
||||
|
||||
wgId, err := task.Result.ID()
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
d.SetId(fmt.Sprintf("%d#%d", d.Get("k8s_id").(int), wgId))
|
||||
break
|
||||
}
|
||||
|
||||
|
||||
@@ -140,6 +140,11 @@ func dataSourceK8sListDeletedSchemaMake() map[string]*schema.Schema {
|
||||
Optional: true,
|
||||
Description: "Filter by Tech Status",
|
||||
},
|
||||
"sort_by": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "sort by one of supported fields, format +|-(field)",
|
||||
},
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
@@ -228,7 +233,7 @@ func dataSourceK8sListDeletedSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"name": {
|
||||
"k8s_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
@@ -447,6 +452,11 @@ func dataSourceK8sListSchemaMake() map[string]*schema.Schema {
|
||||
Default: false,
|
||||
Description: "Include deleted k8s in result",
|
||||
},
|
||||
"sort_by": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "sort by one of supported fields, format +|-(field)",
|
||||
},
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
@@ -1337,8 +1347,8 @@ func resourceK8sCPSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ValidateFunc: validation.IntInSlice([]int{1, 3}),
|
||||
Description: "Number of VMs to create. Can be either 1 or 3",
|
||||
ValidateFunc: validation.IntInSlice([]int{1, 3, 5}),
|
||||
Description: "Number of VMs to create. Can be either 1 or 3 or 5",
|
||||
},
|
||||
"cpu": {
|
||||
Type: schema.TypeInt,
|
||||
@@ -1351,8 +1361,8 @@ func resourceK8sCPSchemaMake() map[string]*schema.Schema {
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ValidateFunc: validation.All(
|
||||
validation.IntAtLeast(constants.MinRamPerCompute),
|
||||
validators.DivisibleBy(constants.RAMDivisibility),
|
||||
validation.IntAtLeast(constants.MIN_RAM_PER_COMPUTE),
|
||||
validators.DivisibleBy(constants.RAM_DIVISIBILITY),
|
||||
),
|
||||
Description: "Node RAM in MB.",
|
||||
},
|
||||
@@ -1429,6 +1439,17 @@ func resourceK8sCPSchemaMake() map[string]*schema.Schema {
|
||||
Optional: true,
|
||||
Description: "insert ssl certificate in x509 pem format",
|
||||
},
|
||||
"lb_sysctl_params": {
|
||||
Type: schema.TypeList,
|
||||
Optional: true,
|
||||
Description: "Custom sysctl values for Load Balancer instance. Applied on boot.",
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeMap,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
},
|
||||
},
|
||||
"extnet_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
@@ -1743,12 +1764,12 @@ func resourceK8sWgSchemaMake() map[string]*schema.Schema {
|
||||
"ram": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Default: 1024,
|
||||
Computed: true,
|
||||
ValidateFunc: validation.All(
|
||||
validation.IntAtLeast(constants.MinRamPerCompute),
|
||||
validators.DivisibleBy(constants.RAMDivisibility),
|
||||
validation.IntAtLeast(constants.MIN_RAM_PER_COMPUTE),
|
||||
validators.DivisibleBy(constants.RAM_DIVISIBILITY),
|
||||
),
|
||||
Description: "Worker node RAM in MB.",
|
||||
Description: "Node RAM in MB.",
|
||||
},
|
||||
"disk": {
|
||||
Type: schema.TypeInt,
|
||||
|
||||
@@ -70,6 +70,9 @@ func utilityK8sListCheckPresence(ctx context.Context, d *schema.ResourceData, m
|
||||
if includeDeleted, ok := d.GetOk("include_deleted"); ok {
|
||||
req.IncludeDeleted = includeDeleted.(bool)
|
||||
}
|
||||
if sortBy, ok := d.GetOk("sort_by"); ok {
|
||||
req.SortBy = sortBy.(string)
|
||||
}
|
||||
if page, ok := d.GetOk("page"); ok {
|
||||
req.Page = uint64(page.(int))
|
||||
}
|
||||
|
||||
@@ -64,6 +64,9 @@ func utilityK8sListDeletedCheckPresence(ctx context.Context, d *schema.ResourceD
|
||||
if tech_status, ok := d.GetOk("tech_status"); ok {
|
||||
req.TechStatus = tech_status.(string)
|
||||
}
|
||||
if sortBy, ok := d.GetOk("sort_by"); ok {
|
||||
req.SortBy = sortBy.(string)
|
||||
}
|
||||
if page, ok := d.GetOk("page"); ok {
|
||||
req.Page = uint64(page.(int))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user