{"action":"created","comment":{"url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/pulls/comments/63998742","id":63998742,"diff_hunk":"@@ -41,28 +43,32 @@ class Configuration(object):\n     \"\"\"\n \n     def __init__(self, config_file):\n-        # TODO(mtakaki#1|2016-04-28): Accept overriding settings using environment\n-        # variables so we have a more docker-friendly approach.\n         self.logger = logging.getLogger('cachet_url_monitor.configuration.Configuration')\n         self.config_file = config_file\n         self.data = load(file(self.config_file, 'r'))\n \n         # We need to validate the configuration is correct and then validate the component actually exists.\n         self.validate()\n-        self.headers = {'X-Cachet-Token': self.data['cachet']['token']}\n-        self.status = self.get_current_status(self.data['cachet']['component_id'])\n \n-        self.logger.info('Monitoring URL: %s %s' %\n-                         (self.data['endpoint']['method'], self.data['endpoint']['url']))\n-        self.expectations = [Expectaction.create(expectation) for expectation\n-                             in self.data['endpoint']['expectation']]\n+        self.headers = {'X-Cachet-Token': os.environ.get('CACHET_TOKEN') or self.data['cachet']['token']}\n+\n+        self.endpoint_method = os.environ.get('ENDPOINT_METHOD') or self.data['endpoint']['method']\n+        self.endpoint_url = os.environ.get('ENDPOINT_URL') or self.data['endpoint']['url']\n+        self.endpoint_timeout = os.environ.get('ENDPOINT_TIMEOUT') or self.data['endpoint'].get('timeout')\n+\n+        self.api_url = os.environ.get('CACHET_API_URL') or self.data['cachet']['api_url']\n+        self.component_id = os.environ.get('CACHET_COMPONENT_ID') or self.data['cachet']['component_id']\n+        self.metric_id = os.environ.get('CACHET_METRIC_ID') or self.data['cachet'].get('metric_id')\n+\n+        self.status = self.get_current_status(self.api_url, self.component_id, self.headers)\n+\n+        self.logger.info('Monitoring URL: %s %s' % (self.endpoint_method, self.endpoint_url))\n+        self.expectations = [Expectaction.create(expectation) for expectation in self.data['endpoint']['expectation']]\n         for expectation in self.expectations:\n             self.logger.info('Registered expectation: %s' % (expectation,))\n \n-    def get_current_status(self, component_id):\n-        get_status_request = requests.get(\n-            '%s/components/%d' % (self.data['cachet']['api_url'], self.data['cachet']['component_id']),\n-            headers=self.headers)\n+    def get_current_status(self, endpoint_url, component_id, headers):","path":"cachet_url_monitor/configuration.py","position":55,"original_position":55,"commit_id":"a3a91edadcd82f443cacba94b5868cfc2370b2d3","original_commit_id":"a3a91edadcd82f443cacba94b5868cfc2370b2d3","user":{"login":"mtakaki","id":6954433,"avatar_url":"https://avatars.githubusercontent.com/u/6954433?v=3","gravatar_id":"","url":"https://api.github.com/users/mtakaki","html_url":"https://github.com/mtakaki","followers_url":"https://api.github.com/users/mtakaki/followers","following_url":"https://api.github.com/users/mtakaki/following{/other_user}","gists_url":"https://api.github.com/users/mtakaki/gists{/gist_id}","starred_url":"https://api.github.com/users/mtakaki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mtakaki/subscriptions","organizations_url":"https://api.github.com/users/mtakaki/orgs","repos_url":"https://api.github.com/users/mtakaki/repos","events_url":"https://api.github.com/users/mtakaki/events{/privacy}","received_events_url":"https://api.github.com/users/mtakaki/received_events","type":"User","site_admin":false},"body":"![Codacy](https://www.codacy.com/assets/images/favicon.png) Issue found: [Method could be a function](https://www.codacy.com/app/mitsuotakaki/cachet-url-monitor/file/2604776702/issues/source?bid=3273968&fileBranchId=3309351#l70)","created_at":"2016-05-20T06:57:21Z","updated_at":"2016-05-20T06:57:21Z","html_url":"https://github.com/mtakaki/cachet-url-monitor/pull/8#discussion_r63998742","pull_request_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/pulls/8","_links":{"self":{"href":"https://api.github.com/repos/mtakaki/cachet-url-monitor/pulls/comments/63998742"},"html":{"href":"https://github.com/mtakaki/cachet-url-monitor/pull/8#discussion_r63998742"},"pull_request":{"href":"https://api.github.com/repos/mtakaki/cachet-url-monitor/pulls/8"}}},"pull_request":{"url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/pulls/8","id":70808263,"html_url":"https://github.com/mtakaki/cachet-url-monitor/pull/8","diff_url":"https://github.com/mtakaki/cachet-url-monitor/pull/8.diff","patch_url":"https://github.com/mtakaki/cachet-url-monitor/pull/8.patch","issue_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/issues/8","number":8,"state":"open","locked":false,"title":"Adding support to overriding some of the configuration through environment variables.","user":{"login":"mtakaki","id":6954433,"avatar_url":"https://avatars.githubusercontent.com/u/6954433?v=3","gravatar_id":"","url":"https://api.github.com/users/mtakaki","html_url":"https://github.com/mtakaki","followers_url":"https://api.github.com/users/mtakaki/followers","following_url":"https://api.github.com/users/mtakaki/following{/other_user}","gists_url":"https://api.github.com/users/mtakaki/gists{/gist_id}","starred_url":"https://api.github.com/users/mtakaki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mtakaki/subscriptions","organizations_url":"https://api.github.com/users/mtakaki/orgs","repos_url":"https://api.github.com/users/mtakaki/repos","events_url":"https://api.github.com/users/mtakaki/events{/privacy}","received_events_url":"https://api.github.com/users/mtakaki/received_events","type":"User","site_admin":false},"body":"Adding the capability of overriding the following configuration:\r\n\r\n- endpoint\r\n    - method\r\n    - url\r\n    - timeout\r\n- cachet\r\n    - api_url\r\n    - component_id\r\n    - metric_id\r\n\r\nStill missing add more unit test to ensure it works fine.","created_at":"2016-05-20T06:43:48Z","updated_at":"2016-05-20T06:57:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a220455c0c4a7a96ff913951654d528515bf4093","assignee":{"login":"gaga0929","id":10603188,"avatar_url":"https://avatars.githubusercontent.com/u/10603188?v=3","gravatar_id":"","url":"https://api.github.com/users/gaga0929","html_url":"https://github.com/gaga0929","followers_url":"https://api.github.com/users/gaga0929/followers","following_url":"https://api.github.com/users/gaga0929/following{/other_user}","gists_url":"https://api.github.com/users/gaga0929/gists{/gist_id}","starred_url":"https://api.github.com/users/gaga0929/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gaga0929/subscriptions","organizations_url":"https://api.github.com/users/gaga0929/orgs","repos_url":"https://api.github.com/users/gaga0929/repos","events_url":"https://api.github.com/users/gaga0929/events{/privacy}","received_events_url":"https://api.github.com/users/gaga0929/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/milestones/2","html_url":"https://github.com/mtakaki/cachet-url-monitor/milestones/0.3","labels_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/milestones/2/labels","id":1746806,"number":2,"title":"0.3","description":"","creator":{"login":"mtakaki","id":6954433,"avatar_url":"https://avatars.githubusercontent.com/u/6954433?v=3","gravatar_id":"","url":"https://api.github.com/users/mtakaki","html_url":"https://github.com/mtakaki","followers_url":"https://api.github.com/users/mtakaki/followers","following_url":"https://api.github.com/users/mtakaki/following{/other_user}","gists_url":"https://api.github.com/users/mtakaki/gists{/gist_id}","starred_url":"https://api.github.com/users/mtakaki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mtakaki/subscriptions","organizations_url":"https://api.github.com/users/mtakaki/orgs","repos_url":"https://api.github.com/users/mtakaki/repos","events_url":"https://api.github.com/users/mtakaki/events{/privacy}","received_events_url":"https://api.github.com/users/mtakaki/received_events","type":"User","site_admin":false},"open_issues":2,"closed_issues":1,"state":"open","created_at":"2016-05-04T07:24:25Z","updated_at":"2016-05-20T06:51:13Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/pulls/8/commits","review_comments_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/pulls/8/comments","review_comment_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/issues/8/comments","statuses_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/statuses/a3a91edadcd82f443cacba94b5868cfc2370b2d3","head":{"label":"mtakaki:mtakaki_1_allow_overriding_through_env_var","ref":"mtakaki_1_allow_overriding_through_env_var","sha":"a3a91edadcd82f443cacba94b5868cfc2370b2d3","user":{"login":"mtakaki","id":6954433,"avatar_url":"https://avatars.githubusercontent.com/u/6954433?v=3","gravatar_id":"","url":"https://api.github.com/users/mtakaki","html_url":"https://github.com/mtakaki","followers_url":"https://api.github.com/users/mtakaki/followers","following_url":"https://api.github.com/users/mtakaki/following{/other_user}","gists_url":"https://api.github.com/users/mtakaki/gists{/gist_id}","starred_url":"https://api.github.com/users/mtakaki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mtakaki/subscriptions","organizations_url":"https://api.github.com/users/mtakaki/orgs","repos_url":"https://api.github.com/users/mtakaki/repos","events_url":"https://api.github.com/users/mtakaki/events{/privacy}","received_events_url":"https://api.github.com/users/mtakaki/received_events","type":"User","site_admin":false},"repo":{"id":57282188,"name":"cachet-url-monitor","full_name":"mtakaki/cachet-url-monitor","owner":{"login":"mtakaki","id":6954433,"avatar_url":"https://avatars.githubusercontent.com/u/6954433?v=3","gravatar_id":"","url":"https://api.github.com/users/mtakaki","html_url":"https://github.com/mtakaki","followers_url":"https://api.github.com/users/mtakaki/followers","following_url":"https://api.github.com/users/mtakaki/following{/other_user}","gists_url":"https://api.github.com/users/mtakaki/gists{/gist_id}","starred_url":"https://api.github.com/users/mtakaki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mtakaki/subscriptions","organizations_url":"https://api.github.com/users/mtakaki/orgs","repos_url":"https://api.github.com/users/mtakaki/repos","events_url":"https://api.github.com/users/mtakaki/events{/privacy}","received_events_url":"https://api.github.com/users/mtakaki/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mtakaki/cachet-url-monitor","description":"URL monitor plugin for cachethq.io","fork":false,"url":"https://api.github.com/repos/mtakaki/cachet-url-monitor","forks_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/forks","keys_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/teams","hooks_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/hooks","issue_events_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/issues/events{/number}","events_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/events","assignees_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/assignees{/user}","branches_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/branches{/branch}","tags_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/tags","blobs_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/git/refs{/sha}","trees_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/statuses/{sha}","languages_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/languages","stargazers_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/stargazers","contributors_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/contributors","subscribers_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/subscribers","subscription_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/subscription","commits_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/commits{/sha}","git_commits_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/git/commits{/sha}","comments_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/comments{/number}","issue_comment_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/issues/comments{/number}","contents_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/contents/{+path}","compare_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/merges","archive_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/downloads","issues_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/issues{/number}","pulls_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/pulls{/number}","milestones_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/milestones{/number}","notifications_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/labels{/name}","releases_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/releases{/id}","deployments_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/deployments","created_at":"2016-04-28T07:57:40Z","updated_at":"2016-04-29T22:36:43Z","pushed_at":"2016-05-20T06:43:49Z","git_url":"git://github.com/mtakaki/cachet-url-monitor.git","ssh_url":"git@github.com:mtakaki/cachet-url-monitor.git","clone_url":"https://github.com/mtakaki/cachet-url-monitor.git","svn_url":"https://github.com/mtakaki/cachet-url-monitor","homepage":null,"size":51,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":3,"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"base":{"label":"mtakaki:master","ref":"master","sha":"2c01d8eb30e7b773132c10814b64b0f428f4229d","user":{"login":"mtakaki","id":6954433,"avatar_url":"https://avatars.githubusercontent.com/u/6954433?v=3","gravatar_id":"","url":"https://api.github.com/users/mtakaki","html_url":"https://github.com/mtakaki","followers_url":"https://api.github.com/users/mtakaki/followers","following_url":"https://api.github.com/users/mtakaki/following{/other_user}","gists_url":"https://api.github.com/users/mtakaki/gists{/gist_id}","starred_url":"https://api.github.com/users/mtakaki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mtakaki/subscriptions","organizations_url":"https://api.github.com/users/mtakaki/orgs","repos_url":"https://api.github.com/users/mtakaki/repos","events_url":"https://api.github.com/users/mtakaki/events{/privacy}","received_events_url":"https://api.github.com/users/mtakaki/received_events","type":"User","site_admin":false},"repo":{"id":57282188,"name":"cachet-url-monitor","full_name":"mtakaki/cachet-url-monitor","owner":{"login":"mtakaki","id":6954433,"avatar_url":"https://avatars.githubusercontent.com/u/6954433?v=3","gravatar_id":"","url":"https://api.github.com/users/mtakaki","html_url":"https://github.com/mtakaki","followers_url":"https://api.github.com/users/mtakaki/followers","following_url":"https://api.github.com/users/mtakaki/following{/other_user}","gists_url":"https://api.github.com/users/mtakaki/gists{/gist_id}","starred_url":"https://api.github.com/users/mtakaki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mtakaki/subscriptions","organizations_url":"https://api.github.com/users/mtakaki/orgs","repos_url":"https://api.github.com/users/mtakaki/repos","events_url":"https://api.github.com/users/mtakaki/events{/privacy}","received_events_url":"https://api.github.com/users/mtakaki/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mtakaki/cachet-url-monitor","description":"URL monitor plugin for cachethq.io","fork":false,"url":"https://api.github.com/repos/mtakaki/cachet-url-monitor","forks_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/forks","keys_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/teams","hooks_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/hooks","issue_events_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/issues/events{/number}","events_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/events","assignees_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/assignees{/user}","branches_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/branches{/branch}","tags_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/tags","blobs_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/git/refs{/sha}","trees_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/statuses/{sha}","languages_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/languages","stargazers_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/stargazers","contributors_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/contributors","subscribers_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/subscribers","subscription_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/subscription","commits_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/commits{/sha}","git_commits_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/git/commits{/sha}","comments_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/comments{/number}","issue_comment_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/issues/comments{/number}","contents_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/contents/{+path}","compare_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/merges","archive_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/downloads","issues_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/issues{/number}","pulls_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/pulls{/number}","milestones_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/milestones{/number}","notifications_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/labels{/name}","releases_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/releases{/id}","deployments_url":"https://api.github.com/repos/mtakaki/cachet-url-monitor/deployments","created_at":"2016-04-28T07:57:40Z","updated_at":"2016-04-29T22:36:43Z","pushed_at":"2016-05-20T06:43:49Z","git_url":"git://github.com/mtakaki/cachet-url-monitor.git","ssh_url":"git@github.com:mtakaki/cachet-url-monitor.git","clone_url":"https://github.com/mtakaki/cachet-url-monitor.git","svn_url":"https://github.com/mtakaki/cachet-url-monitor","homepage":null,"size":51,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":3,"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mtakaki/cachet-url-monitor/pulls/8"},"html":{"href":"https://github.com/mtakaki/cachet-url-monitor/pull/8"},"issue":{"href":"https://api.github.com/repos/mtakaki/cachet-url-monitor/issues/8"},"comments":{"href":"https://api.github.com/repos/mtakaki/cachet-url-monitor/issues/8/comments"},"review_comments":{"href":"https://api.github.com/repos/mtakaki/cachet-url-monitor/pulls/8/comments"},"review_comment":{"href":"https://api.github.com/repos/mtakaki/cachet-url-monitor/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mtakaki/cachet-url-monitor/pulls/8/commits"},"statuses":{"href":"https://api.github.com/repos/mtakaki/cachet-url-monitor/statuses/a3a91edadcd82f443cacba94b5868cfc2370b2d3"}}}}
{"actor":{"display_login":"mtakaki"}}