@@ -130,6 +130,7 @@ package tencentcloud
130130
131131import (
132132 "context"
133+ "encoding/base64"
133134 "fmt"
134135 "strings"
135136
@@ -169,6 +170,21 @@ func resourceTencentCloudTkeAddonAttachment() *schema.Resource {
169170 ConflictsWith : []string {"request_body" },
170171 Elem : & schema.Schema {Type : schema .TypeString },
171172 },
173+ "raw_values" : {
174+ Type : schema .TypeString ,
175+ Optional : true ,
176+ Computed : true ,
177+ Description : "Raw Values. Conflict with `request_body`. Required with `raw_values_type`." ,
178+ ConflictsWith : []string {"request_body" },
179+ RequiredWith : []string {"raw_values_type" },
180+ },
181+ "raw_values_type" : {
182+ Type : schema .TypeString ,
183+ Optional : true ,
184+ Computed : true ,
185+ Description : "The type of raw Values. Required with `raw_values`." ,
186+ RequiredWith : []string {"raw_values" },
187+ },
172188 "request_body" : {
173189 Type : schema .TypeString ,
174190 Optional : true ,
@@ -204,11 +220,13 @@ func resourceTencentCloudTkeAddonAttachmentCreate(d *schema.ResourceData, meta i
204220 ctx := context .WithValue (context .TODO (), logIdKey , logId )
205221
206222 var (
207- clusterId = d .Get ("cluster_id" ).(string )
208- addonName = d .Get ("name" ).(string )
209- version = d .Get ("version" ).(string )
210- values = d .Get ("values" ).([]interface {})
211- reqBody = d .Get ("request_body" ).(string )
223+ clusterId = d .Get ("cluster_id" ).(string )
224+ addonName = d .Get ("name" ).(string )
225+ version = d .Get ("version" ).(string )
226+ values = d .Get ("values" ).([]interface {})
227+ rawValues * string
228+ rawValuesType * string
229+ reqBody = d .Get ("request_body" ).(string )
212230 )
213231
214232 if version == "" {
@@ -227,9 +245,16 @@ func resourceTencentCloudTkeAddonAttachmentCreate(d *schema.ResourceData, meta i
227245 }
228246
229247 if reqBody == "" {
248+ if v , ok := d .GetOk ("raw_values" ); ok {
249+ rawValues = helper .String (v .(string ))
250+ }
251+ if v , ok := d .GetOk ("raw_values_type" ); ok {
252+ rawValuesType = helper .String (v .(string ))
253+ }
254+
230255 var reqErr error
231256 v := helper .InterfacesStringsPoint (values )
232- reqBody , reqErr = service .GetAddonReqBody (addonName , version , v )
257+ reqBody , reqErr = service .GetAddonReqBody (addonName , version , v , rawValues , rawValuesType )
233258 if reqErr != nil {
234259 return reqErr
235260 }
@@ -317,6 +342,17 @@ func resourceTencentCloudTkeAddonAttachmentRead(d *schema.ResourceData, meta int
317342 filteredValues := getFilteredValues (d , spec .Values .Values )
318343 _ = d .Set ("values" , filteredValues )
319344 }
345+
346+ if spec .Values != nil && spec .Values .RawValues != nil {
347+ rawValues := spec .Values .RawValues
348+ rawValuesType := spec .Values .RawValuesType
349+
350+ base64DecodeValues , _ := base64 .StdEncoding .DecodeString (* rawValues )
351+ jsonValues := string (base64DecodeValues )
352+
353+ _ = d .Set ("raw_values" , jsonValues )
354+ _ = d .Set ("raw_values_type" , rawValuesType )
355+ }
320356 }
321357
322358 if statuses != nil || len (statuses ) == 0 {
@@ -339,18 +375,26 @@ func resourceTencentCloudTkeAddonAttachmentUpdate(d *schema.ResourceData, meta i
339375 service := TkeService {client : meta .(* TencentCloudClient ).apiV3Conn }
340376
341377 var (
342- id = d .Id ()
343- split = strings .Split (id , FILED_SP )
344- clusterId = split [0 ]
345- addonName = split [1 ]
346- version = d .Get ("version" ).(string )
347- values = d .Get ("values" ).([]interface {})
348- reqBody = d .Get ("request_body" ).(string )
349- err error
378+ id = d .Id ()
379+ split = strings .Split (id , FILED_SP )
380+ clusterId = split [0 ]
381+ addonName = split [1 ]
382+ version = d .Get ("version" ).(string )
383+ values = d .Get ("values" ).([]interface {})
384+ reqBody = d .Get ("request_body" ).(string )
385+ err error
386+ rawValues * string
387+ rawValuesType * string
350388 )
351389
352- if d .HasChange ("request_body" ) && reqBody == "" || d .HasChange ("version" ) || d .HasChange ("values" ) {
353- reqBody , err = service .GetAddonReqBody (addonName , version , helper .InterfacesStringsPoint (values ))
390+ if d .HasChange ("request_body" ) && reqBody == "" || d .HasChange ("version" ) || d .HasChange ("values" ) || d .HasChange ("raw_values" ) || d .HasChange ("raw_values_type" ) {
391+ if v , ok := d .GetOk ("raw_values" ); ok {
392+ rawValues = helper .String (v .(string ))
393+ }
394+ if v , ok := d .GetOk ("raw_values_type" ); ok {
395+ rawValuesType = helper .String (v .(string ))
396+ }
397+ reqBody , err = service .GetAddonReqBody (addonName , version , helper .InterfacesStringsPoint (values ), rawValues , rawValuesType )
354398 }
355399
356400 if err != nil {
0 commit comments