Skip to content

Commit 968b8d3

Browse files
xiaokouliualantlliu
andauthored
import node (#2246)
Co-authored-by: alantlliu <alantlliu@tencent.com>
1 parent 72d4d41 commit 968b8d3

File tree

5 files changed

+258
-76
lines changed

5 files changed

+258
-76
lines changed

.changelog/2246.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
```release-note:enhancement
2+
resource/tencentcloud_kubernetes_scale_worker: set up the node and import it into Terraform
3+
```
4+
```release-note:bug
5+
resource/tencentcloud_kubernetes_cluster_attachment: fix the null pointer issue in data_disk
6+
```

tencentcloud/resource_tc_kubernetes_cluster.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ func TkeCvmCreateInfo() map[string]*schema.Schema {
924924
Type: schema.TypeString,
925925
Optional: true,
926926
ForceNew: true,
927-
Default: CVM_PREPAID_RENEW_FLAG_NOTIFY_AND_MANUAL_RENEW,
927+
Computed: true,
928928
ValidateFunc: validateAllowedStringValue(CVM_PREPAID_RENEW_FLAG),
929929
Description: "Auto renewal flag. Valid values: `NOTIFY_AND_AUTO_RENEW`: notify upon expiration and renew automatically, `NOTIFY_AND_MANUAL_RENEW`: notify upon expiration but do not renew automatically, `DISABLE_NOTIFY_AND_MANUAL_RENEW`: neither notify upon expiration nor renew automatically. Default value: `NOTIFY_AND_MANUAL_RENEW`. If this parameter is specified as `NOTIFY_AND_AUTO_RENEW`, the instance will be automatically renewed on a monthly basis if the account balance is sufficient. NOTE: it only works when instance_charge_type is set to `PREPAID`.",
930930
},

tencentcloud/resource_tc_kubernetes_cluster_attachment.go

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -355,31 +355,37 @@ func tkeGetInstanceAdvancedPara(dMap map[string]interface{}, meta interface{}) (
355355
}
356356

357357
if v, ok := dMap["data_disk"]; ok {
358-
359358
dataDisks := v.([]interface{})
360-
setting.DataDisks = make([]*tke.DataDisk, 0, len(dataDisks))
361-
362-
for _, d := range dataDisks {
363-
var (
364-
value = d.(map[string]interface{})
365-
diskType = value["disk_type"].(string)
366-
diskSize = int64(value["disk_size"].(int))
367-
fileSystem = value["file_system"].(string)
368-
autoFormatAndMount = value["auto_format_and_mount"].(bool)
369-
mountTarget = value["mount_target"].(string)
370-
diskPartition = value["disk_partition"].(string)
371-
dataDisk = tke.DataDisk{
372-
DiskType: &diskType,
373-
FileSystem: &fileSystem,
374-
AutoFormatAndMount: &autoFormatAndMount,
375-
MountTarget: &mountTarget,
376-
DiskPartition: &diskPartition,
377-
}
378-
)
359+
setting.DataDisks = make([]*tke.DataDisk, len(dataDisks))
360+
for i, d := range dataDisks {
361+
value := d.(map[string]interface{})
362+
var diskType, fileSystem, mountTarget, diskPartition string
363+
if v, ok := value["disk_type"].(string); ok {
364+
diskType = v
365+
}
366+
if v, ok := value["file_system"].(string); ok {
367+
fileSystem = v
368+
}
369+
if v, ok := value["mount_target"].(string); ok {
370+
mountTarget = v
371+
}
372+
if v, ok := value["disk_partition"].(string); ok {
373+
diskPartition = v
374+
}
375+
376+
diskSize := int64(value["disk_size"].(int))
377+
autoFormatAndMount := value["auto_format_and_mount"].(bool)
378+
dataDisk := &tke.DataDisk{
379+
DiskType: &diskType,
380+
FileSystem: &fileSystem,
381+
AutoFormatAndMount: &autoFormatAndMount,
382+
MountTarget: &mountTarget,
383+
DiskPartition: &diskPartition,
384+
}
379385
if diskSize > 0 {
380386
dataDisk.DiskSize = &diskSize
381387
}
382-
setting.DataDisks = append(setting.DataDisks, &dataDisk)
388+
setting.DataDisks[i] = dataDisk
383389
}
384390
}
385391
if v, ok := dMap["is_schedule"]; ok {

0 commit comments

Comments
 (0)