@@ -10,11 +10,11 @@ resource "tencentcloud_ckafka_topic" "foo" {
1010 note = "topic note"
1111 replica_num = 2
1212 partition_num = 1
13- enable_white_list = 1
14- ip_white_list = ["ip1","ip2"]
13+ enable_white_list = true
14+ ip_white_list = ["ip1","ip2"]
1515 clean_up_policy = "delete"
1616 sync_replica_min_num = 1
17- unclean_leader_election_enable = false
17+ unclean_leader_election_enable = false
1818 segment = 3600000
1919 retention = 60000
2020 max_message_bytes = 0
@@ -33,7 +33,7 @@ import (
3333
3434func dataSourceTencentCloudCkafkaTopics () * schema.Resource {
3535 return & schema.Resource {
36- Read : dataSourceTencentCloudCkafkaTopicRead ,
36+ Read : dataSourceTencentCloudCkafkaTopicsRead ,
3737
3838 Schema : map [string ]* schema.Schema {
3939 "instance_id" : {
@@ -52,7 +52,6 @@ func dataSourceTencentCloudCkafkaTopics() *schema.Resource {
5252 Optional : true ,
5353 Description : "Used to store results." ,
5454 },
55- // computed
5655 "instance_list" : {
5756 Type : schema .TypeList ,
5857 Computed : true ,
@@ -82,17 +81,17 @@ func dataSourceTencentCloudCkafkaTopics() *schema.Resource {
8281 "note" : {
8382 Type : schema .TypeString ,
8483 Computed : true ,
85- Description : "Topic note description." ,
84+ Description : "CKafka topic note description." ,
8685 },
8786 "create_time" : {
8887 Type : schema .TypeString ,
8988 Computed : true ,
90- Description : "Create time of the topic instance ." ,
89+ Description : "Create time of the CKafka topic ." ,
9190 },
9291 "enable_white_list" : {
9392 Type : schema .TypeBool ,
9493 Computed : true ,
95- Description : "IP Whitelist switch, 1 : open; 0 : close." ,
94+ Description : "Whether to open the IP Whitelist, true : open, false : close." ,
9695 },
9796 "ip_white_list_count" : {
9897 Type : schema .TypeInt ,
@@ -112,7 +111,7 @@ func dataSourceTencentCloudCkafkaTopics() *schema.Resource {
112111 "forward_status" : {
113112 Type : schema .TypeInt ,
114113 Computed : true ,
115- Description : "Data backup cos status: 1 do not open data backup, 0 open data backup." ,
114+ Description : "Data backup cos status. 1: do not open data backup, 0: open data backup." ,
116115 },
117116 "retention" : {
118117 Type : schema .TypeInt ,
@@ -127,12 +126,12 @@ func dataSourceTencentCloudCkafkaTopics() *schema.Resource {
127126 "clean_up_policy" : {
128127 Type : schema .TypeString ,
129128 Computed : true ,
130- Description : "Clear log policy, log clear mode. delete: logs are deleted according to the storage time, compact: logs are compressed according to the key, compact, delete: logs are compressed according to the key and will be deleted according to the storage time." ,
129+ Description : "Clear log policy, log clear mode. ` delete` : logs are deleted according to the storage time, ` compact` : logs are compressed according to the key, ` compact, delete` : logs are compressed according to the key and will be deleted according to the storage time." ,
131130 },
132131 "unclean_leader_election_enable" : {
133132 Type : schema .TypeBool ,
134133 Computed : true ,
135- Description : "Whether to allow unsynchronized replicas to be selected as leader, false: not allowed, true: allowed, not allowed by default ." ,
134+ Description : "Whether to allow unsynchronized replicas to be selected as leader, default is `false`, ` true: ` allowed, `false`: not allowed." ,
136135 },
137136 "max_message_bytes" : {
138137 Type : schema .TypeInt ,
@@ -156,19 +155,13 @@ func dataSourceTencentCloudCkafkaTopics() *schema.Resource {
156155 }
157156}
158157
159- func dataSourceTencentCloudCkafkaTopicRead (d * schema.ResourceData , meta interface {}) error {
160- defer logElapsed ("data_source.tencentcloud_ckafka_topic .read" )()
158+ func dataSourceTencentCloudCkafkaTopicsRead (d * schema.ResourceData , meta interface {}) error {
159+ defer logElapsed ("data_source.tencentcloud_ckafka_topics .read" )()
161160
162161 logId := getLogId (contextNil )
163162 ctx := context .WithValue (context .TODO (), logIdKey , logId )
164-
165- var instanceId , topicName string
166- if v , ok := d .GetOk ("instance_id" ); ok {
167- instanceId = v .(string )
168- }
169- if v , ok := d .GetOk ("topic_name" ); ok {
170- topicName = v .(string )
171- }
163+ instanceId := d .Get ("instance_id" ).(string )
164+ topicName := d .Get ("topic_name" ).(string )
172165 ckafkcService := CkafkaService {
173166 client : meta .(* TencentCloudClient ).apiV3Conn ,
174167 }
@@ -181,9 +174,9 @@ func dataSourceTencentCloudCkafkaTopicRead(d *schema.ResourceData, meta interfac
181174 ids := make ([]string , 0 , len (topicDetails ))
182175
183176 for _ , topic := range topicDetails {
184- uncleanLeaderElectionEnable := false
185- if * topic .Config .UncleanLeaderElectionEnable == int64 ( 1 ) {
186- uncleanLeaderElectionEnable = true
177+ var uncleanLeaderElectionEnable bool
178+ if topic .Config .UncleanLeaderElectionEnable != nil {
179+ uncleanLeaderElectionEnable = * topic . Config . UncleanLeaderElectionEnable == 1
187180 }
188181 instance := map [string ]interface {}{
189182 "topic_name" : topic .TopicName ,
@@ -212,7 +205,7 @@ func dataSourceTencentCloudCkafkaTopicRead(d *schema.ResourceData, meta interfac
212205
213206 d .SetId (helper .DataResourceIdsHash (ids ))
214207 if err = d .Set ("instance_list" , instanceList ); err != nil {
215- log .Printf ("[CRITAL]%s provider set ckafka topic instance list fail, reason:%s\n " , logId , err .Error ())
208+ log .Printf ("[CRITAL]%s provider set ckafka topic list fail, reason:%s\n " , logId , err .Error ())
216209 return err
217210 }
218211
0 commit comments