Skip to content

Commit

Permalink
AWS provider: Properly check suitable domains
Browse files Browse the repository at this point in the history
  • Loading branch information
elordahl committed Jun 14, 2018
1 parent f458b37 commit 2896444
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion provider/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,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)) {
Expand Down
6 changes: 6 additions & 0 deletions provider/aws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,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)
Expand Down

0 comments on commit 2896444

Please sign in to comment.