Merge branch 'master' of github.com:hashicorp/terraform

This commit is contained in:
stack72 2017-04-21 12:52:22 +03:00
commit 82293bf59e
No known key found for this signature in database
GPG Key ID: 8619A619B085CB16
2 changed files with 76 additions and 13 deletions

View File

@ -29,7 +29,7 @@ func TestAccRecord_basic(t *testing.T) {
testAccCheckRecordUseClientSubnet(&record, true), testAccCheckRecordUseClientSubnet(&record, true),
testAccCheckRecordRegionName(&record, []string{"cal"}), testAccCheckRecordRegionName(&record, []string{"cal"}),
// testAccCheckRecordAnswerMetaWeight(&record, 10), // testAccCheckRecordAnswerMetaWeight(&record, 10),
testAccCheckRecordAnswerRdata(&record, "test1.terraform-record-test.io"), testAccCheckRecordAnswerRdata(&record, 0, "test1.terraform-record-test.io"),
), ),
}, },
}, },
@ -52,7 +52,7 @@ func TestAccRecord_updated(t *testing.T) {
testAccCheckRecordUseClientSubnet(&record, true), testAccCheckRecordUseClientSubnet(&record, true),
testAccCheckRecordRegionName(&record, []string{"cal"}), testAccCheckRecordRegionName(&record, []string{"cal"}),
// testAccCheckRecordAnswerMetaWeight(&record, 10), // testAccCheckRecordAnswerMetaWeight(&record, 10),
testAccCheckRecordAnswerRdata(&record, "test1.terraform-record-test.io"), testAccCheckRecordAnswerRdata(&record, 0, "test1.terraform-record-test.io"),
), ),
}, },
resource.TestStep{ resource.TestStep{
@ -64,7 +64,7 @@ func TestAccRecord_updated(t *testing.T) {
testAccCheckRecordUseClientSubnet(&record, false), testAccCheckRecordUseClientSubnet(&record, false),
testAccCheckRecordRegionName(&record, []string{"ny", "wa"}), testAccCheckRecordRegionName(&record, []string{"ny", "wa"}),
// testAccCheckRecordAnswerMetaWeight(&record, 5), // testAccCheckRecordAnswerMetaWeight(&record, 5),
testAccCheckRecordAnswerRdata(&record, "test2.terraform-record-test.io"), testAccCheckRecordAnswerRdata(&record, 0, "test2.terraform-record-test.io"),
), ),
}, },
}, },
@ -85,7 +85,31 @@ func TestAccRecord_SPF(t *testing.T) {
testAccCheckRecordDomain(&record, "terraform-record-test.io"), testAccCheckRecordDomain(&record, "terraform-record-test.io"),
testAccCheckRecordTTL(&record, 86400), testAccCheckRecordTTL(&record, 86400),
testAccCheckRecordUseClientSubnet(&record, true), testAccCheckRecordUseClientSubnet(&record, true),
testAccCheckRecordAnswerRdata(&record, "v=DKIM1; k=rsa; p=XXXXXXXX"), testAccCheckRecordAnswerRdata(&record, 0, "v=DKIM1; k=rsa; p=XXXXXXXX"),
),
},
},
})
}
func TestAccRecord_SRV(t *testing.T) {
var record dns.Record
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckRecordDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccRecordSRV,
Check: resource.ComposeTestCheckFunc(
testAccCheckRecordExists("ns1_record.srv", &record),
testAccCheckRecordDomain(&record, "_some-server._tcp.terraform-record-test.io"),
testAccCheckRecordTTL(&record, 86400),
testAccCheckRecordUseClientSubnet(&record, true),
testAccCheckRecordAnswerRdata(&record, 0, "10"),
testAccCheckRecordAnswerRdata(&record, 1, "0"),
testAccCheckRecordAnswerRdata(&record, 2, "2380"),
testAccCheckRecordAnswerRdata(&record, 3, "node-1.terraform-record-test.io"),
), ),
}, },
}, },
@ -206,12 +230,12 @@ func testAccCheckRecordAnswerMetaWeight(r *dns.Record, expected float64) resourc
} }
} }
func testAccCheckRecordAnswerRdata(r *dns.Record, expected string) resource.TestCheckFunc { func testAccCheckRecordAnswerRdata(r *dns.Record, idx int, expected string) resource.TestCheckFunc {
return func(s *terraform.State) error { return func(s *terraform.State) error {
recordAnswer := r.Answers[0] recordAnswer := r.Answers[0]
recordAnswerString := recordAnswer.Rdata[0] recordAnswerString := recordAnswer.Rdata[idx]
if recordAnswerString != expected { if recordAnswerString != expected {
return fmt.Errorf("Answers[0].Rdata[0]: got: %#v want: %#v", recordAnswerString, expected) return fmt.Errorf("Answers[0].Rdata[%d]: got: %#v want: %#v", idx, recordAnswerString, expected)
} }
return nil return nil
} }
@ -335,3 +359,20 @@ resource "ns1_zone" "test" {
zone = "terraform-record-test.io" zone = "terraform-record-test.io"
} }
` `
const testAccRecordSRV = `
resource "ns1_record" "srv" {
zone = "${ns1_zone.test.zone}"
domain = "_some-server._tcp.${ns1_zone.test.zone}"
type = "SRV"
ttl = 86400
use_client_subnet = "true"
answers {
answer = "10 0 2380 node-1.${ns1_zone.test.zone}"
}
}
resource "ns1_zone" "test" {
zone = "terraform-record-test.io"
}
`

View File

@ -51,16 +51,38 @@ The following arguments are supported:
* `ttl` - (Optional) The records' time to live. * `ttl` - (Optional) The records' time to live.
* `link` - (Optional) The target record to link to. This means this record is a 'linked' record, and it inherits all properties from its target. * `link` - (Optional) The target record to link to. This means this record is a 'linked' record, and it inherits all properties from its target.
* `use_client_subnet` - (Optional) Whether to use EDNS client subnet data when available(in filter chain). * `use_client_subnet` - (Optional) Whether to use EDNS client subnet data when available(in filter chain).
* `answers` - (Optional) The list of the RDATA fields for the records' specified type. Answers are documented below. * `answers` - (Optional) One or more NS1 answers for the records' specified type. Answers are documented below.
* `filters` - (Optional) The list of NS1 filters for the record(order matters). Filters are documented below. * `filters` - (Optional) One or more NS1 filters for the record(order matters). Filters are documented below.
Answers (`answers`) support the following: Answers (`answers`) support the following:
* `answer` - (Required) List of RDATA fields. * `answer` - (Required) Space delimited string of RDATA fields dependent on the record type.
* `region` - (Required) The region this answer belongs to.
A:
answer = "1.2.3.4"
CNAME:
answer = "www.example.com"
MX:
answer = "5 mail.example.com"
SRV:
answer = "10 0 2380 node-1.example.com"
SPF:
answer = "v=DKIM1; k=rsa; p=XXXXXXXX"
* `region` - (Optional) The region(or group) name that this answer belongs to.
Filters (`filters`) support the following: Filters (`filters`) support the following:
* `filter` - (Required) The type of filter. * `filter` - (Required) The type of filter.
* `disabled` - (Required) Determines whether the filter is applied in the filter chain. * `disabled` - (Optional) Determines whether the filter is applied in the filter chain.
* `config` - (Required) The filters' configuration. Simple key/value pairs determined by the filter type. * `config` - (Optional) The filters' configuration. Simple key/value pairs determined by the filter type.