Skip to content

Commit 67b8397

Browse files
authored
fix(tke): [127075624] tencentcloud_kubernetes_cluster optmize code logic (#3511)
* add * add
1 parent f3fcf0d commit 67b8397

File tree

3 files changed

+27
-16
lines changed

3 files changed

+27
-16
lines changed

.changelog/3511.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
resource/tencentcloud_kubernetes_cluster: optmize code logic
3+
```

tencentcloud/services/tke/resource_tc_kubernetes_cluster.go

Lines changed: 9 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tencentcloud/services/tke/resource_tc_kubernetes_cluster_extension.go

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1805,8 +1805,9 @@ func tkeGetCvmRunInstancesPara(dMap map[string]interface{}, meta interface{},
18051805
if len(keyIds) != 0 {
18061806
request.LoginSettings.KeyIds = make([]*string, 0, len(keyIds))
18071807
for i := range keyIds {
1808-
keyId := keyIds[i].(string)
1809-
request.LoginSettings.KeyIds = append(request.LoginSettings.KeyIds, &keyId)
1808+
if keyId, ok := keyIds[i].(string); ok && keyId != "" {
1809+
request.LoginSettings.KeyIds = append(request.LoginSettings.KeyIds, &keyId)
1810+
}
18101811
}
18111812
}
18121813
}
@@ -1825,17 +1826,19 @@ func tkeGetCvmRunInstancesPara(dMap map[string]interface{}, meta interface{},
18251826
securityGroups := v.([]interface{})
18261827
request.SecurityGroupIds = make([]*string, 0, len(securityGroups))
18271828
for i := range securityGroups {
1828-
securityGroup := securityGroups[i].(string)
1829-
request.SecurityGroupIds = append(request.SecurityGroupIds, &securityGroup)
1829+
if securityGroup, ok := securityGroups[i].(string); ok && securityGroup != "" {
1830+
request.SecurityGroupIds = append(request.SecurityGroupIds, &securityGroup)
1831+
}
18301832
}
18311833
}
18321834

18331835
if v, ok := dMap["disaster_recover_group_ids"]; ok {
18341836
disasterGroups := v.([]interface{})
18351837
request.DisasterRecoverGroupIds = make([]*string, 0, len(disasterGroups))
18361838
for i := range disasterGroups {
1837-
disasterGroup := disasterGroups[i].(string)
1838-
request.DisasterRecoverGroupIds = append(request.DisasterRecoverGroupIds, &disasterGroup)
1839+
if disasterGroup, ok := disasterGroups[i].(string); ok && disasterGroup != "" {
1840+
request.DisasterRecoverGroupIds = append(request.DisasterRecoverGroupIds, &disasterGroup)
1841+
}
18391842
}
18401843
}
18411844

@@ -1960,8 +1963,9 @@ func tkeGetCvmExistInstancesPara(dMap map[string]interface{}) (tke.ExistedInstan
19601963
sgIds := v.([]interface{})
19611964
inst.ExistedInstancesPara.SecurityGroupIds = make([]*string, 0, len(sgIds))
19621965
for i := range sgIds {
1963-
sgId := sgIds[i].(string)
1964-
inst.ExistedInstancesPara.SecurityGroupIds = append(inst.ExistedInstancesPara.SecurityGroupIds, &sgId)
1966+
if sgId, ok := sgIds[i].(string); ok && sgId != "" {
1967+
inst.ExistedInstancesPara.SecurityGroupIds = append(inst.ExistedInstancesPara.SecurityGroupIds, &sgId)
1968+
}
19651969
}
19661970
}
19671971

@@ -1974,8 +1978,9 @@ func tkeGetCvmExistInstancesPara(dMap map[string]interface{}) (tke.ExistedInstan
19741978
keyIds := v.([]interface{})
19751979
loginSettings.KeyIds = make([]*string, 0, len(keyIds))
19761980
for i := range keyIds {
1977-
keyId := keyIds[i].(string)
1978-
loginSettings.KeyIds = append(loginSettings.KeyIds, &keyId)
1981+
if keyId, ok := keyIds[i].(string); ok && keyId != "" {
1982+
loginSettings.KeyIds = append(loginSettings.KeyIds, &keyId)
1983+
}
19791984
}
19801985

19811986
inst.ExistedInstancesPara.LoginSettings = loginSettings

0 commit comments

Comments
 (0)