Skip to content

Commit b016104

Browse files
authored
Merge pull request #397 from ovh/yomovh/zone_ttl_fix
Validate TTL in zone_record to >=60
2 parents 134c8ee + 791734e commit b016104

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

ovh/resource_domain_zone_record.go

+7
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ func resourceOvhDomainZoneRecord() *schema.Resource {
7272
Type: schema.TypeInt,
7373
Optional: true,
7474
Default: 3600,
75+
ValidateFunc: func(val interface{}, key string) (warns []string, errs []error) {
76+
v := val.(int)
77+
if v < 60 {
78+
errs = append(errs, fmt.Errorf("%q must be greater than or equal to 60, got: %d", key, v))
79+
}
80+
return
81+
},
7582
},
7683
"fieldtype": {
7784
Type: schema.TypeString,

ovh/resource_domain_zone_record_test.go

+10-3
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ import (
66
"strconv"
77
"testing"
88

9-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
10-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
11-
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
129
"log"
10+
"regexp"
1311
"strings"
1412
"time"
13+
14+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
15+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
16+
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
1517
)
1618

1719
func init() {
@@ -103,6 +105,11 @@ func TestAccDomainZoneRecord_Basic(t *testing.T) {
103105
Providers: testAccProviders,
104106
CheckDestroy: testAccCheckOvhDomainZoneRecordDestroy,
105107
Steps: []resource.TestStep{
108+
// provider shall send an error if the TTL is less than 60
109+
{
110+
Config: testAccCheckOvhDomainZoneRecordConfig_CNAME(zone, subdomain, "google.com.", 10),
111+
ExpectError: regexp.MustCompile(`must be greater`),
112+
},
106113
{
107114
Config: testAccCheckOvhDomainZoneRecordConfig_A(zone, subdomain, "192.168.0.10", 3600),
108115
Check: resource.ComposeTestCheckFunc(

website/docs/r/ovh_domain_zone_record.html.markdown

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ The following arguments are supported:
3131
* `subdomain` - (Required) The name of the record
3232
* `target` - (Required) The value of the record
3333
* `fieldtype` - (Required) The type of the record
34-
* `ttl` - (Optional) The TTL of the record
34+
* `ttl` - (Optional) The TTL of the record, it shall be >= to 60.
3535

3636

3737
## Attributes Reference

0 commit comments

Comments
 (0)