{"action":"created","comment":{"url":"https://api.github.com/repos/coredns/coredns/pulls/comments/223878504","pull_request_review_id":163115597,"id":223878504,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyMzg3ODUwNA==","diff_hunk":"@@ -30,28 +30,44 @@ type Route53 struct {\n \tupstream  *upstream.Upstream\n \n \tzMu   sync.RWMutex\n-\tzones map[string]*zone\n+\tzones zones\n }\n \n type zone struct {\n-\tid string\n-\tz  *file.Zone\n+\tid  string\n+\tz   *file.Zone\n+\tdns string\n+}\n+\n+type zones map[string][]*zone\n+\n+// AddHostedZone adds a new hosted zone into the zones map.\n+// Returns true if the zone introduces a new domain.\n+func (z zones) AddHostedZone(hz *zone) (newDomain bool) {\n+\thz.z = file.NewZone(hz.dns, \"\")\n+\tif _, ok := z[hz.dns]; !ok {\n+\t\tz[hz.dns] = make([]*zone, 0)\n+\t\tnewDomain = true\n+\t}\n+\tz[hz.dns] = append(z[hz.dns], hz)\n+\treturn\n }\n \n // New returns new *Route53.\n-func New(ctx context.Context, c route53iface.Route53API, keys map[string]string, up *upstream.Upstream) (*Route53, error) {\n-\tzones := make(map[string]*zone, len(keys))\n+func New(ctx context.Context, c route53iface.Route53API, keys []*zone, up *upstream.Upstream) (*Route53, error) {\n+\tzones := make(zones, len(keys))\n \tzoneNames := make([]string, 0, len(keys))\n-\tfor dns, id := range keys {\n+\tfor _, hostedZone := range keys {\n \t\t_, err := c.ListHostedZonesByNameWithContext(ctx, &route53.ListHostedZonesByNameInput{\n-\t\t\tDNSName:      aws.String(dns),\n-\t\t\tHostedZoneId: aws.String(id),\n+\t\t\tDNSName:      aws.String(hostedZone.dns),\n+\t\t\tHostedZoneId: aws.String(hostedZone.id),\n \t\t})\n \t\tif err != nil {\n \t\t\treturn nil, err\n \t\t}\n-\t\tzones[dns] = &zone{id: id, z: file.NewZone(dns, \"\")}\n-\t\tzoneNames = append(zoneNames, dns)\n+\t\tif zones.AddHostedZone(hostedZone) {","path":"plugin/route53/route53.go","position":null,"original_position":49,"commit_id":"673c9263cdb45e4b862b050eee47644304475a90","original_commit_id":"dbdace535d41d27196f23550224911f7c651d215","user":{"login":"canthefason","id":73976,"node_id":"MDQ6VXNlcjczOTc2","avatar_url":"https://avatars3.githubusercontent.com/u/73976?v=4","gravatar_id":"","url":"https://api.github.com/users/canthefason","html_url":"https://github.com/canthefason","followers_url":"https://api.github.com/users/canthefason/followers","following_url":"https://api.github.com/users/canthefason/following{/other_user}","gists_url":"https://api.github.com/users/canthefason/gists{/gist_id}","starred_url":"https://api.github.com/users/canthefason/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/canthefason/subscriptions","organizations_url":"https://api.github.com/users/canthefason/orgs","repos_url":"https://api.github.com/users/canthefason/repos","events_url":"https://api.github.com/users/canthefason/events{/privacy}","received_events_url":"https://api.github.com/users/canthefason/received_events","type":"User","site_admin":false},"body":"just inverting was my initial thought, however it was ending up with losing the hosted zone ordering.\r\n\r\nI changed the structure to a map[string][]string instead where the key is domain name and the value is a list of hosted zone ids. Let me know how you feel about it.","created_at":"2018-10-09T22:00:14Z","updated_at":"2018-10-09T22:00:14Z","html_url":"https://github.com/coredns/coredns/pull/2160#discussion_r223878504","pull_request_url":"https://api.github.com/repos/coredns/coredns/pulls/2160","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/coredns/coredns/pulls/comments/223878504"},"html":{"href":"https://github.com/coredns/coredns/pull/2160#discussion_r223878504"},"pull_request":{"href":"https://api.github.com/repos/coredns/coredns/pulls/2160"}},"in_reply_to_id":223755884},"pull_request":{"url":"https://api.github.com/repos/coredns/coredns/pulls/2160","id":220472927,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIwNDcyOTI3","html_url":"https://github.com/coredns/coredns/pull/2160","diff_url":"https://github.com/coredns/coredns/pull/2160.diff","patch_url":"https://github.com/coredns/coredns/pull/2160.patch","issue_url":"https://api.github.com/repos/coredns/coredns/issues/2160","number":2160,"state":"open","locked":false,"title":"plugin/route53: add split zone support","user":{"login":"canthefason","id":73976,"node_id":"MDQ6VXNlcjczOTc2","avatar_url":"https://avatars3.githubusercontent.com/u/73976?v=4","gravatar_id":"","url":"https://api.github.com/users/canthefason","html_url":"https://github.com/canthefason","followers_url":"https://api.github.com/users/canthefason/followers","following_url":"https://api.github.com/users/canthefason/following{/other_user}","gists_url":"https://api.github.com/users/canthefason/gists{/gist_id}","starred_url":"https://api.github.com/users/canthefason/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/canthefason/subscriptions","organizations_url":"https://api.github.com/users/canthefason/orgs","repos_url":"https://api.github.com/users/canthefason/repos","events_url":"https://api.github.com/users/canthefason/events{/privacy}","received_events_url":"https://api.github.com/users/canthefason/received_events","type":"User","site_admin":false},"body":"This PR introduces split-zone support for the Route53 plugin. \r\n\r\nWhen there are multiple hosted zones with overlapping domains (private vs. public hosted zone), previously this plugin was returning a zone conflict error. Now CoreDNS looks up for the queried domain starting from the leftmost hosted zone and moves forward to the next one until it finds a matching resource record. When there's no matching resource record, CoreDNS responds with the rightmost hosted zones SOA record.\r\n\r\nSigned-off-by: Can Yucel <jon.yucel@getcruise.com>","created_at":"2018-10-04T18:23:50Z","updated_at":"2018-10-09T22:00:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2f954ca694d9494fe9bdd34ab42886351a2aa26e","assignee":null,"assignees":[],"requested_reviewers":[{"login":"yongtang","id":6932348,"node_id":"MDQ6VXNlcjY5MzIzNDg=","avatar_url":"https://avatars0.githubusercontent.com/u/6932348?v=4","gravatar_id":"","url":"https://api.github.com/users/yongtang","html_url":"https://github.com/yongtang","followers_url":"https://api.github.com/users/yongtang/followers","following_url":"https://api.github.com/users/yongtang/following{/other_user}","gists_url":"https://api.github.com/users/yongtang/gists{/gist_id}","starred_url":"https://api.github.com/users/yongtang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yongtang/subscriptions","organizations_url":"https://api.github.com/users/yongtang/orgs","repos_url":"https://api.github.com/users/yongtang/repos","events_url":"https://api.github.com/users/yongtang/events{/privacy}","received_events_url":"https://api.github.com/users/yongtang/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/coredns/coredns/pulls/2160/commits","review_comments_url":"https://api.github.com/repos/coredns/coredns/pulls/2160/comments","review_comment_url":"https://api.github.com/repos/coredns/coredns/pulls/comments{/number}","comments_url":"https://api.github.com/repos/coredns/coredns/issues/2160/comments","statuses_url":"https://api.github.com/repos/coredns/coredns/statuses/673c9263cdb45e4b862b050eee47644304475a90","head":{"label":"canthefason:split-zone","ref":"split-zone","sha":"673c9263cdb45e4b862b050eee47644304475a90","user":{"login":"canthefason","id":73976,"node_id":"MDQ6VXNlcjczOTc2","avatar_url":"https://avatars3.githubusercontent.com/u/73976?v=4","gravatar_id":"","url":"https://api.github.com/users/canthefason","html_url":"https://github.com/canthefason","followers_url":"https://api.github.com/users/canthefason/followers","following_url":"https://api.github.com/users/canthefason/following{/other_user}","gists_url":"https://api.github.com/users/canthefason/gists{/gist_id}","starred_url":"https://api.github.com/users/canthefason/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/canthefason/subscriptions","organizations_url":"https://api.github.com/users/canthefason/orgs","repos_url":"https://api.github.com/users/canthefason/repos","events_url":"https://api.github.com/users/canthefason/events{/privacy}","received_events_url":"https://api.github.com/users/canthefason/received_events","type":"User","site_admin":false},"repo":{"id":147896783,"node_id":"MDEwOlJlcG9zaXRvcnkxNDc4OTY3ODM=","name":"coredns","full_name":"canthefason/coredns","private":false,"owner":{"login":"canthefason","id":73976,"node_id":"MDQ6VXNlcjczOTc2","avatar_url":"https://avatars3.githubusercontent.com/u/73976?v=4","gravatar_id":"","url":"https://api.github.com/users/canthefason","html_url":"https://github.com/canthefason","followers_url":"https://api.github.com/users/canthefason/followers","following_url":"https://api.github.com/users/canthefason/following{/other_user}","gists_url":"https://api.github.com/users/canthefason/gists{/gist_id}","starred_url":"https://api.github.com/users/canthefason/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/canthefason/subscriptions","organizations_url":"https://api.github.com/users/canthefason/orgs","repos_url":"https://api.github.com/users/canthefason/repos","events_url":"https://api.github.com/users/canthefason/events{/privacy}","received_events_url":"https://api.github.com/users/canthefason/received_events","type":"User","site_admin":false},"html_url":"https://github.com/canthefason/coredns","description":"CoreDNS is a DNS server that chains plugins","fork":true,"url":"https://api.github.com/repos/canthefason/coredns","forks_url":"https://api.github.com/repos/canthefason/coredns/forks","keys_url":"https://api.github.com/repos/canthefason/coredns/keys{/key_id}","collaborators_url":"https://api.github.com/repos/canthefason/coredns/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/canthefason/coredns/teams","hooks_url":"https://api.github.com/repos/canthefason/coredns/hooks","issue_events_url":"https://api.github.com/repos/canthefason/coredns/issues/events{/number}","events_url":"https://api.github.com/repos/canthefason/coredns/events","assignees_url":"https://api.github.com/repos/canthefason/coredns/assignees{/user}","branches_url":"https://api.github.com/repos/canthefason/coredns/branches{/branch}","tags_url":"https://api.github.com/repos/canthefason/coredns/tags","blobs_url":"https://api.github.com/repos/canthefason/coredns/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/canthefason/coredns/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/canthefason/coredns/git/refs{/sha}","trees_url":"https://api.github.com/repos/canthefason/coredns/git/trees{/sha}","statuses_url":"https://api.github.com/repos/canthefason/coredns/statuses/{sha}","languages_url":"https://api.github.com/repos/canthefason/coredns/languages","stargazers_url":"https://api.github.com/repos/canthefason/coredns/stargazers","contributors_url":"https://api.github.com/repos/canthefason/coredns/contributors","subscribers_url":"https://api.github.com/repos/canthefason/coredns/subscribers","subscription_url":"https://api.github.com/repos/canthefason/coredns/subscription","commits_url":"https://api.github.com/repos/canthefason/coredns/commits{/sha}","git_commits_url":"https://api.github.com/repos/canthefason/coredns/git/commits{/sha}","comments_url":"https://api.github.com/repos/canthefason/coredns/comments{/number}","issue_comment_url":"https://api.github.com/repos/canthefason/coredns/issues/comments{/number}","contents_url":"https://api.github.com/repos/canthefason/coredns/contents/{+path}","compare_url":"https://api.github.com/repos/canthefason/coredns/compare/{base}...{head}","merges_url":"https://api.github.com/repos/canthefason/coredns/merges","archive_url":"https://api.github.com/repos/canthefason/coredns/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/canthefason/coredns/downloads","issues_url":"https://api.github.com/repos/canthefason/coredns/issues{/number}","pulls_url":"https://api.github.com/repos/canthefason/coredns/pulls{/number}","milestones_url":"https://api.github.com/repos/canthefason/coredns/milestones{/number}","notifications_url":"https://api.github.com/repos/canthefason/coredns/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/canthefason/coredns/labels{/name}","releases_url":"https://api.github.com/repos/canthefason/coredns/releases{/id}","deployments_url":"https://api.github.com/repos/canthefason/coredns/deployments","created_at":"2018-09-08T03:15:19Z","updated_at":"2018-09-08T03:15:23Z","pushed_at":"2018-10-09T21:57:32Z","git_url":"git://github.com/canthefason/coredns.git","ssh_url":"git@github.com:canthefason/coredns.git","clone_url":"https://github.com/canthefason/coredns.git","svn_url":"https://github.com/canthefason/coredns","homepage":"https://coredns.io","size":86881,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"coredns:master","ref":"master","sha":"1018a8267a05ea0a3bd968b471706604b875aeaf","user":{"login":"coredns","id":21110084,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIxMTEwMDg0","avatar_url":"https://avatars3.githubusercontent.com/u/21110084?v=4","gravatar_id":"","url":"https://api.github.com/users/coredns","html_url":"https://github.com/coredns","followers_url":"https://api.github.com/users/coredns/followers","following_url":"https://api.github.com/users/coredns/following{/other_user}","gists_url":"https://api.github.com/users/coredns/gists{/gist_id}","starred_url":"https://api.github.com/users/coredns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coredns/subscriptions","organizations_url":"https://api.github.com/users/coredns/orgs","repos_url":"https://api.github.com/users/coredns/repos","events_url":"https://api.github.com/users/coredns/events{/privacy}","received_events_url":"https://api.github.com/users/coredns/received_events","type":"Organization","site_admin":false},"repo":{"id":54230994,"node_id":"MDEwOlJlcG9zaXRvcnk1NDIzMDk5NA==","name":"coredns","full_name":"coredns/coredns","private":false,"owner":{"login":"coredns","id":21110084,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIxMTEwMDg0","avatar_url":"https://avatars3.githubusercontent.com/u/21110084?v=4","gravatar_id":"","url":"https://api.github.com/users/coredns","html_url":"https://github.com/coredns","followers_url":"https://api.github.com/users/coredns/followers","following_url":"https://api.github.com/users/coredns/following{/other_user}","gists_url":"https://api.github.com/users/coredns/gists{/gist_id}","starred_url":"https://api.github.com/users/coredns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coredns/subscriptions","organizations_url":"https://api.github.com/users/coredns/orgs","repos_url":"https://api.github.com/users/coredns/repos","events_url":"https://api.github.com/users/coredns/events{/privacy}","received_events_url":"https://api.github.com/users/coredns/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/coredns/coredns","description":"CoreDNS is a DNS server that chains plugins","fork":false,"url":"https://api.github.com/repos/coredns/coredns","forks_url":"https://api.github.com/repos/coredns/coredns/forks","keys_url":"https://api.github.com/repos/coredns/coredns/keys{/key_id}","collaborators_url":"https://api.github.com/repos/coredns/coredns/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/coredns/coredns/teams","hooks_url":"https://api.github.com/repos/coredns/coredns/hooks","issue_events_url":"https://api.github.com/repos/coredns/coredns/issues/events{/number}","events_url":"https://api.github.com/repos/coredns/coredns/events","assignees_url":"https://api.github.com/repos/coredns/coredns/assignees{/user}","branches_url":"https://api.github.com/repos/coredns/coredns/branches{/branch}","tags_url":"https://api.github.com/repos/coredns/coredns/tags","blobs_url":"https://api.github.com/repos/coredns/coredns/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/coredns/coredns/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/coredns/coredns/git/refs{/sha}","trees_url":"https://api.github.com/repos/coredns/coredns/git/trees{/sha}","statuses_url":"https://api.github.com/repos/coredns/coredns/statuses/{sha}","languages_url":"https://api.github.com/repos/coredns/coredns/languages","stargazers_url":"https://api.github.com/repos/coredns/coredns/stargazers","contributors_url":"https://api.github.com/repos/coredns/coredns/contributors","subscribers_url":"https://api.github.com/repos/coredns/coredns/subscribers","subscription_url":"https://api.github.com/repos/coredns/coredns/subscription","commits_url":"https://api.github.com/repos/coredns/coredns/commits{/sha}","git_commits_url":"https://api.github.com/repos/coredns/coredns/git/commits{/sha}","comments_url":"https://api.github.com/repos/coredns/coredns/comments{/number}","issue_comment_url":"https://api.github.com/repos/coredns/coredns/issues/comments{/number}","contents_url":"https://api.github.com/repos/coredns/coredns/contents/{+path}","compare_url":"https://api.github.com/repos/coredns/coredns/compare/{base}...{head}","merges_url":"https://api.github.com/repos/coredns/coredns/merges","archive_url":"https://api.github.com/repos/coredns/coredns/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/coredns/coredns/downloads","issues_url":"https://api.github.com/repos/coredns/coredns/issues{/number}","pulls_url":"https://api.github.com/repos/coredns/coredns/pulls{/number}","milestones_url":"https://api.github.com/repos/coredns/coredns/milestones{/number}","notifications_url":"https://api.github.com/repos/coredns/coredns/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/coredns/coredns/labels{/name}","releases_url":"https://api.github.com/repos/coredns/coredns/releases{/id}","deployments_url":"https://api.github.com/repos/coredns/coredns/deployments","created_at":"2016-03-18T20:56:45Z","updated_at":"2018-10-09T20:56:32Z","pushed_at":"2018-10-09T21:57:33Z","git_url":"git://github.com/coredns/coredns.git","ssh_url":"git@github.com:coredns/coredns.git","clone_url":"https://github.com/coredns/coredns.git","svn_url":"https://github.com/coredns/coredns","homepage":"https://coredns.io","size":87148,"stargazers_count":2654,"watchers_count":2654,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":406,"mirror_url":null,"archived":false,"open_issues_count":98,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":406,"open_issues":98,"watchers":2654,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/coredns/coredns/pulls/2160"},"html":{"href":"https://github.com/coredns/coredns/pull/2160"},"issue":{"href":"https://api.github.com/repos/coredns/coredns/issues/2160"},"comments":{"href":"https://api.github.com/repos/coredns/coredns/issues/2160/comments"},"review_comments":{"href":"https://api.github.com/repos/coredns/coredns/pulls/2160/comments"},"review_comment":{"href":"https://api.github.com/repos/coredns/coredns/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/coredns/coredns/pulls/2160/commits"},"statuses":{"href":"https://api.github.com/repos/coredns/coredns/statuses/673c9263cdb45e4b862b050eee47644304475a90"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"canthefason"}}