Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/3585.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
data-source/tencentcloud_dnspod_record_list: support `filter_at_ns`
```
27 changes: 27 additions & 0 deletions schema/filter.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,33 @@
},
"required": true,
"description": ""
},
"filter_at_ns": {
"type": "bool",
"metadata": {
"filter": {
"enable": true
},
"values": [
{
"value": true,
"display_name": "是"
}
],
"widget": "select",
"val_source": {
"values": {}
},
"description": "是否过滤主机记录为 @ 的 NS 记录",
"display_name": "是否过滤主机记录为 @ 的 NS 记录",
"default_value": {
"value": true,
"display_name": "是"
},
"is_not_edited": true
},
"required": true,
"description": ""
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,13 @@ func DataSourceTencentCloudDnspodRecordList() *schema.Resource {
Description: "Project ID.",
},

"filter_at_ns": {
Optional: true,
Type: schema.TypeBool,
Description: "Filter @ type NS records. Default is false.",
Default: false,
},

"record_count_info": {
Computed: true,
Type: schema.TypeList,
Expand Down Expand Up @@ -484,7 +491,10 @@ func dataSourceTencentCloudDnspodRecordListRead(d *schema.ResourceData, meta int
if v, ok := d.GetOkExists("project_id"); ok {
paramMap["ProjectId"] = helper.IntInt64(v.(int))
}

var filterAtNS bool
if v, ok := d.GetOkExists("filter_at_ns"); ok {
filterAtNS = v.(bool)
}
service := DnspodService{client: meta.(tccommon.ProviderMeta).GetAPIV3Conn()}

var recordList []*dnspod.RecordListItem
Expand Down Expand Up @@ -536,6 +546,9 @@ func dataSourceTencentCloudDnspodRecordListRead(d *schema.ResourceData, meta int
instanceList := make([]map[string]interface{}, 0, len(recordList))
if recordList != nil {
for _, recordListItem := range recordList {
if filterAtNS && recordListItem.Name != nil && *recordListItem.Name == DNSPOD_RECORD_NAME_AT && recordListItem.Type != nil && *recordListItem.Type == DNSPOD_RECORD_TYPE_NS {
continue
}
recordListItemMap := map[string]interface{}{}
instanceListItemMap := map[string]interface{}{}
instanceListItemMap["domain"] = domain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,36 @@ func TestAccTencentCloudDnspodRecordListDataSource_withoutSubDomain(t *testing.T
})
}

func TestAccTencentCloudDnspodRecordListDataSource_filterAtNS(t *testing.T) {
t.Parallel()
resource.Test(t, resource.TestCase{
PreCheck: func() { tcacctest.AccPreCheck(t) },
Providers: tcacctest.AccProviders,
Steps: []resource.TestStep{
{
Config: testAccDnspodRecordListDataSource_filterAtNSTrue,
Check: resource.ComposeTestCheckFunc(
tcacctest.AccCheckTencentCloudDataSourceID("data.tencentcloud_dnspod_record_list.subdomains"),
resource.TestCheckResourceAttr("data.tencentcloud_dnspod_record_list.subdomains", "record_list.#", "0"),
resource.TestCheckResourceAttr("data.tencentcloud_dnspod_record_list.subdomains", "instance_list.#", "0"),
),
},
{
Config: testAccDnspodRecordListDataSource_filterAtNSFalse,
Check: resource.ComposeTestCheckFunc(
tcacctest.AccCheckTencentCloudDataSourceID("data.tencentcloud_dnspod_record_list.subdomains"),
resource.TestCheckResourceAttr("data.tencentcloud_dnspod_record_list.subdomains", "record_list.#", "2"),
resource.TestCheckResourceAttr("data.tencentcloud_dnspod_record_list.subdomains", "instance_list.#", "2"),
),
},
},
})
}

const testAccDnspodRecordListDataSource = `

data "tencentcloud_dnspod_record_list" "record_list" {
domain = "iac-tf.cloud"
domain = "tencentcloud-terraform-provider.cn"
# domain_id = 123
# sub_domain = "www"
record_type = ["A", "NS", "CNAME", "NS", "AAAA"]
Expand Down Expand Up @@ -101,3 +127,20 @@ data "tencentcloud_dnspod_record_list" "subdomains" {
is_exact_sub_domain = true
}
`

const testAccDnspodRecordListDataSource_filterAtNSTrue = `
data "tencentcloud_dnspod_record_list" "subdomains" {
domain = "tencentcloud-terraform-provider.cn"
sub_domains = ["@"]
record_type = ["NS"]
filter_at_ns = true
}
`
const testAccDnspodRecordListDataSource_filterAtNSFalse = `
data "tencentcloud_dnspod_record_list" "subdomains" {
domain = "tencentcloud-terraform-provider.cn"
sub_domains = ["@"]
record_type = ["NS"]
filter_at_ns = false
}
`
5 changes: 5 additions & 0 deletions tencentcloud/services/dnspod/extension_dnspod.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,8 @@ var DNSPOD_DOMAIN_STATUS_TYPE = []string{
DNSPOD_DOMAIN_STATUS_ENABLE,
DNSPOD_DOMAIN_STATUS_DISABLE,
}

const (
DNSPOD_RECORD_NAME_AT = "@"
DNSPOD_RECORD_TYPE_NS = "NS"
)
1 change: 1 addition & 0 deletions website/docs/d/dnspod_record_list.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ The following arguments are supported:

* `domain` - (Required, String) The domain to which the resolution record belongs.
* `domain_id` - (Optional, Int) The domain ID to which the resolution record belongs. If DomainId is provided, the system will ignore the Domain parameter. You can find all Domain and DomainId through the DescribeDomainList interface.
* `filter_at_ns` - (Optional, Bool) Filter @ type NS records. Default is false.
* `group_id` - (Optional, Set: [`Int`]) When retrieving resolution records under certain groups, pass this group ID. You can obtain the GroupId field through the DescribeRecordGroupList interface.
* `is_exact_sub_domain` - (Optional, Bool) Whether to perform an exact search based on the SubDomain parameter.
* `keyword` - (Optional, String) Search for resolution records by keyword, currently supporting searching host headers and record values.
Expand Down
Loading