Skip to content

Commit 4c35288

Browse files
committed
fix: don't compare TTL when checking if record matches
1 parent f11ba09 commit 4c35288

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

hostingde/record_resource.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ func (r *recordResource) Create(ctx context.Context, req resource.CreateRequest,
137137

138138
var returnedRecord DNSRecord
139139
for _, responseRecord := range recordResp.Response.Records {
140-
if responseRecord.Name == record.Name && responseRecord.Type == record.Type && responseRecord.TTL == record.TTL {
140+
if responseRecord.Name == record.Name && responseRecord.Type == record.Type {
141141
if responseRecord.Content == record.Content {
142142
returnedRecord = responseRecord
143143
break;
@@ -255,7 +255,7 @@ func (r *recordResource) Update(ctx context.Context, req resource.UpdateRequest,
255255

256256
var returnedRecord DNSRecord
257257
for _, responseRecord := range recordResp.Response.Records {
258-
if responseRecord.Name == record.Name && responseRecord.Type == record.Type && responseRecord.TTL == record.TTL {
258+
if responseRecord.Name == record.Name && responseRecord.Type == record.Type {
259259
if responseRecord.Content == record.Content {
260260
returnedRecord = responseRecord
261261
break;

hostingde/record_resource_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ resource "hostingde_record" "test_mx" {
5252
content = "mail.example2.test"
5353
priority = 10
5454
}
55+
resource "hostingde_record" "test_mx" {
56+
zone_id = hostingde_zone.test.id
57+
name = "example2.test"
58+
type = "MX"
59+
content = "mail.example2.test"
60+
priority = 10
61+
}
5562
`,
5663
Check: resource.ComposeAggregateTestCheckFunc(
5764
// Verify name attribute.
@@ -142,6 +149,27 @@ resource "hostingde_record" "test_mx" {
142149
resource.TestCheckResourceAttr("hostingde_record.test_mx", "priority", "20"),
143150
),
144151
},
152+
// Update and Read testing for TXT records
153+
{
154+
Config: providerConfig + `
155+
resource "hostingde_zone" "test" {
156+
name = "example2.test"
157+
type = "NATIVE"
158+
email = "hostmaster@example2.test"
159+
}
160+
resource "hostingde_record" "test_dkim" {
161+
zone_id = hostingde_zone.test.id
162+
name = "default._domainkey.example2.test"
163+
type = "TXT"
164+
content = "v=DKIM1;k=rsa;p=MiibiJanbGKQHKIg9W0baqefaaocaq8amiibcGkcaqeaYLA9Hw3tVOxVzqXWZAj4sz9ICT1hu3e6+fWlwNIgE6tIpTCyRJtiSIUDqB8TLTIBoxIs+QQBXZi+QUi3Agu6OSY2RiV0EwO8+OooQod9PerFTC/AQE51CxUV4KpQWVPxebWRxfwvm+vXIVeUBuj7EkKfYxjPELV0lSLxV/mMyBuYED6Df+REogzcSVNBIrV74QDXBal/25J62e8wRNXzJwhUtx/JhdBOjsHBvuw9hy6rZsVJL9eXayWyGRV6qmsLRzsRSBs+mDrgmKk4dugADd11+A03ics3i8hplRoWDkqnNKz1qy4f5TsV6v9283IANrAzRfHwX8EvNiFsBz+ZCQIDAQAB"
165+
ttl = 300
166+
}
167+
`,
168+
Check: resource.ComposeAggregateTestCheckFunc(
169+
// Verify content attribute.
170+
resource.TestCheckResourceAttr("hostingde_record.test_dkim", "content", "v=DKIM1;k=rsa;p=MiibiJanbGKQHKIg9W0baqefaaocaq8amiibcGkcaqeaYLA9Hw3tVOxVzqXWZAj4sz9ICT1hu3e6+fWlwNIgE6tIpTCyRJtiSIUDqB8TLTIBoxIs+QQBXZi+QUi3Agu6OSY2RiV0EwO8+OooQod9PerFTC/AQE51CxUV4KpQWVPxebWRxfwvm+vXIVeUBuj7EkKfYxjPELV0lSLxV/mMyBuYED6Df+REogzcSVNBIrV74QDXBal/25J62e8wRNXzJwhUtx/JhdBOjsHBvuw9hy6rZsVJL9eXayWyGRV6qmsLRzsRSBs+mDrgmKk4dugADd11+A03ics3i8hplRoWDkqnNKz1qy4f5TsV6v9283IANrAzRfHwX8EvNiFsBz+ZCQIDAQAB"),
171+
),
172+
},
145173
// Delete testing automatically occurs in TestCase
146174
},
147175
})

0 commit comments

Comments
 (0)