4.6.0
This commit is contained in:
@@ -94,6 +94,11 @@ func dataSourceK8CIListSchemaMake() map[string]*schema.Schema {
|
||||
Default: false,
|
||||
Description: "Include deleted k8cis in result",
|
||||
},
|
||||
"sort_by": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "sort by one of supported fields, format +|-(field)",
|
||||
},
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
|
||||
@@ -179,6 +179,11 @@ func createK8sListSchema() map[string]*schema.Schema {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
},
|
||||
"sort_by": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "sort by one of supported fields, format +|-(field)",
|
||||
},
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
|
||||
@@ -75,8 +75,8 @@ func mastersSchemaMake() map[string]*schema.Schema {
|
||||
masters["num"] = &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
ValidateFunc: validation.IntInSlice([]int{1, 3}),
|
||||
Description: "Number of nodes to create. Can be either 1 or 3",
|
||||
ValidateFunc: validation.IntInSlice([]int{1, 3, 5}),
|
||||
Description: "Number of nodes to create. Can be either 1, 3 or 5",
|
||||
}
|
||||
masters["sep_id"] = &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
@@ -97,8 +97,8 @@ func mastersSchemaMake() map[string]*schema.Schema {
|
||||
Required: true,
|
||||
//ForceNew: 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.",
|
||||
}
|
||||
@@ -125,8 +125,8 @@ func workersSchemaMake() map[string]*schema.Schema {
|
||||
"ram": {
|
||||
Type: schema.TypeInt,
|
||||
ValidateFunc: validation.All(
|
||||
validation.IntAtLeast(constants.MinRamPerCompute),
|
||||
validators.DivisibleBy(constants.RAMDivisibility),
|
||||
validation.IntAtLeast(constants.MIN_RAM_PER_COMPUTE),
|
||||
validators.DivisibleBy(constants.RAM_DIVISIBILITY),
|
||||
),
|
||||
Required: true,
|
||||
},
|
||||
|
||||
@@ -101,7 +101,7 @@ func resourceK8sCreate(ctx context.Context, d *schema.ResourceData, m interface{
|
||||
}
|
||||
createReq.MasterNum = uint(masterNode.Num)
|
||||
createReq.MasterCPU = uint(masterNode.Cpu)
|
||||
createReq.MasterRAM = uint(masterNode.Ram)
|
||||
createReq.MasterRAM = uint64(masterNode.Ram)
|
||||
createReq.MasterDisk = uint(masterNode.Disk)
|
||||
createReq.MasterSEPID = uint64(masterNode.SepID)
|
||||
createReq.MasterSEPPool = masterNode.SepPool
|
||||
@@ -115,7 +115,7 @@ func resourceK8sCreate(ctx context.Context, d *schema.ResourceData, m interface{
|
||||
|
||||
createReq.WorkerNum = uint(workerNode.Num)
|
||||
createReq.WorkerCPU = uint(workerNode.Cpu)
|
||||
createReq.WorkerRAM = uint(workerNode.Ram)
|
||||
createReq.WorkerRAM = uint64(workerNode.Ram)
|
||||
createReq.WorkerDisk = uint(workerNode.Disk)
|
||||
createReq.WorkerSEPID = uint64(workerNode.SepID)
|
||||
createReq.WorkerSEPPool = workerNode.SepPool
|
||||
@@ -183,12 +183,26 @@ func resourceK8sCreate(ctx context.Context, d *schema.ResourceData, m interface{
|
||||
}
|
||||
|
||||
if lbSysctlParams, ok := d.GetOk("lb_sysctl_params"); ok {
|
||||
createReq.LbSysctlParams = lbSysctlParams.(string)
|
||||
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
|
||||
}
|
||||
|
||||
if oidcCertificate, ok := d.GetOk("oidc_cert"); ok {
|
||||
createReq.OidcCertificate = oidcCertificate.(string)
|
||||
}
|
||||
///
|
||||
|
||||
createReq.ExtNetOnly = d.Get("extnet_only").(bool)
|
||||
|
||||
@@ -231,7 +245,11 @@ func resourceK8sCreate(ctx context.Context, d *schema.ResourceData, m interface{
|
||||
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
|
||||
}
|
||||
|
||||
@@ -515,6 +533,31 @@ func resourceK8sUpdate(ctx context.Context, d *schema.ResourceData, m interface{
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("lb_sysctl_params") && d.Get("with_lb").(bool) {
|
||||
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: cluster.LBID,
|
||||
SysctlParams: res,
|
||||
}
|
||||
_, err := c.CloudAPI().LB().UpdateSysctlParams(ctx, req)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
return resourceK8sRead(ctx, d, m)
|
||||
}
|
||||
|
||||
@@ -685,15 +728,22 @@ func resourceK8sSchemaMake() map[string]*schema.Schema {
|
||||
Description: "Use Highly Available schema for LB deploy",
|
||||
},
|
||||
"lb_sysctl_params": {
|
||||
Type: schema.TypeString,
|
||||
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,
|
||||
},
|
||||
},
|
||||
},
|
||||
"oidc_cert": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "insert ssl certificate in x509 pem format",
|
||||
},
|
||||
|
||||
"desc": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
@@ -705,6 +755,7 @@ func resourceK8sSchemaMake() map[string]*schema.Schema {
|
||||
Default: true,
|
||||
Description: "Start k8s cluster",
|
||||
},
|
||||
|
||||
"acl": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
|
||||
@@ -109,7 +109,7 @@ func resourceK8sCPCreate(ctx context.Context, d *schema.ResourceData, m interfac
|
||||
}
|
||||
|
||||
if ram, ok := d.GetOk("ram"); ok {
|
||||
createReq.MasterRAM = uint(ram.(int))
|
||||
createReq.MasterRAM = uint64(ram.(int))
|
||||
} else {
|
||||
createReq.MasterRAM = 2048
|
||||
}
|
||||
@@ -168,7 +168,20 @@ func resourceK8sCPCreate(ctx context.Context, d *schema.ResourceData, m interfac
|
||||
}
|
||||
|
||||
if lbSysctlParams, ok := d.GetOk("lb_sysctl_params"); ok {
|
||||
createReq.LbSysctlParams = lbSysctlParams.(string)
|
||||
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
|
||||
}
|
||||
|
||||
if oidcCertificate, ok := d.GetOk("oidc_cert"); ok {
|
||||
@@ -176,6 +189,8 @@ func resourceK8sCPCreate(ctx context.Context, d *schema.ResourceData, m interfac
|
||||
log.Debug(createReq.OidcCertificate)
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
createReq.ExtNetOnly = d.Get("extnet_only").(bool)
|
||||
|
||||
if extNet, ok := d.GetOk("extnet_id"); ok {
|
||||
@@ -217,7 +232,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
|
||||
}
|
||||
|
||||
@@ -532,6 +551,31 @@ func resourceK8sCPUpdate(ctx context.Context, d *schema.ResourceData, m interfac
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("lb_sysctl_params") && d.Get("with_lb").(bool) {
|
||||
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: cluster.LBID,
|
||||
SysctlParams: res,
|
||||
}
|
||||
_, err := c.CloudAPI().LB().UpdateSysctlParams(ctx, req)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
return resourceK8sCPRead(ctx, d, m)
|
||||
}
|
||||
|
||||
@@ -592,8 +636,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, 3 or 5",
|
||||
},
|
||||
"cpu": {
|
||||
Type: schema.TypeInt,
|
||||
@@ -606,8 +650,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.",
|
||||
},
|
||||
@@ -680,9 +724,15 @@ func resourceK8sCPSchemaMake() map[string]*schema.Schema {
|
||||
Description: "Use Highly Available schema for LB deploy",
|
||||
},
|
||||
"lb_sysctl_params": {
|
||||
Type: schema.TypeString,
|
||||
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,
|
||||
},
|
||||
},
|
||||
},
|
||||
"oidc_cert": {
|
||||
Type: schema.TypeString,
|
||||
@@ -724,6 +774,12 @@ func resourceK8sCPSchemaMake() map[string]*schema.Schema {
|
||||
Computed: true,
|
||||
Description: "Master group name.",
|
||||
},
|
||||
"permanently": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: false,
|
||||
Description: "Determines if cluster should be destroyed",
|
||||
},
|
||||
"acl": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -776,12 +832,6 @@ func resourceK8sCPSchemaMake() map[string]*schema.Schema {
|
||||
Computed: true,
|
||||
Description: "IP address of default load balancer.",
|
||||
},
|
||||
"permanently": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: false,
|
||||
Description: "Determines if cluster should be destroyed",
|
||||
},
|
||||
"rg_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
|
||||
@@ -267,8 +267,8 @@ func resourceK8sWgSchemaMake() map[string]*schema.Schema {
|
||||
//ForceNew: true,
|
||||
Default: 1024,
|
||||
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.",
|
||||
},
|
||||
|
||||
@@ -67,6 +67,9 @@ func utilityK8CIListCheckPresence(ctx context.Context, d *schema.ResourceData, m
|
||||
if include_disabled, ok := d.GetOk("include_disabled"); ok {
|
||||
req.IncludeDisabled = include_disabled.(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))
|
||||
}
|
||||
|
||||
@@ -265,6 +265,10 @@ func utilityK8sListCheckPresence(ctx context.Context, d *schema.ResourceData, m
|
||||
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))
|
||||
}
|
||||
@@ -329,6 +333,10 @@ func utilityK8sListDeletedCheckPresence(ctx context.Context, d *schema.ResourceD
|
||||
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