@@ -3,7 +3,9 @@ package tke
33import (
44 "context"
55 "encoding/base64"
6+ "encoding/json"
67 "fmt"
8+ "log"
79 "strings"
810
911 tke "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke/v20180525"
@@ -13,8 +15,6 @@ import (
1315 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1416)
1517
16- var addonResponseData = & AddonResponseData {}
17-
1818func resourceTencentCloudKubernetesAddonAttachmentCreatePostFillRequest0 (ctx context.Context , req * tke.ForwardApplicationRequestV3Request ) error {
1919 d := tccommon .ResourceDataFromContext (ctx )
2020 meta := tccommon .ProviderMetaFromContext (ctx )
@@ -116,7 +116,7 @@ func resourceTencentCloudKubernetesAddonAttachmentReadPreRequest0(ctx context.Co
116116 clusterName := d .Get ("cluster_id" ).(string )
117117 addonName := d .Get ("name" ).(string )
118118
119- _ , has , err = service .PollingAddonsPhase (ctx , clusterName , addonName , addonResponseData )
119+ _ , has , err = service .PollingAddonsPhase (ctx , clusterName , addonName , nil )
120120
121121 if err != nil || ! has {
122122 d .SetId ("" )
@@ -133,14 +133,23 @@ func resourceTencentCloudKubernetesAddonAttachmentReadPreRequest0(ctx context.Co
133133func resourceTencentCloudKubernetesAddonAttachmentReadPostHandleResponse0 (ctx context.Context , resp * tke.ForwardApplicationRequestV3ResponseParams ) error {
134134 d := tccommon .ResourceDataFromContext (ctx )
135135
136+ // get the addonResponseData from respbody of each response rather than from a global attribute
137+ var addonResponseData = & AddonResponseData {}
138+ response := * resp .ResponseBody
139+ if err := json .Unmarshal ([]byte (response ), addonResponseData ); err != nil {
140+ return err
141+ }
142+
136143 spec := addonResponseData .Spec
137144 statuses := addonResponseData .Status
138145 clusterId := d .Get ("cluster_id" ).(string )
146+ name := d .Get ("name" ).(string )
139147
140148 if spec != nil {
141149 _ = d .Set ("cluster_id" , clusterId )
142150 _ = d .Set ("name" , spec .Chart .ChartName )
143151 _ = d .Set ("version" , spec .Chart .ChartVersion )
152+ log .Printf ("set clusterId:[%v] name:[%s] chartName:[%s]\n " , clusterId , name , * spec .Chart .ChartName )
144153 if spec .Values != nil && len (spec .Values .Values ) > 0 {
145154
146155 // Filter auto-filled values from addon creation
0 commit comments