{"action":"created","comment":{"url":"https://api.github.com/repos/open-craft/opencraft/pulls/comments/92725379","pull_request_review_id":13237019,"id":92725379,"diff_hunk":"@@ -61,15 +64,38 @@ def client_zone(self):\n         \"\"\"\n         return self.client.domain.zone\n \n+    def _populate_zone_id_cache(self):\n+        \"\"\"\n+        Populate the internal zone ID cache with all domains in the current Gandi account.\n+        \"\"\"\n+        self._zone_id_cache = {}\n+        for domain_dict in self.client.domain.list(self.api_key):\n+            domain = domain_dict['fqdn'].lower()\n+            self._zone_id_cache[domain] = self.client.domain.info(self.api_key, domain)['zone_id']\n+\n+    def split_domain_name(self, domain):\n+        \"\"\"\n+        Split the given domain name in the registered domain and the subdomain.\n+        \"\"\"\n+        if self._zone_id_cache is None:\n+            self._populate_zone_id_cache()\n+        labels = domain.lower().split('.')\n+        for split_index in range(len(labels) - 1):\n+            registered_domain = '.'.join(labels[split_index:])\n+            if registered_domain in self._zone_id_cache:\n+                subdomain = '.'.join(labels[:split_index]) or '@'\n+                return subdomain, registered_domain\n+        raise ValueError(\n+            'The given domain name does not match any domain registered in the Gandi account.'\n+        )","path":"instance/gandi.py","position":44,"original_position":44,"commit_id":"a19ed4fecd2733c900407d5e5995385a61bcf296","original_commit_id":"a19ed4fecd2733c900407d5e5995385a61bcf296","user":{"login":"pomegranited","id":7556571,"avatar_url":"https://avatars.githubusercontent.com/u/7556571?v=3","gravatar_id":"","url":"https://api.github.com/users/pomegranited","html_url":"https://github.com/pomegranited","followers_url":"https://api.github.com/users/pomegranited/followers","following_url":"https://api.github.com/users/pomegranited/following{/other_user}","gists_url":"https://api.github.com/users/pomegranited/gists{/gist_id}","starred_url":"https://api.github.com/users/pomegranited/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pomegranited/subscriptions","organizations_url":"https://api.github.com/users/pomegranited/orgs","repos_url":"https://api.github.com/users/pomegranited/repos","events_url":"https://api.github.com/users/pomegranited/events{/privacy}","received_events_url":"https://api.github.com/users/pomegranited/received_events","type":"User","site_admin":false},"body":"Can this `ValueError` be caught and displayed to the GUI?","created_at":"2016-12-15T23:45:19Z","updated_at":"2016-12-16T00:04:37Z","html_url":"https://github.com/open-craft/opencraft/pull/163#discussion_r92725379","pull_request_url":"https://api.github.com/repos/open-craft/opencraft/pulls/163","_links":{"self":{"href":"https://api.github.com/repos/open-craft/opencraft/pulls/comments/92725379"},"html":{"href":"https://github.com/open-craft/opencraft/pull/163#discussion_r92725379"},"pull_request":{"href":"https://api.github.com/repos/open-craft/opencraft/pulls/163"}}},"pull_request":{"url":"https://api.github.com/repos/open-craft/opencraft/pulls/163","id":97849470,"html_url":"https://github.com/open-craft/opencraft/pull/163","diff_url":"https://github.com/open-craft/opencraft/pull/163.diff","patch_url":"https://github.com/open-craft/opencraft/pull/163.patch","issue_url":"https://api.github.com/repos/open-craft/opencraft/issues/163","number":163,"state":"open","locked":false,"title":"Use the Gandi API to determine the registered domain.","user":{"login":"smarnach","id":249196,"avatar_url":"https://avatars.githubusercontent.com/u/249196?v=3","gravatar_id":"","url":"https://api.github.com/users/smarnach","html_url":"https://github.com/smarnach","followers_url":"https://api.github.com/users/smarnach/followers","following_url":"https://api.github.com/users/smarnach/following{/other_user}","gists_url":"https://api.github.com/users/smarnach/gists{/gist_id}","starred_url":"https://api.github.com/users/smarnach/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smarnach/subscriptions","organizations_url":"https://api.github.com/users/smarnach/orgs","repos_url":"https://api.github.com/users/smarnach/repos","events_url":"https://api.github.com/users/smarnach/events{/privacy}","received_events_url":"https://api.github.com/users/smarnach/received_events","type":"User","site_admin":false},"body":"This PR removes the dependency on the `tldextract` library and uses information from the Gandi API instead to determine the registered domain name.  This is necessary since `tldextract` depends on the Public Suffix List, so it will return incorrect results for `opencraft.hosting`, which is now on the Public Suffix List.\r\n\r\nThe new version requests the list of all domains registered with the Gandi account when first needed, and builds a dictionary of all zone IDs.  For setting a DNS record, we now pass in the fully qualified domain name and search the dictionary for a matching suffix.  If none is found, we raise an exception, since this means the domain name can't be set using the configured Gandi account.\r\n\r\nThis PR also introduces a fake implementation of the Gandi API which behaves similar to the actual Gandi API (at least similar enough).  It provides stricter tests that can concentrate more on desired outcomes at the same time.  (I actually didn't expect this to become as complex as it did.)\r\n\r\nThis is tested by the integration tests.  For manual testing, you can try this on stage, which uses the domain `stage.opencraft.hosting`, so it's a good test candidate.  You only need to _start_ provisioning an instance, since DNS records are set early in the process.","created_at":"2016-12-13T22:30:36Z","updated_at":"2016-12-16T00:04:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"57b3ddca4fba09d3a8b3f1cf717a83a0199945f5","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/open-craft/opencraft/pulls/163/commits","review_comments_url":"https://api.github.com/repos/open-craft/opencraft/pulls/163/comments","review_comment_url":"https://api.github.com/repos/open-craft/opencraft/pulls/comments{/number}","comments_url":"https://api.github.com/repos/open-craft/opencraft/issues/163/comments","statuses_url":"https://api.github.com/repos/open-craft/opencraft/statuses/a19ed4fecd2733c900407d5e5995385a61bcf296","head":{"label":"open-craft:smarnach/remove-tldextract","ref":"smarnach/remove-tldextract","sha":"a19ed4fecd2733c900407d5e5995385a61bcf296","user":{"login":"open-craft","id":7414786,"avatar_url":"https://avatars.githubusercontent.com/u/7414786?v=3","gravatar_id":"","url":"https://api.github.com/users/open-craft","html_url":"https://github.com/open-craft","followers_url":"https://api.github.com/users/open-craft/followers","following_url":"https://api.github.com/users/open-craft/following{/other_user}","gists_url":"https://api.github.com/users/open-craft/gists{/gist_id}","starred_url":"https://api.github.com/users/open-craft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/open-craft/subscriptions","organizations_url":"https://api.github.com/users/open-craft/orgs","repos_url":"https://api.github.com/users/open-craft/repos","events_url":"https://api.github.com/users/open-craft/events{/privacy}","received_events_url":"https://api.github.com/users/open-craft/received_events","type":"Organization","site_admin":false},"repo":{"id":40447973,"name":"opencraft","full_name":"open-craft/opencraft","owner":{"login":"open-craft","id":7414786,"avatar_url":"https://avatars.githubusercontent.com/u/7414786?v=3","gravatar_id":"","url":"https://api.github.com/users/open-craft","html_url":"https://github.com/open-craft","followers_url":"https://api.github.com/users/open-craft/followers","following_url":"https://api.github.com/users/open-craft/following{/other_user}","gists_url":"https://api.github.com/users/open-craft/gists{/gist_id}","starred_url":"https://api.github.com/users/open-craft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/open-craft/subscriptions","organizations_url":"https://api.github.com/users/open-craft/orgs","repos_url":"https://api.github.com/users/open-craft/repos","events_url":"https://api.github.com/users/open-craft/events{/privacy}","received_events_url":"https://api.github.com/users/open-craft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/open-craft/opencraft","description":"OpenCraft - Instance Manager","fork":false,"url":"https://api.github.com/repos/open-craft/opencraft","forks_url":"https://api.github.com/repos/open-craft/opencraft/forks","keys_url":"https://api.github.com/repos/open-craft/opencraft/keys{/key_id}","collaborators_url":"https://api.github.com/repos/open-craft/opencraft/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/open-craft/opencraft/teams","hooks_url":"https://api.github.com/repos/open-craft/opencraft/hooks","issue_events_url":"https://api.github.com/repos/open-craft/opencraft/issues/events{/number}","events_url":"https://api.github.com/repos/open-craft/opencraft/events","assignees_url":"https://api.github.com/repos/open-craft/opencraft/assignees{/user}","branches_url":"https://api.github.com/repos/open-craft/opencraft/branches{/branch}","tags_url":"https://api.github.com/repos/open-craft/opencraft/tags","blobs_url":"https://api.github.com/repos/open-craft/opencraft/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/open-craft/opencraft/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/open-craft/opencraft/git/refs{/sha}","trees_url":"https://api.github.com/repos/open-craft/opencraft/git/trees{/sha}","statuses_url":"https://api.github.com/repos/open-craft/opencraft/statuses/{sha}","languages_url":"https://api.github.com/repos/open-craft/opencraft/languages","stargazers_url":"https://api.github.com/repos/open-craft/opencraft/stargazers","contributors_url":"https://api.github.com/repos/open-craft/opencraft/contributors","subscribers_url":"https://api.github.com/repos/open-craft/opencraft/subscribers","subscription_url":"https://api.github.com/repos/open-craft/opencraft/subscription","commits_url":"https://api.github.com/repos/open-craft/opencraft/commits{/sha}","git_commits_url":"https://api.github.com/repos/open-craft/opencraft/git/commits{/sha}","comments_url":"https://api.github.com/repos/open-craft/opencraft/comments{/number}","issue_comment_url":"https://api.github.com/repos/open-craft/opencraft/issues/comments{/number}","contents_url":"https://api.github.com/repos/open-craft/opencraft/contents/{+path}","compare_url":"https://api.github.com/repos/open-craft/opencraft/compare/{base}...{head}","merges_url":"https://api.github.com/repos/open-craft/opencraft/merges","archive_url":"https://api.github.com/repos/open-craft/opencraft/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/open-craft/opencraft/downloads","issues_url":"https://api.github.com/repos/open-craft/opencraft/issues{/number}","pulls_url":"https://api.github.com/repos/open-craft/opencraft/pulls{/number}","milestones_url":"https://api.github.com/repos/open-craft/opencraft/milestones{/number}","notifications_url":"https://api.github.com/repos/open-craft/opencraft/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/open-craft/opencraft/labels{/name}","releases_url":"https://api.github.com/repos/open-craft/opencraft/releases{/id}","deployments_url":"https://api.github.com/repos/open-craft/opencraft/deployments","created_at":"2015-08-09T19:35:05Z","updated_at":"2016-11-10T19:35:43Z","pushed_at":"2016-12-15T14:07:17Z","git_url":"git://github.com/open-craft/opencraft.git","ssh_url":"git@github.com:open-craft/opencraft.git","clone_url":"https://github.com/open-craft/opencraft.git","svn_url":"https://github.com/open-craft/opencraft","homepage":"http://opencraft.hosting","size":2553,"stargazers_count":13,"watchers_count":13,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":8,"forks":8,"open_issues":8,"watchers":13,"default_branch":"master"}},"base":{"label":"open-craft:master","ref":"master","sha":"43961f5c6c52babd3d6c5b94558701c006db817a","user":{"login":"open-craft","id":7414786,"avatar_url":"https://avatars.githubusercontent.com/u/7414786?v=3","gravatar_id":"","url":"https://api.github.com/users/open-craft","html_url":"https://github.com/open-craft","followers_url":"https://api.github.com/users/open-craft/followers","following_url":"https://api.github.com/users/open-craft/following{/other_user}","gists_url":"https://api.github.com/users/open-craft/gists{/gist_id}","starred_url":"https://api.github.com/users/open-craft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/open-craft/subscriptions","organizations_url":"https://api.github.com/users/open-craft/orgs","repos_url":"https://api.github.com/users/open-craft/repos","events_url":"https://api.github.com/users/open-craft/events{/privacy}","received_events_url":"https://api.github.com/users/open-craft/received_events","type":"Organization","site_admin":false},"repo":{"id":40447973,"name":"opencraft","full_name":"open-craft/opencraft","owner":{"login":"open-craft","id":7414786,"avatar_url":"https://avatars.githubusercontent.com/u/7414786?v=3","gravatar_id":"","url":"https://api.github.com/users/open-craft","html_url":"https://github.com/open-craft","followers_url":"https://api.github.com/users/open-craft/followers","following_url":"https://api.github.com/users/open-craft/following{/other_user}","gists_url":"https://api.github.com/users/open-craft/gists{/gist_id}","starred_url":"https://api.github.com/users/open-craft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/open-craft/subscriptions","organizations_url":"https://api.github.com/users/open-craft/orgs","repos_url":"https://api.github.com/users/open-craft/repos","events_url":"https://api.github.com/users/open-craft/events{/privacy}","received_events_url":"https://api.github.com/users/open-craft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/open-craft/opencraft","description":"OpenCraft - Instance Manager","fork":false,"url":"https://api.github.com/repos/open-craft/opencraft","forks_url":"https://api.github.com/repos/open-craft/opencraft/forks","keys_url":"https://api.github.com/repos/open-craft/opencraft/keys{/key_id}","collaborators_url":"https://api.github.com/repos/open-craft/opencraft/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/open-craft/opencraft/teams","hooks_url":"https://api.github.com/repos/open-craft/opencraft/hooks","issue_events_url":"https://api.github.com/repos/open-craft/opencraft/issues/events{/number}","events_url":"https://api.github.com/repos/open-craft/opencraft/events","assignees_url":"https://api.github.com/repos/open-craft/opencraft/assignees{/user}","branches_url":"https://api.github.com/repos/open-craft/opencraft/branches{/branch}","tags_url":"https://api.github.com/repos/open-craft/opencraft/tags","blobs_url":"https://api.github.com/repos/open-craft/opencraft/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/open-craft/opencraft/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/open-craft/opencraft/git/refs{/sha}","trees_url":"https://api.github.com/repos/open-craft/opencraft/git/trees{/sha}","statuses_url":"https://api.github.com/repos/open-craft/opencraft/statuses/{sha}","languages_url":"https://api.github.com/repos/open-craft/opencraft/languages","stargazers_url":"https://api.github.com/repos/open-craft/opencraft/stargazers","contributors_url":"https://api.github.com/repos/open-craft/opencraft/contributors","subscribers_url":"https://api.github.com/repos/open-craft/opencraft/subscribers","subscription_url":"https://api.github.com/repos/open-craft/opencraft/subscription","commits_url":"https://api.github.com/repos/open-craft/opencraft/commits{/sha}","git_commits_url":"https://api.github.com/repos/open-craft/opencraft/git/commits{/sha}","comments_url":"https://api.github.com/repos/open-craft/opencraft/comments{/number}","issue_comment_url":"https://api.github.com/repos/open-craft/opencraft/issues/comments{/number}","contents_url":"https://api.github.com/repos/open-craft/opencraft/contents/{+path}","compare_url":"https://api.github.com/repos/open-craft/opencraft/compare/{base}...{head}","merges_url":"https://api.github.com/repos/open-craft/opencraft/merges","archive_url":"https://api.github.com/repos/open-craft/opencraft/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/open-craft/opencraft/downloads","issues_url":"https://api.github.com/repos/open-craft/opencraft/issues{/number}","pulls_url":"https://api.github.com/repos/open-craft/opencraft/pulls{/number}","milestones_url":"https://api.github.com/repos/open-craft/opencraft/milestones{/number}","notifications_url":"https://api.github.com/repos/open-craft/opencraft/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/open-craft/opencraft/labels{/name}","releases_url":"https://api.github.com/repos/open-craft/opencraft/releases{/id}","deployments_url":"https://api.github.com/repos/open-craft/opencraft/deployments","created_at":"2015-08-09T19:35:05Z","updated_at":"2016-11-10T19:35:43Z","pushed_at":"2016-12-15T14:07:17Z","git_url":"git://github.com/open-craft/opencraft.git","ssh_url":"git@github.com:open-craft/opencraft.git","clone_url":"https://github.com/open-craft/opencraft.git","svn_url":"https://github.com/open-craft/opencraft","homepage":"http://opencraft.hosting","size":2553,"stargazers_count":13,"watchers_count":13,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":8,"forks":8,"open_issues":8,"watchers":13,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/open-craft/opencraft/pulls/163"},"html":{"href":"https://github.com/open-craft/opencraft/pull/163"},"issue":{"href":"https://api.github.com/repos/open-craft/opencraft/issues/163"},"comments":{"href":"https://api.github.com/repos/open-craft/opencraft/issues/163/comments"},"review_comments":{"href":"https://api.github.com/repos/open-craft/opencraft/pulls/163/comments"},"review_comment":{"href":"https://api.github.com/repos/open-craft/opencraft/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/open-craft/opencraft/pulls/163/commits"},"statuses":{"href":"https://api.github.com/repos/open-craft/opencraft/statuses/a19ed4fecd2733c900407d5e5995385a61bcf296"}}}}
{"actor":{"display_login":"pomegranited"}}