Skip to content

Commit 290af37

Browse files
committed
fix: ovh_domain_zone_record: use correct default value for ttl
Fixes #666 Signed-off-by: Romain Beuque <[email protected]>
1 parent 5a12e31 commit 290af37

File tree

2 files changed

+41
-3
lines changed

2 files changed

+41
-3
lines changed

ovh/resource_domain_zone_record.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ func resourceOvhDomainZoneRecord() *schema.Resource {
7272
"ttl": {
7373
Type: schema.TypeInt,
7474
Optional: true,
75-
Default: 3600,
75+
Default: 0,
7676
ValidateFunc: func(val interface{}, key string) (warns []string, errs []error) {
7777
v := val.(int)
78-
if v < 60 {
79-
errs = append(errs, fmt.Errorf("%q must be greater than or equal to 60, got: %d", key, v))
78+
if v < 60 && v != 0 {
79+
errs = append(errs, fmt.Errorf("%q must be either equal to 0 or, greater than or equal to 60, got: %d", key, v))
8080
}
8181
return
8282
},

ovh/resource_domain_zone_record_test.go

+38
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,34 @@ func TestAccDomainZoneRecord_Basic(t *testing.T) {
124124
"ovh_domain_zone_record.foobar", "ttl", "3600"),
125125
),
126126
},
127+
{
128+
Config: testAccCheckOvhDomainZoneRecordConfig_A(zone, subdomain, "192.168.0.11", 0),
129+
Check: resource.ComposeTestCheckFunc(
130+
testAccCheckOvhDomainZoneRecordExists("ovh_domain_zone_record.foobar", &record),
131+
resource.TestCheckResourceAttr(
132+
"ovh_domain_zone_record.foobar", "subdomain", subdomain),
133+
resource.TestCheckResourceAttr(
134+
"ovh_domain_zone_record.foobar", "zone", zone),
135+
resource.TestCheckResourceAttr(
136+
"ovh_domain_zone_record.foobar", "target", "192.168.0.11"),
137+
resource.TestCheckResourceAttr(
138+
"ovh_domain_zone_record.foobar", "ttl", "0"),
139+
),
140+
},
141+
{
142+
Config: testAccCheckOvhDomainZoneRecordConfig_A_noTTL(zone, subdomain, "192.168.0.12"),
143+
Check: resource.ComposeTestCheckFunc(
144+
testAccCheckOvhDomainZoneRecordExists("ovh_domain_zone_record.foobar", &record),
145+
resource.TestCheckResourceAttr(
146+
"ovh_domain_zone_record.foobar", "subdomain", subdomain),
147+
resource.TestCheckResourceAttr(
148+
"ovh_domain_zone_record.foobar", "zone", zone),
149+
resource.TestCheckResourceAttr(
150+
"ovh_domain_zone_record.foobar", "target", "192.168.0.12"),
151+
resource.TestCheckResourceAttr(
152+
"ovh_domain_zone_record.foobar", "ttl", "0"),
153+
),
154+
},
127155
},
128156
})
129157
}
@@ -312,6 +340,16 @@ resource "ovh_domain_zone_record" "foobar" {
312340
}`, zone, subdomain, target, ttl)
313341
}
314342

343+
func testAccCheckOvhDomainZoneRecordConfig_A_noTTL(zone, subdomain, target string) string {
344+
return fmt.Sprintf(`
345+
resource "ovh_domain_zone_record" "foobar" {
346+
zone = "%s"
347+
subdomain = "%s"
348+
target = "%s"
349+
fieldtype = "A"
350+
}`, zone, subdomain, target)
351+
}
352+
315353
func testAccCheckOvhDomainZoneRecordConfig_CNAME(zone, subdomain, target string, ttl int) string {
316354
return fmt.Sprintf(`
317355
resource "ovh_domain_zone_record" "foobar" {

0 commit comments

Comments
 (0)