Skip to content

Commit

Permalink
Merge pull request #3084 from PAYBACKGmbH/master
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobbednarz authored Jan 30, 2024
2 parents cc323da + ae4c383 commit f55fe6e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .changelog/3084.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
datasource/cloudflare_record: Add the option to filter by "content"
```
1 change: 1 addition & 0 deletions docs/data-sources/record.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ data "cloudflare_record" "example" {

### Optional

- `content` (String) Content to filter record results on.
- `priority` (Number) DNS priority to filter record results on.
- `type` (String) DNS record type to filter record results on. Defaults to `A`.

Expand Down
10 changes: 8 additions & 2 deletions internal/sdkv2provider/data_source_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ func dataSourceCloudflareRecord() *schema.Resource {
ValidateFunc: validation.StringInSlice([]string{"A", "AAAA", "CAA", "CNAME", "TXT", "SRV", "LOC", "MX", "NS", "SPF", "CERT", "DNSKEY", "DS", "NAPTR", "SMIMEA", "SSHFP", "TLSA", "URI", "PTR", "HTTPS", "SVCB"}, false),
Description: "DNS record type to filter record results on.",
},
"content": {
Type: schema.TypeString,
Optional: true,
Description: "Content to filter record results on.",
},
"priority": {
Type: schema.TypeInt,
Optional: true,
Expand Down Expand Up @@ -81,8 +86,9 @@ func dataSourceCloudflareRecordRead(ctx context.Context, d *schema.ResourceData,
zoneID := d.Get(consts.ZoneIDSchemaKey).(string)

searchRecord := cloudflare.ListDNSRecordsParams{
Name: d.Get("hostname").(string),
Type: d.Get("type").(string),
Name: d.Get("hostname").(string),
Type: d.Get("type").(string),
Content: d.Get("content").(string),
}

records, _, err := client.ListDNSRecords(ctx, cloudflare.ZoneIdentifier(zoneID), searchRecord)
Expand Down

0 comments on commit f55fe6e

Please sign in to comment.