@@ -3,7 +3,9 @@ package tke
3
3
import (
4
4
"context"
5
5
"encoding/base64"
6
+ "encoding/json"
6
7
"fmt"
8
+ "log"
7
9
"strings"
8
10
9
11
tke "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke/v20180525"
@@ -13,8 +15,6 @@ import (
13
15
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
14
16
)
15
17
16
- var addonResponseData = & AddonResponseData {}
17
-
18
18
func resourceTencentCloudKubernetesAddonAttachmentCreatePostFillRequest0 (ctx context.Context , req * tke.ForwardApplicationRequestV3Request ) error {
19
19
d := tccommon .ResourceDataFromContext (ctx )
20
20
meta := tccommon .ProviderMetaFromContext (ctx )
@@ -116,7 +116,7 @@ func resourceTencentCloudKubernetesAddonAttachmentReadPreRequest0(ctx context.Co
116
116
clusterName := d .Get ("cluster_id" ).(string )
117
117
addonName := d .Get ("name" ).(string )
118
118
119
- _ , has , err = service .PollingAddonsPhase (ctx , clusterName , addonName , addonResponseData )
119
+ _ , has , err = service .PollingAddonsPhase (ctx , clusterName , addonName , nil )
120
120
121
121
if err != nil || ! has {
122
122
d .SetId ("" )
@@ -133,14 +133,23 @@ func resourceTencentCloudKubernetesAddonAttachmentReadPreRequest0(ctx context.Co
133
133
func resourceTencentCloudKubernetesAddonAttachmentReadPostHandleResponse0 (ctx context.Context , resp * tke.ForwardApplicationRequestV3ResponseParams ) error {
134
134
d := tccommon .ResourceDataFromContext (ctx )
135
135
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
+
136
143
spec := addonResponseData .Spec
137
144
statuses := addonResponseData .Status
138
145
clusterId := d .Get ("cluster_id" ).(string )
146
+ name := d .Get ("name" ).(string )
139
147
140
148
if spec != nil {
141
149
_ = d .Set ("cluster_id" , clusterId )
142
150
_ = d .Set ("name" , spec .Chart .ChartName )
143
151
_ = d .Set ("version" , spec .Chart .ChartVersion )
152
+ log .Printf ("set clusterId:[%v] name:[%s] chartName:[%s]\n " , clusterId , name , * spec .Chart .ChartName )
144
153
if spec .Values != nil && len (spec .Values .Values ) > 0 {
145
154
146
155
// Filter auto-filled values from addon creation
0 commit comments