Skip to content

Commit 0f32084

Browse files
authored
fix DescribeClusters return parameter parsing code (#2480)
* fix DescribeClusters return parameter parsing code * add changelog 2480.txt
1 parent 35617d2 commit 0f32084

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

.changelog/2480.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
resource/tencentcloud_kubernetes_scale_worker: fix DescribeClusters return parameter `Property` parsing code
3+
```

tencentcloud/internal/helper/helper.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,9 @@ func MapToString(param map[string]interface{}) (string, bool) {
256256
}
257257

258258
func JsonToMap(str string) (map[string]interface{}, error) {
259+
if str == "" {
260+
return nil, nil
261+
}
259262
var temp map[string]interface{}
260263

261264
err := json.Unmarshal([]byte(str), &temp)

tencentcloud/services/tke/service_tencentcloud_tke.go

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,11 @@ func (me *TkeService) DescribeClusters(ctx context.Context, id string, name stri
377377
errRet = err
378378
return
379379
}
380-
if projectMap["VpcCniType"] != nil {
381-
vpcCniType := projectMap["VpcCniType"].(string)
382-
clusterInfo.VpcCniType = vpcCniType
380+
if projectMap != nil {
381+
if projectMap["VpcCniType"] != nil {
382+
vpcCniType := projectMap["VpcCniType"].(string)
383+
clusterInfo.VpcCniType = vpcCniType
384+
}
383385
}
384386

385387
if len(cluster.TagSpecification) > 0 {
@@ -461,13 +463,15 @@ func (me *TkeService) DescribeCluster(ctx context.Context, id string) (
461463
errRet = err
462464
return
463465
}
464-
if projectMap["VpcCniType"] != nil {
465-
vpcCniType := projectMap["VpcCniType"].(string)
466-
clusterInfo.VpcCniType = vpcCniType
467-
}
468-
if projectMap["NetworkType"] != nil {
469-
networkType := projectMap["NetworkType"].(string)
470-
clusterInfo.NetworkType = networkType
466+
if projectMap != nil {
467+
if projectMap["VpcCniType"] != nil {
468+
vpcCniType := projectMap["VpcCniType"].(string)
469+
clusterInfo.VpcCniType = vpcCniType
470+
}
471+
if projectMap["NetworkType"] != nil {
472+
networkType := projectMap["NetworkType"].(string)
473+
clusterInfo.NetworkType = networkType
474+
}
471475
}
472476

473477
if len(cluster.TagSpecification) > 0 {

0 commit comments

Comments
 (0)