mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2025-10-14 19:31:00 +02:00
Merge pull request #594 from elordahl/names
AWS provider: Properly check suitable domains
This commit is contained in:
commit
2e4778fac8
@ -449,7 +449,7 @@ func suitableZones(hostname string, zones map[string]*route53.HostedZone) []*rou
|
|||||||
var publicZone *route53.HostedZone
|
var publicZone *route53.HostedZone
|
||||||
|
|
||||||
for _, z := range zones {
|
for _, z := range zones {
|
||||||
if strings.HasSuffix(hostname, aws.StringValue(z.Name)) {
|
if aws.StringValue(z.Name) == hostname || strings.HasSuffix(hostname, "."+aws.StringValue(z.Name)) {
|
||||||
if z.Config == nil || !aws.BoolValue(z.Config.PrivateZone) {
|
if z.Config == nil || !aws.BoolValue(z.Config.PrivateZone) {
|
||||||
// Only select the best matching public zone
|
// Only select the best matching public zone
|
||||||
if publicZone == nil || len(aws.StringValue(z.Name)) > len(aws.StringValue(publicZone.Name)) {
|
if publicZone == nil || len(aws.StringValue(z.Name)) > len(aws.StringValue(publicZone.Name)) {
|
||||||
|
@ -783,6 +783,12 @@ func TestAWSSuitableZones(t *testing.T) {
|
|||||||
}{
|
}{
|
||||||
{"foo.bar.example.org.", []*route53.HostedZone{zones["example-org-private"], zones["bar-example-org-private"], zones["bar-example-org"]}},
|
{"foo.bar.example.org.", []*route53.HostedZone{zones["example-org-private"], zones["bar-example-org-private"], zones["bar-example-org"]}},
|
||||||
{"foo.example.org.", []*route53.HostedZone{zones["example-org-private"], zones["example-org"]}},
|
{"foo.example.org.", []*route53.HostedZone{zones["example-org-private"], zones["example-org"]}},
|
||||||
|
|
||||||
|
// bar.example.org is NOT suitable
|
||||||
|
{"foobar.example.org.", []*route53.HostedZone{zones["example-org-private"], zones["example-org"]}},
|
||||||
|
|
||||||
|
// all matching private zones are suitable (i'm not sure why)
|
||||||
|
{"bar.example.org.", []*route53.HostedZone{zones["example-org-private"], zones["bar-example-org-private"], zones["bar-example-org"]}},
|
||||||
{"foo.kubernetes.io.", nil},
|
{"foo.kubernetes.io.", nil},
|
||||||
} {
|
} {
|
||||||
suitableZones := suitableZones(tc.hostname, zones)
|
suitableZones := suitableZones(tc.hostname, zones)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user