Merge branch 'improbable-io-b-dme-support-gtdlocation'

This commit is contained in:
James Nugent 2016-01-21 06:48:53 -05:00
commit 16ea2435c2
3 changed files with 51 additions and 4 deletions

View File

@ -74,6 +74,10 @@ func resourceDMERecord() *schema.Resource {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
}, },
"gtdLocation": &schema.Schema{
Type: schema.TypeString,
Optional: true,
},
}, },
} }
} }
@ -168,6 +172,9 @@ func getAll(d *schema.ResourceData, cr map[string]interface{}) error {
if attr, ok := d.GetOk("value"); ok { if attr, ok := d.GetOk("value"); ok {
cr["value"] = attr.(string) cr["value"] = attr.(string)
} }
if attr, ok := d.GetOk("gtdLocation"); ok {
cr["gtdLocation"] = attr.(string)
}
switch strings.ToUpper(d.Get("type").(string)) { switch strings.ToUpper(d.Get("type").(string)) {
case "A", "CNAME", "ANAME", "TXT", "SPF", "NS", "PTR", "AAAA": case "A", "CNAME", "ANAME", "TXT", "SPF", "NS", "PTR", "AAAA":
@ -213,6 +220,10 @@ func setAll(d *schema.ResourceData, rec *dnsmadeeasy.Record) error {
d.Set("name", rec.Name) d.Set("name", rec.Name)
d.Set("ttl", rec.TTL) d.Set("ttl", rec.TTL)
d.Set("value", rec.Value) 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 { switch rec.Type {
case "A", "CNAME", "ANAME", "TXT", "SPF", "NS", "PTR": case "A", "CNAME", "ANAME", "TXT", "SPF", "NS", "PTR":

View File

@ -36,6 +36,8 @@ func TestAccDMERecord_basic(t *testing.T) {
"dme_record.test", "value", "1.1.1.1"), "dme_record.test", "value", "1.1.1.1"),
resource.TestCheckResourceAttr( resource.TestCheckResourceAttr(
"dme_record.test", "ttl", "2000"), "dme_record.test", "ttl", "2000"),
resource.TestCheckResourceAttr(
"dme_record.test", "gtdLocation", "DEFAULT"),
), ),
}, },
}, },
@ -65,6 +67,8 @@ func TestAccDMERecordCName(t *testing.T) {
"dme_record.test", "value", "foo"), "dme_record.test", "value", "foo"),
resource.TestCheckResourceAttr( resource.TestCheckResourceAttr(
"dme_record.test", "ttl", "2000"), "dme_record.test", "ttl", "2000"),
resource.TestCheckResourceAttr(
"dme_record.test", "gtdLocation", "DEFAULT"),
), ),
}, },
}, },
@ -131,6 +135,8 @@ func TestAccDMERecordMX(t *testing.T) {
"dme_record.test", "mxLevel", "10"), "dme_record.test", "mxLevel", "10"),
resource.TestCheckResourceAttr( resource.TestCheckResourceAttr(
"dme_record.test", "ttl", "2000"), "dme_record.test", "ttl", "2000"),
resource.TestCheckResourceAttr(
"dme_record.test", "gtdLocation", "DEFAULT"),
), ),
}, },
}, },
@ -172,6 +178,8 @@ func TestAccDMERecordHTTPRED(t *testing.T) {
resource.TestCheckResourceAttr( resource.TestCheckResourceAttr(
"dme_record.test", "ttl", "2000"), "dme_record.test", "ttl", "2000"),
resource.TestCheckResourceAttr(
"dme_record.test", "gtdLocation", "DEFAULT"),
), ),
}, },
}, },
@ -201,6 +209,8 @@ func TestAccDMERecordTXT(t *testing.T) {
"dme_record.test", "value", "\"foo\""), "dme_record.test", "value", "\"foo\""),
resource.TestCheckResourceAttr( resource.TestCheckResourceAttr(
"dme_record.test", "ttl", "2000"), "dme_record.test", "ttl", "2000"),
resource.TestCheckResourceAttr(
"dme_record.test", "gtdLocation", "DEFAULT"),
), ),
}, },
}, },
@ -230,6 +240,8 @@ func TestAccDMERecordSPF(t *testing.T) {
"dme_record.test", "value", "\"foo\""), "dme_record.test", "value", "\"foo\""),
resource.TestCheckResourceAttr( resource.TestCheckResourceAttr(
"dme_record.test", "ttl", "2000"), "dme_record.test", "ttl", "2000"),
resource.TestCheckResourceAttr(
"dme_record.test", "gtdLocation", "DEFAULT"),
), ),
}, },
}, },
@ -259,6 +271,8 @@ func TestAccDMERecordPTR(t *testing.T) {
"dme_record.test", "value", "foo"), "dme_record.test", "value", "foo"),
resource.TestCheckResourceAttr( resource.TestCheckResourceAttr(
"dme_record.test", "ttl", "2000"), "dme_record.test", "ttl", "2000"),
resource.TestCheckResourceAttr(
"dme_record.test", "gtdLocation", "DEFAULT"),
), ),
}, },
}, },
@ -288,6 +302,8 @@ func TestAccDMERecordNS(t *testing.T) {
"dme_record.test", "value", "foo"), "dme_record.test", "value", "foo"),
resource.TestCheckResourceAttr( resource.TestCheckResourceAttr(
"dme_record.test", "ttl", "2000"), "dme_record.test", "ttl", "2000"),
resource.TestCheckResourceAttr(
"dme_record.test", "gtdLocation", "DEFAULT"),
), ),
}, },
}, },
@ -317,6 +333,8 @@ func TestAccDMERecordAAAA(t *testing.T) {
"dme_record.test", "value", "fe80::0202:b3ff:fe1e:8329"), "dme_record.test", "value", "fe80::0202:b3ff:fe1e:8329"),
resource.TestCheckResourceAttr( resource.TestCheckResourceAttr(
"dme_record.test", "ttl", "2000"), "dme_record.test", "ttl", "2000"),
resource.TestCheckResourceAttr(
"dme_record.test", "gtdLocation", "DEFAULT"),
), ),
}, },
}, },
@ -352,6 +370,8 @@ func TestAccDMERecordSRV(t *testing.T) {
"dme_record.test", "port", "30"), "dme_record.test", "port", "30"),
resource.TestCheckResourceAttr( resource.TestCheckResourceAttr(
"dme_record.test", "ttl", "2000"), "dme_record.test", "ttl", "2000"),
resource.TestCheckResourceAttr(
"dme_record.test", "gtdLocation", "DEFAULT"),
), ),
}, },
}, },
@ -413,6 +433,7 @@ resource "dme_record" "test" {
type = "A" type = "A"
value = "1.1.1.1" value = "1.1.1.1"
ttl = 2000 ttl = 2000
gtdLocation = "DEFAULT"
}` }`
const testDMERecordConfigCName = ` const testDMERecordConfigCName = `
@ -422,6 +443,7 @@ resource "dme_record" "test" {
type = "CNAME" type = "CNAME"
value = "foo" value = "foo"
ttl = 2000 ttl = 2000
gtdLocation = "DEFAULT"
}` }`
const testDMERecordConfigAName = ` const testDMERecordConfigAName = `
@ -431,6 +453,7 @@ resource "dme_record" "test" {
type = "ANAME" type = "ANAME"
value = "foo" value = "foo"
ttl = 2000 ttl = 2000
gtdLocation = "DEFAULT"
}` }`
const testDMERecordConfigMX = ` const testDMERecordConfigMX = `
@ -441,6 +464,7 @@ resource "dme_record" "test" {
value = "foo" value = "foo"
mxLevel = 10 mxLevel = 10
ttl = 2000 ttl = 2000
gtdLocation = "DEFAULT"
}` }`
const testDMERecordConfigHTTPRED = ` const testDMERecordConfigHTTPRED = `
@ -455,6 +479,7 @@ resource "dme_record" "test" {
keywords = "terraform example" keywords = "terraform example"
description = "This is a description" description = "This is a description"
ttl = 2000 ttl = 2000
gtdLocation = "DEFAULT"
}` }`
const testDMERecordConfigTXT = ` const testDMERecordConfigTXT = `
@ -464,6 +489,7 @@ resource "dme_record" "test" {
type = "TXT" type = "TXT"
value = "foo" value = "foo"
ttl = 2000 ttl = 2000
gtdLocation = "DEFAULT"
}` }`
const testDMERecordConfigSPF = ` const testDMERecordConfigSPF = `
@ -473,6 +499,7 @@ resource "dme_record" "test" {
type = "SPF" type = "SPF"
value = "foo" value = "foo"
ttl = 2000 ttl = 2000
gtdLocation = "DEFAULT"
}` }`
const testDMERecordConfigPTR = ` const testDMERecordConfigPTR = `
@ -482,6 +509,7 @@ resource "dme_record" "test" {
type = "PTR" type = "PTR"
value = "foo" value = "foo"
ttl = 2000 ttl = 2000
gtdLocation = "DEFAULT"
}` }`
const testDMERecordConfigNS = ` const testDMERecordConfigNS = `
@ -491,6 +519,7 @@ resource "dme_record" "test" {
type = "NS" type = "NS"
value = "foo" value = "foo"
ttl = 2000 ttl = 2000
gtdLocation = "DEFAULT"
}` }`
const testDMERecordConfigAAAA = ` const testDMERecordConfigAAAA = `
@ -500,6 +529,7 @@ resource "dme_record" "test" {
type = "AAAA" type = "AAAA"
value = "FE80::0202:B3FF:FE1E:8329" value = "FE80::0202:B3FF:FE1E:8329"
ttl = 2000 ttl = 2000
gtdLocation = "DEFAULT"
}` }`
const testDMERecordConfigSRV = ` const testDMERecordConfigSRV = `
@ -512,4 +542,5 @@ resource "dme_record" "test" {
weight = 20 weight = 20
port = 30 port = 30
ttl = 2000 ttl = 2000
gtdLocation = "DEFAULT"
}` }`

View File

@ -20,6 +20,7 @@ resource "dme_record" "www" {
type = "A" type = "A"
value = "192.168.1.1" value = "192.168.1.1"
ttl = 3600 ttl = 3600
gtdLocation = "DEFAULT"
} }
``` ```
@ -29,11 +30,13 @@ The following arguments are supported:
* `domainid` - (String, Required) The domain id to add the * `domainid` - (String, Required) The domain id to add the
record to record to
* `name` - (Required) The name of the record * `name` - (Required) The name of the record `type` - (Required) The type of
* `type` - (Required) The type of the record * the record `value` - (Required) The value of the record; its usage
* `value` - (Required) The value of the record; its usage
will depend on the `type` (see below) will depend on the `type` (see below)
* `ttl` - (Integer, Optional) The TTL of the record * `ttl` - (Integer, Optional) The TTL of the record `gtdLocation` - (String,
Optional) The GTD Location of the record on Global Traffic Director enabled
domains; Unless GTD is enabled this should either be omitted or set to
"DEFAULT"
Additional arguments are listed below under DNS Record Types. Additional arguments are listed below under DNS Record Types.
@ -117,6 +120,7 @@ The following attributes are exported:
* `value` - The value of the record * `value` - The value of the record
`type` (see below) `type` (see below)
* `ttl` - The TTL of the record * `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 - Additional fields may also be exported by some record types -
see DNS Record Types. see DNS Record Types.
@ -141,6 +145,7 @@ resource "dme_record" "testa" {
type = "A" type = "A"
value = "1.1.1.1" value = "1.1.1.1"
ttl = 1000 ttl = 1000
gtdLocation = "DEFAULT"
} }
# CNAME record # CNAME record