mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
* Stable comparison of metadata (#239) Iterating over a map in Go never produces twice the same ordering. Thus when comparing two metadata map with more than one key, the `differ` is always finding differences. To properly compare records metadata, we need to iterate the maps in a deterministic way. Signed-off-by: Brice Figureau <brice@daysofwonder.com> * Support for Route53 ALIAS record type (#239) Route53 ALIAS doesn't behave like a regular ALIAS, and is much more limited as its target can only be some specific AWS resources or another record in the same zone. According to #239, this change adds a new directive R53_ALIAS which implements this specific alias. This record type can only be used with the Route53 provider. This directive usage looks like this: ```js D("example.com", REGISTRAR, DnsProvider("ROUTE53"), R53_ALIAS("foo1", "A", "bar") // record in same zone R53_ALIAS("foo2", "A", "blahblah.elasticloadbalancing.us-west-1.amazonaws.com", R53_ZONE('Z368ELLRRE2KJ0')) // ELB in us-west-1 ``` Unfortunately, Route53 requires indicating the hosted zone id where the target is defined (those are listed in AWS documentation, see the R53_ALIAS documentation for links).
This commit is contained in:
committed by
Tom Limoncelli
parent
2fc55dfdc4
commit
7b8d608019
@@ -107,8 +107,8 @@ func runTests(t *testing.T, prv providers.DNSServiceProvider, domainName string,
|
||||
for _, r := range tst.Records {
|
||||
rc := models.RecordConfig(*r)
|
||||
rc.NameFQDN = dnsutil.AddOrigin(rc.Name, domainName)
|
||||
if rc.Target == "**current-domain**" {
|
||||
rc.Target = domainName + "."
|
||||
if strings.Contains(rc.Target, "**current-domain**") {
|
||||
rc.Target = strings.Replace(rc.Target, "**current-domain**", domainName, 1) + "."
|
||||
}
|
||||
dom.Records = append(dom.Records, &rc)
|
||||
}
|
||||
@@ -216,6 +216,14 @@ func alias(name, target string) *rec {
|
||||
return makeRec(name, target, "ALIAS")
|
||||
}
|
||||
|
||||
func r53alias(name, aliasType, target string) *rec {
|
||||
r := makeRec(name, target, "R53_ALIAS")
|
||||
r.R53Alias = map[string]string{
|
||||
"type": aliasType,
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func ns(name, target string) *rec {
|
||||
return makeRec(name, target, "NS")
|
||||
}
|
||||
@@ -506,5 +514,16 @@ func makeTests(t *testing.T) []*TestCase {
|
||||
tc("Add a new record - ignoring foo", a("bar", "1.2.3.4"), ignore("foo")),
|
||||
)
|
||||
|
||||
// R53_ALIAS
|
||||
if !providers.ProviderHasCabability(*providerToRun, providers.CanUseRoute53Alias) {
|
||||
t.Log("Skipping Route53 ALIAS Tests because provider does not support them")
|
||||
} else {
|
||||
tests = append(tests, tc("Empty"),
|
||||
tc("create dependent records", a("foo", "1.2.3.4"), a("quux", "2.3.4.5")),
|
||||
tc("ALIAS to A record in same zone", a("foo", "1.2.3.4"), a("quux", "2.3.4.5"), r53alias("bar", "A", "foo.**current-domain**")),
|
||||
tc("change it", a("foo", "1.2.3.4"), a("quux", "2.3.4.5"), r53alias("bar", "A", "quux.**current-domain**")),
|
||||
)
|
||||
}
|
||||
|
||||
return tests
|
||||
}
|
||||
|
Reference in New Issue
Block a user