Skip to content

Commit 638ead7

Browse files
authored
feat(domain): handles @ records (#1883)
* feat(domain): handles `@` records * use statefunc * add tests
1 parent 8d4ea80 commit 638ead7

File tree

3 files changed

+716
-0
lines changed

3 files changed

+716
-0
lines changed

scaleway/resource_domain_record.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ func resourceScalewayDomainRecord() *schema.Resource {
5353
Description: "The name of the record",
5454
ForceNew: true,
5555
Optional: true,
56+
StateFunc: func(val interface{}) string {
57+
value := val.(string)
58+
if value == "@" {
59+
return ""
60+
}
61+
62+
return value
63+
},
5664
},
5765
"type": {
5866
Type: schema.TypeString,

scaleway/resource_domain_record_test.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,47 @@ func TestAccScalewayDomainRecord_Basic2(t *testing.T) {
284284
})
285285
}
286286

287+
func TestAccScalewayDomainRecord_Arobase(t *testing.T) {
288+
tt := NewTestTools(t)
289+
defer tt.Cleanup()
290+
291+
testDNSZone := fmt.Sprintf("test-arobase.%s", testDomain)
292+
l.Debugf("TestAccScalewayDomainRecord_Arobase: test dns zone: %s", testDNSZone)
293+
294+
resource.ParallelTest(t, resource.TestCase{
295+
PreCheck: func() { testAccPreCheck(t) },
296+
ProviderFactories: tt.ProviderFactories,
297+
CheckDestroy: testAccCheckScalewayDomainRecordDestroy(tt),
298+
Steps: []resource.TestStep{
299+
{
300+
Config: fmt.Sprintf(`
301+
resource "scaleway_domain_record" "main" {
302+
dns_zone = %[1]q
303+
name = "@"
304+
type = "TXT"
305+
data = "this-is-a-test"
306+
}
307+
`, testDNSZone),
308+
Check: resource.ComposeTestCheckFunc(
309+
testAccCheckScalewayDomainRecordExists(tt, "scaleway_domain_record.main"),
310+
resource.TestCheckResourceAttr("scaleway_domain_record.main", "name", ""),
311+
),
312+
},
313+
{
314+
Config: fmt.Sprintf(`
315+
resource "scaleway_domain_record" "main" {
316+
dns_zone = %[1]q
317+
name = ""
318+
type = "TXT"
319+
data = "this-is-a-test"
320+
}
321+
`, testDNSZone),
322+
PlanOnly: true,
323+
},
324+
},
325+
})
326+
}
327+
287328
func TestAccScalewayDomainRecord_GeoIP(t *testing.T) {
288329
tt := NewTestTools(t)
289330
defer tt.Cleanup()

0 commit comments

Comments
 (0)