Skip to content

Commit 9216eab

Browse files
tongyimingmikatong
and
mikatong
authored
update (#3168)
Co-authored-by: mikatong <[email protected]>
1 parent f190f42 commit 9216eab

File tree

4 files changed

+64
-12
lines changed

4 files changed

+64
-12
lines changed

schema/filter.json

+8-9
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,20 @@
5252
"required": true,
5353
"description": "域名."
5454
},
55-
"sub_domain": {
56-
"type": "string",
55+
"sub_domains": {
56+
"type": "set_string",
5757
"metadata": {
58-
"filter": {
59-
"enable": true
60-
},
61-
"widget": "text",
58+
"widget": "textarea",
6259
"val_source": {
6360
"values": {}
6461
},
65-
"description": "主机记录, 默认值为 @.",
66-
"display_name": "主机记录"
62+
"display_name": "主机记录",
63+
"delimiter": "[\\s\n,;]",
64+
"help": "多个描述以英文逗号、英文分号、空格或换行分割,最多10个,重复将去重",
65+
"description": "主机记录列表, 默认值为 @."
6766
},
6867
"optional": true,
69-
"description": "主机记录, 默认值为 @."
68+
"description": "主机记录列表, 默认值为 @."
7069
},
7170
"is_exact_sub_domain": {
7271
"type": "bool",

tencentcloud/services/dnspod/data_source_tc_dnspod_record_list.go

+30-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package dnspod
22

33
import (
44
"context"
5+
"fmt"
56

67
tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common"
78

@@ -488,8 +489,7 @@ func dataSourceTencentCloudDnspodRecordListRead(d *schema.ResourceData, meta int
488489

489490
var recordList []*dnspod.RecordListItem
490491

491-
for _, subDomain := range subDomains {
492-
paramMap["SubDomain"] = helper.String(subDomain)
492+
if len(subDomains) == 0 {
493493
err := resource.Retry(tccommon.ReadRetryTimeout, func() *resource.RetryError {
494494
result, e := service.DescribeDnspodRecordListByFilter(ctx, paramMap)
495495
if e != nil {
@@ -501,6 +501,34 @@ func dataSourceTencentCloudDnspodRecordListRead(d *schema.ResourceData, meta int
501501
if err != nil {
502502
return err
503503
}
504+
} else {
505+
recordIds := map[uint64]struct{}{}
506+
507+
for _, subDomain := range subDomains {
508+
paramMap["SubDomain"] = helper.String(subDomain)
509+
err := resource.Retry(tccommon.ReadRetryTimeout, func() *resource.RetryError {
510+
result, e := service.DescribeDnspodRecordListByFilter(ctx, paramMap)
511+
if e != nil {
512+
return tccommon.RetryError(e)
513+
}
514+
for _, resultItem := range result {
515+
if resultItem.RecordId == nil {
516+
return resource.NonRetryableError(fmt.Errorf("record id is nil"))
517+
}
518+
if _, ok := recordIds[*resultItem.RecordId]; ok {
519+
continue
520+
} else {
521+
recordIds[*resultItem.RecordId] = struct{}{}
522+
recordList = append(recordList, resultItem)
523+
}
524+
}
525+
526+
return nil
527+
})
528+
if err != nil {
529+
return err
530+
}
531+
}
504532
}
505533

506534
ids := make([]string, 0, len(recordList))

tencentcloud/services/dnspod/data_source_tc_dnspod_record_list_test.go

+25
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,24 @@ func TestAccTencentCloudDnspodRecordListDataSource_subDomains(t *testing.T) {
4040
})
4141
}
4242

43+
func TestAccTencentCloudDnspodRecordListDataSource_withoutSubDomain(t *testing.T) {
44+
t.Parallel()
45+
resource.Test(t, resource.TestCase{
46+
PreCheck: func() { tcacctest.AccPreCheck(t) },
47+
Providers: tcacctest.AccProviders,
48+
Steps: []resource.TestStep{
49+
{
50+
Config: testAccDnspodRecordListDataSource_withoutSubDomain,
51+
Check: resource.ComposeTestCheckFunc(
52+
tcacctest.AccCheckTencentCloudDataSourceID("data.tencentcloud_dnspod_record_list.subdomains"),
53+
resource.TestCheckResourceAttrSet("data.tencentcloud_dnspod_record_list.subdomains", "record_list.#"),
54+
resource.TestCheckResourceAttrSet("data.tencentcloud_dnspod_record_list.subdomains", "instance_list.#"),
55+
),
56+
},
57+
},
58+
})
59+
}
60+
4361
const testAccDnspodRecordListDataSource = `
4462
4563
data "tencentcloud_dnspod_record_list" "record_list" {
@@ -76,3 +94,10 @@ data "tencentcloud_dnspod_record_list" "subdomains" {
7694
sub_domains = ["tes1029","tes103"]
7795
}
7896
`
97+
98+
const testAccDnspodRecordListDataSource_withoutSubDomain = `
99+
data "tencentcloud_dnspod_record_list" "subdomains" {
100+
domain = "mikatong.xyz"
101+
is_exact_sub_domain = true
102+
}
103+
`

tencentcloud/services/dnspod/service_tencentcloud_dnspod.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ func (me *DnspodService) DescribeDnspodRecordListByFilter(ctx context.Context, p
527527

528528
var (
529529
offset uint64 = 0
530-
limit uint64 = 20
530+
limit uint64 = 1000
531531
)
532532
for {
533533
request.Offset = &offset

0 commit comments

Comments
 (0)