Merge pull request #594 from elordahl/names

AWS provider: Properly check suitable domains
This commit is contained in:
Nick Jüttner 2018-06-20 17:15:46 +02:00 committed by GitHub
commit 2e4778fac8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -449,7 +449,7 @@ func suitableZones(hostname string, zones map[string]*route53.HostedZone) []*rou
var publicZone *route53.HostedZone
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) {
// Only select the best matching public zone
if publicZone == nil || len(aws.StringValue(z.Name)) > len(aws.StringValue(publicZone.Name)) {

View File

@ -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.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},
} {
suitableZones := suitableZones(tc.hostname, zones)