Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support GTD enabled domains to DME provider #4305

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions builtin/providers/dme/resource_dme_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ func resourceDMERecord() *schema.Resource {
Type: schema.TypeString,
Optional: true,
},
"gtdLocation": &schema.Schema{
Type: schema.TypeString,
Optional: true,
},
},
}
}
Expand Down Expand Up @@ -168,6 +172,9 @@ func getAll(d *schema.ResourceData, cr map[string]interface{}) error {
if attr, ok := d.GetOk("value"); ok {
cr["value"] = attr.(string)
}
if attr, ok := d.GetOk("gtdLocation"); ok {
cr["gtdLocation"] = attr.(string)
}

switch strings.ToUpper(d.Get("type").(string)) {
case "A", "CNAME", "ANAME", "TXT", "SPF", "NS", "PTR", "AAAA":
Expand Down Expand Up @@ -213,6 +220,10 @@ func setAll(d *schema.ResourceData, rec *dnsmadeeasy.Record) error {
d.Set("name", rec.Name)
d.Set("ttl", rec.TTL)
d.Set("value", rec.Value)
// only set gtdLocation if it is given as this is optional.
if rec.GtdLocation != "" {
d.Set("gtdLocation", rec.GtdLocation)
}

switch rec.Type {
case "A", "CNAME", "ANAME", "TXT", "SPF", "NS", "PTR":
Expand Down
33 changes: 33 additions & 0 deletions builtin/providers/dme/resource_dme_record_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ func TestAccDMERecord_basic(t *testing.T) {
"dme_record.test", "value", "1.1.1.1"),
resource.TestCheckResourceAttr(
"dme_record.test", "ttl", "2000"),
resource.TestCheckResourceAttr(
"dme_record.test", "gtdLocation", "DEFAULT"),

),
},
},
Expand Down Expand Up @@ -65,6 +68,9 @@ func TestAccDMERecordCName(t *testing.T) {
"dme_record.test", "value", "foo"),
resource.TestCheckResourceAttr(
"dme_record.test", "ttl", "2000"),
resource.TestCheckResourceAttr(
"dme_record.test", "gtdLocation", "DEFAULT"),

),
},
},
Expand Down Expand Up @@ -131,6 +137,8 @@ func TestAccDMERecordMX(t *testing.T) {
"dme_record.test", "mxLevel", "10"),
resource.TestCheckResourceAttr(
"dme_record.test", "ttl", "2000"),
resource.TestCheckResourceAttr(
"dme_record.test", "gtdLocation", "DEFAULT"),
),
},
},
Expand Down Expand Up @@ -172,6 +180,8 @@ func TestAccDMERecordHTTPRED(t *testing.T) {

resource.TestCheckResourceAttr(
"dme_record.test", "ttl", "2000"),
resource.TestCheckResourceAttr(
"dme_record.test", "gtdLocation", "DEFAULT"),
),
},
},
Expand Down Expand Up @@ -201,6 +211,8 @@ func TestAccDMERecordTXT(t *testing.T) {
"dme_record.test", "value", "\"foo\""),
resource.TestCheckResourceAttr(
"dme_record.test", "ttl", "2000"),
resource.TestCheckResourceAttr(
"dme_record.test", "gtdLocation", "DEFAULT"),
),
},
},
Expand Down Expand Up @@ -230,6 +242,8 @@ func TestAccDMERecordSPF(t *testing.T) {
"dme_record.test", "value", "\"foo\""),
resource.TestCheckResourceAttr(
"dme_record.test", "ttl", "2000"),
resource.TestCheckResourceAttr(
"dme_record.test", "gtdLocation", "DEFAULT"),
),
},
},
Expand Down Expand Up @@ -259,6 +273,8 @@ func TestAccDMERecordPTR(t *testing.T) {
"dme_record.test", "value", "foo"),
resource.TestCheckResourceAttr(
"dme_record.test", "ttl", "2000"),
resource.TestCheckResourceAttr(
"dme_record.test", "gtdLocation", "DEFAULT"),
),
},
},
Expand Down Expand Up @@ -288,6 +304,8 @@ func TestAccDMERecordNS(t *testing.T) {
"dme_record.test", "value", "foo"),
resource.TestCheckResourceAttr(
"dme_record.test", "ttl", "2000"),
resource.TestCheckResourceAttr(
"dme_record.test", "gtdLocation", "DEFAULT"),
),
},
},
Expand Down Expand Up @@ -317,6 +335,8 @@ func TestAccDMERecordAAAA(t *testing.T) {
"dme_record.test", "value", "fe80::0202:b3ff:fe1e:8329"),
resource.TestCheckResourceAttr(
"dme_record.test", "ttl", "2000"),
resource.TestCheckResourceAttr(
"dme_record.test", "gtdLocation", "DEFAULT"),
),
},
},
Expand Down Expand Up @@ -352,6 +372,8 @@ func TestAccDMERecordSRV(t *testing.T) {
"dme_record.test", "port", "30"),
resource.TestCheckResourceAttr(
"dme_record.test", "ttl", "2000"),
resource.TestCheckResourceAttr(
"dme_record.test", "gtdLocation", "DEFAULT"),
),
},
},
Expand Down Expand Up @@ -413,6 +435,7 @@ resource "dme_record" "test" {
type = "A"
value = "1.1.1.1"
ttl = 2000
gtdLocation = "DEFAULT"
}`

const testDMERecordConfigCName = `
Expand All @@ -422,6 +445,7 @@ resource "dme_record" "test" {
type = "CNAME"
value = "foo"
ttl = 2000
gtdLocation = "DEFAULT"
}`

const testDMERecordConfigAName = `
Expand All @@ -431,6 +455,7 @@ resource "dme_record" "test" {
type = "ANAME"
value = "foo"
ttl = 2000
gtdLocation = "DEFAULT"
}`

const testDMERecordConfigMX = `
Expand All @@ -441,6 +466,7 @@ resource "dme_record" "test" {
value = "foo"
mxLevel = 10
ttl = 2000
gtdLocation = "DEFAULT"
}`

const testDMERecordConfigHTTPRED = `
Expand All @@ -455,6 +481,7 @@ resource "dme_record" "test" {
keywords = "terraform example"
description = "This is a description"
ttl = 2000
gtdLocation = "DEFAULT"
}`

const testDMERecordConfigTXT = `
Expand All @@ -464,6 +491,7 @@ resource "dme_record" "test" {
type = "TXT"
value = "foo"
ttl = 2000
gtdLocation = "DEFAULT"
}`

const testDMERecordConfigSPF = `
Expand All @@ -473,6 +501,7 @@ resource "dme_record" "test" {
type = "SPF"
value = "foo"
ttl = 2000
gtdLocation = "DEFAULT"
}`

const testDMERecordConfigPTR = `
Expand All @@ -482,6 +511,7 @@ resource "dme_record" "test" {
type = "PTR"
value = "foo"
ttl = 2000
gtdLocation = "DEFAULT"
}`

const testDMERecordConfigNS = `
Expand All @@ -491,6 +521,7 @@ resource "dme_record" "test" {
type = "NS"
value = "foo"
ttl = 2000
gtdLocation = "DEFAULT"
}`

const testDMERecordConfigAAAA = `
Expand All @@ -500,6 +531,7 @@ resource "dme_record" "test" {
type = "AAAA"
value = "FE80::0202:B3FF:FE1E:8329"
ttl = 2000
gtdLocation = "DEFAULT"
}`

const testDMERecordConfigSRV = `
Expand All @@ -512,4 +544,5 @@ resource "dme_record" "test" {
weight = 20
port = 30
ttl = 2000
gtdLocation = "DEFAULT"
}`
4 changes: 4 additions & 0 deletions website/source/docs/providers/dme/r/record.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ resource "dme_record" "www" {
type = "A"
value = "192.168.1.1"
ttl = 3600
gtdLocation = "DEFAULT"
}
```

Expand All @@ -34,6 +35,7 @@ The following arguments are supported:
* `value` - (Required) The value of the record; its usage
will depend on the `type` (see below)
* `ttl` - (Integer, Optional) The TTL of the record
* `gtdLocation` - (String, Optional) The GTD Location of the record on GTD enabled domains; Unless GTD is enabled this should be omitted or set to "DEFAULT"

Additional arguments are listed below under DNS Record Types.

Expand Down Expand Up @@ -117,6 +119,7 @@ The following attributes are exported:
* `value` - The value of the record
`type` (see below)
* `ttl` - The TTL of the record
* `gtdLocation` - The GTD Location of the record on GTD enabled domains

Additional fields may also be exported by some record types -
see DNS Record Types.
Expand All @@ -141,6 +144,7 @@ resource "dme_record" "testa" {
type = "A"
value = "1.1.1.1"
ttl = 1000
gtdLocation = "DEFAULT"
}

# CNAME record
Expand Down