Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AWS provider: Properly check suitable domains #594

Merged
merged 1 commit into from
Jun 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's explained in #356 (comment) and your test matches the one above, so I think it's fine how you did it. Can you move this test line to first block so it's easier to see?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Submitted in new PR since this was merged. Feel free to close if no longer needed. #608

{"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