Skip to content

Commit 68714d7

Browse files
authored
fix(tke): [119316597] tencentcloud_kubernetes_addon_attachment support multiple resources scenario (#2797)
* get the addonResponseData from respbody of each response * add changelog
1 parent a3b494b commit 68714d7

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

.changelog/2797.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_addon_attachment: support multiple resources scenario.
3+
```

tencentcloud/services/tke/resource_tc_kubernetes_addon_attachment_extension.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ package tke
33
import (
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-
1818
func 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
133133
func 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

Comments
 (0)