Skip to content

Commit 466cfef

Browse files
committed
feat(tke): [119910893] support taints for tencentcloud_kubernetes_cluster_attachment
1 parent ede4b59 commit 466cfef

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

tencentcloud/services/tke/resource_tc_kubernetes_cluster_attachment.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,34 @@ func ResourceTencentCloudKubernetesClusterAttachment() *schema.Resource {
165165
ForceNew: true,
166166
Description: "Base64-encoded user script, executed before initializing the node, currently only effective for adding existing nodes.",
167167
},
168+
"taints": {
169+
Type: schema.TypeList,
170+
Optional: true,
171+
ForceNew: true,
172+
Description: "Node taint.",
173+
Elem: &schema.Resource{
174+
Schema: map[string]*schema.Schema{
175+
"key": {
176+
Type: schema.TypeString,
177+
Optional: true,
178+
ForceNew: true,
179+
Description: "Key of the taint.",
180+
},
181+
"value": {
182+
Type: schema.TypeString,
183+
Optional: true,
184+
ForceNew: true,
185+
Description: "Value of the taint.",
186+
},
187+
"effect": {
188+
Type: schema.TypeString,
189+
Optional: true,
190+
ForceNew: true,
191+
Description: "Effect of the taint.",
192+
},
193+
},
194+
},
195+
},
168196
"is_schedule": {
169197
Type: schema.TypeBool,
170198
Optional: true,
@@ -490,6 +518,22 @@ func resourceTencentCloudKubernetesClusterAttachmentCreate(d *schema.ResourceDat
490518
if v, ok := instanceAdvancedSettingsMap["pre_start_user_script"]; ok {
491519
instanceAdvancedSettings.PreStartUserScript = helper.String(v.(string))
492520
}
521+
if v, ok := instanceAdvancedSettingsMap["taints"]; ok {
522+
for _, item := range v.([]interface{}) {
523+
taintsMap := item.(map[string]interface{})
524+
taint := tke.Taint{}
525+
if v, ok := taintsMap["key"]; ok {
526+
taint.Key = helper.String(v.(string))
527+
}
528+
if v, ok := taintsMap["value"]; ok {
529+
taint.Value = helper.String(v.(string))
530+
}
531+
if v, ok := taintsMap["effect"]; ok {
532+
taint.Effect = helper.String(v.(string))
533+
}
534+
instanceAdvancedSettings.Taints = append(instanceAdvancedSettings.Taints, &taint)
535+
}
536+
}
493537
if v, ok := instanceAdvancedSettingsMap["docker_graph_path"]; ok {
494538
instanceAdvancedSettings.DockerGraphPath = helper.String(v.(string))
495539
}

tencentcloud/services/tke/resource_tc_kubernetes_cluster_attachment_extension.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ func resourceTencentCloudKubernetesClusterAttachmentReadRequestOnError2(ctx cont
170170
}
171171

172172
func resourceTencentCloudKubernetesClusterAttachmentReadRequestOnSuccess2(ctx context.Context, resp *tke.Instance) *resource.RetryError {
173+
d := tccommon.ResourceDataFromContext(ctx)
173174
if resp == nil {
174175
return nil
175176
}
@@ -196,6 +197,32 @@ func resourceTencentCloudKubernetesClusterAttachmentReadRequestOnSuccess2(ctx co
196197
))
197198
}
198199

200+
if resp.InstanceAdvancedSettings.Taints != nil {
201+
iAdvanced := resp.InstanceAdvancedSettings
202+
taintsList := make([]map[string]interface{}, 0, len(iAdvanced.Taints))
203+
if iAdvanced.Taints != nil {
204+
for _, taints := range iAdvanced.Taints {
205+
taintsMap := map[string]interface{}{}
206+
207+
if taints.Key != nil {
208+
taintsMap["key"] = taints.Key
209+
}
210+
211+
if taints.Value != nil {
212+
taintsMap["value"] = taints.Value
213+
}
214+
215+
if taints.Effect != nil {
216+
taintsMap["effect"] = taints.Effect
217+
}
218+
219+
taintsList = append(taintsList, taintsMap)
220+
}
221+
222+
_ = d.Set("taints", taintsList)
223+
}
224+
}
225+
199226
return nil
200227
}
201228

0 commit comments

Comments
 (0)