@@ -73,7 +73,8 @@ func resourceTencentCloudMonitorTmpTkeClusterAgent() *schema.Resource {
7373 Description : "Whether to enable the public network CLB." ,
7474 },
7575 "in_cluster_pod_config" : {
76- Type : schema .TypeMap ,
76+ Type : schema .TypeList ,
77+ MaxItems : 1 ,
7778 Optional : true ,
7879 Description : "Pod configuration for components deployed in the cluster." ,
7980 Elem : & schema.Resource {
@@ -208,35 +209,38 @@ func resourceTencentCloudMonitorTmpTkeClusterAgentCreate(d *schema.ResourceData,
208209 prometheusClusterAgent .EnableExternal = helper .Bool (v .(bool ))
209210 }
210211 if v , ok := dMap ["in_cluster_pod_config" ]; ok {
211- podConfig := v .(map [string ]interface {})
212212 var clusterAgentPodConfig * tke.PrometheusClusterAgentPodConfig
213- if vv , ok := podConfig ["host_net" ]; ok {
214- clusterAgentPodConfig .HostNet = helper .Bool (vv .(bool ))
215- }
216- if vv , ok := podConfig ["node_selector" ]; ok {
217- labelsList := vv .([]interface {})
218- nodeSelectorKV := make ([]* tke.Label , 0 , len (labelsList ))
219- for _ , labels := range labelsList {
220- label := labels .(map [string ]interface {})
221- var kv tke.Label
222- kv .Name = helper .String (label ["name" ].(string ))
223- kv .Value = helper .String (label ["value" ].(string ))
224- nodeSelectorKV = append (nodeSelectorKV , & kv )
213+ if len (v .([]interface {})) > 0 {
214+ podConfig := v .([]interface {})[0 ].(map [string ]interface {})
215+
216+ if vv , ok := podConfig ["host_net" ]; ok {
217+ clusterAgentPodConfig .HostNet = helper .Bool (vv .(bool ))
225218 }
226- clusterAgentPodConfig .NodeSelector = nodeSelectorKV
227- }
228- if vv , ok := podConfig ["tolerations" ]; ok {
229- tolerationList := vv .([]interface {})
230- tolerations := make ([]* tke.Toleration , 0 , len (tolerationList ))
231- for _ , t := range tolerationList {
232- tolerationMap := t .(map [string ]interface {})
233- var toleration tke.Toleration
234- toleration .Key = helper .String (tolerationMap ["key" ].(string ))
235- toleration .Operator = helper .String (tolerationMap ["operator" ].(string ))
236- toleration .Effect = helper .String (tolerationMap ["effect" ].(string ))
237- tolerations = append (tolerations , & toleration )
219+ if vv , ok := podConfig ["node_selector" ]; ok {
220+ labelsList := vv .([]interface {})
221+ nodeSelectorKV := make ([]* tke.Label , 0 , len (labelsList ))
222+ for _ , labels := range labelsList {
223+ label := labels .(map [string ]interface {})
224+ var kv tke.Label
225+ kv .Name = helper .String (label ["name" ].(string ))
226+ kv .Value = helper .String (label ["value" ].(string ))
227+ nodeSelectorKV = append (nodeSelectorKV , & kv )
228+ }
229+ clusterAgentPodConfig .NodeSelector = nodeSelectorKV
230+ }
231+ if vv , ok := podConfig ["tolerations" ]; ok {
232+ tolerationList := vv .([]interface {})
233+ tolerations := make ([]* tke.Toleration , 0 , len (tolerationList ))
234+ for _ , t := range tolerationList {
235+ tolerationMap := t .(map [string ]interface {})
236+ var toleration tke.Toleration
237+ toleration .Key = helper .String (tolerationMap ["key" ].(string ))
238+ toleration .Operator = helper .String (tolerationMap ["operator" ].(string ))
239+ toleration .Effect = helper .String (tolerationMap ["effect" ].(string ))
240+ tolerations = append (tolerations , & toleration )
241+ }
242+ clusterAgentPodConfig .Tolerations = tolerations
238243 }
239- clusterAgentPodConfig .Tolerations = tolerations
240244 }
241245 prometheusClusterAgent .InClusterPodConfig = clusterAgentPodConfig
242246 }
0 commit comments