GitHub PullRequestReviewCommentEvent at 2014-07-11 07:08:11
Repository: juju
Actor: dimitern
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/juju/juju/pulls/comments/14809099","id":14809099,"diff_hunk":"@@ -0,0 +1,277 @@\n+// Copyright 2014 Canonical Ltd.\n+// Licensed under the AGPLv3, see LICENCE file for details.\n+\n+package networker\n+\n+import (\n+\t\"fmt\"\n+\t\"io/ioutil\"\n+\t\"os\"\n+\t\"regexp\"\n+\t\"syscall\"\n+)\n+\n+// Patches for testing.\n+var (\n+\tConfigDirName    = \"/etc/network\"\n+\tConfigFileName   = ConfigDirName + \"/interfaces\"\n+\tConfigSubDirName = ConfigDirName + \"/interfaces.d\"\n+)\n+\n+// Indication what to do with file.\n+const (\n+\tDoNone = iota\n+\tDoWrite\n+\tDoRemove\n+)\n+\n+// file struct contains information about config file, its contents and what to do to apply changes.\n+type ConfigFile struct {\n+\tFileName string\n+\tData     string\n+\tOp       int\n+}\n+\n+// ConfigFiles contains information about all configuration files. Key for map is\n+// - empty string for /etc/netwotk/interfaces file\n+// - interface name for /etc/netwotk/interfaces.d/*.cfg files\n+// - \"#\" + filename for the other files\n+type ConfigFiles map[string]*ConfigFile\n+\n+func (cf ConfigFiles) readOneFile(key, fileName string) error {\n+\tcf[key] = &ConfigFile{FileName: fileName}\n+\tdata, err := ioutil.ReadFile(fileName)\n+\tif err != nil {\n+\t\tlogger.Errorf(\"failed to read file %q: %v\", fileName, err)\n+\t\treturn err\n+\t}\n+\tcf[key].Data = string(data)\n+\treturn nil\n+}\n+\n+func (cf *ConfigFiles) ReadAll() error {\n+\tvar err error\n+\t*cf = ConfigFiles{}\n+\terr = cf.readOneFile(\"\", ConfigFileName)\n+\tif err != nil {\n+\t\treturn err\n+\t}\n+\n+\t// Read /etc/network/interfaces.d/*.cfg files.\n+\tfiles, err := ioutil.ReadDir(ConfigSubDirName)\n+\tif err != nil {\n+\t\tif e, ok := err.(*os.PathError); ok && e.Err == syscall.ENOENT {\n+\t\t\t// ignore error when directory is absent\n+\t\t} else {\n+\t\t\tlogger.Errorf(\"failed to read directory %q: %#v\\n\", ConfigSubDirName, err)\n+\t\t\treturn err\n+\t\t}\n+\t}\n+\tfor _, info := range files {\n+\t\tname := info.Name()\n+\t\tif info.Mode().IsRegular() && len(name) > 4 && name[len(name)-4:] == \".cfg\" {","path":"worker/networker/configfiles.go","position":72,"original_position":72,"commit_id":"963ce5007ff21586988d91bcab5d6e2fe1246d05","original_commit_id":"963ce5007ff21586988d91bcab5d6e2fe1246d05","user":{"login":"dimitern","id":619986,"avatar_url":"https://avatars.githubusercontent.com/u/619986?","gravatar_id":"6889e0065cf206ab0e4b3873576b5026","url":"https://api.github.com/users/dimitern","html_url":"https://github.com/dimitern","followers_url":"https://api.github.com/users/dimitern/followers","following_url":"https://api.github.com/users/dimitern/following{/other_user}","gists_url":"https://api.github.com/users/dimitern/gists{/gist_id}","starred_url":"https://api.github.com/users/dimitern/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dimitern/subscriptions","organizations_url":"https://api.github.com/users/dimitern/orgs","repos_url":"https://api.github.com/users/dimitern/repos","events_url":"https://api.github.com/users/dimitern/events{/privacy}","received_events_url":"https://api.github.com/users/dimitern/received_events","type":"User","site_admin":false},"body":"Please, use filepath.Ext(name) == \".cfg\" here instead.","created_at":"2014-07-11T07:08:11Z","updated_at":"2014-07-11T07:08:11Z","html_url":"https://github.com/juju/juju/pull/121#discussion_r14809099","pull_request_url":"https://api.github.com/repos/juju/juju/pulls/121","_links":{"self":{"href":"https://api.github.com/repos/juju/juju/pulls/comments/14809099"},"html":{"href":"https://github.com/juju/juju/pull/121#discussion_r14809099"},"pull_request":{"href":"https://api.github.com/repos/juju/juju/pulls/121"}}},"pull_request":{"url":"https://api.github.com/repos/juju/juju/pulls/121","id":17286546,"html_url":"https://github.com/juju/juju/pull/121","diff_url":"https://github.com/juju/juju/pull/121.diff","patch_url":"https://github.com/juju/juju/pull/121.patch","issue_url":"https://api.github.com/repos/juju/juju/issues/121","number":121,"state":"open","title":"WIP: networker skeleton","user":{"login":"klyachin","id":2362623,"avatar_url":"https://avatars.githubusercontent.com/u/2362623?","gravatar_id":"43c0954922b5c6ed7f94913f2178affa","url":"https://api.github.com/users/klyachin","html_url":"https://github.com/klyachin","followers_url":"https://api.github.com/users/klyachin/followers","following_url":"https://api.github.com/users/klyachin/following{/other_user}","gists_url":"https://api.github.com/users/klyachin/gists{/gist_id}","starred_url":"https://api.github.com/users/klyachin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/klyachin/subscriptions","organizations_url":"https://api.github.com/users/klyachin/orgs","repos_url":"https://api.github.com/users/klyachin/repos","events_url":"https://api.github.com/users/klyachin/events{/privacy}","received_events_url":"https://api.github.com/users/klyachin/received_events","type":"User","site_admin":false},"body":"worker: networker skeleton\r\n\r\nThis RP is a skeleton for the future networker based on StringsWorker\r\n\r\nContinue of work from: https://github.com/juju/juju/pull/86","created_at":"2014-06-18T10:51:28Z","updated_at":"2014-07-11T07:08:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3fb7ca7c3d57e70eb70194458567797a6e6cd270","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/juju/juju/pulls/121/commits","review_comments_url":"https://api.github.com/repos/juju/juju/pulls/121/comments","review_comment_url":"https://api.github.com/repos/juju/juju/pulls/comments/{number}","comments_url":"https://api.github.com/repos/juju/juju/issues/121/comments","statuses_url":"https://api.github.com/repos/juju/juju/statuses/963ce5007ff21586988d91bcab5d6e2fe1246d05","head":{"label":"klyachin:120-networker","ref":"120-networker","sha":"963ce5007ff21586988d91bcab5d6e2fe1246d05","user":{"login":"klyachin","id":2362623,"avatar_url":"https://avatars.githubusercontent.com/u/2362623?","gravatar_id":"43c0954922b5c6ed7f94913f2178affa","url":"https://api.github.com/users/klyachin","html_url":"https://github.com/klyachin","followers_url":"https://api.github.com/users/klyachin/followers","following_url":"https://api.github.com/users/klyachin/following{/other_user}","gists_url":"https://api.github.com/users/klyachin/gists{/gist_id}","starred_url":"https://api.github.com/users/klyachin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/klyachin/subscriptions","organizations_url":"https://api.github.com/users/klyachin/orgs","repos_url":"https://api.github.com/users/klyachin/repos","events_url":"https://api.github.com/users/klyachin/events{/privacy}","received_events_url":"https://api.github.com/users/klyachin/received_events","type":"User","site_admin":false},"repo":{"id":20490649,"name":"juju","full_name":"klyachin/juju","owner":{"login":"klyachin","id":2362623,"avatar_url":"https://avatars.githubusercontent.com/u/2362623?","gravatar_id":"43c0954922b5c6ed7f94913f2178affa","url":"https://api.github.com/users/klyachin","html_url":"https://github.com/klyachin","followers_url":"https://api.github.com/users/klyachin/followers","following_url":"https://api.github.com/users/klyachin/following{/other_user}","gists_url":"https://api.github.com/users/klyachin/gists{/gist_id}","starred_url":"https://api.github.com/users/klyachin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/klyachin/subscriptions","organizations_url":"https://api.github.com/users/klyachin/orgs","repos_url":"https://api.github.com/users/klyachin/repos","events_url":"https://api.github.com/users/klyachin/events{/privacy}","received_events_url":"https://api.github.com/users/klyachin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/klyachin/juju","description":"juju is devops distilled","fork":true,"url":"https://api.github.com/repos/klyachin/juju","forks_url":"https://api.github.com/repos/klyachin/juju/forks","keys_url":"https://api.github.com/repos/klyachin/juju/keys{/key_id}","collaborators_url":"https://api.github.com/repos/klyachin/juju/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/klyachin/juju/teams","hooks_url":"https://api.github.com/repos/klyachin/juju/hooks","issue_events_url":"https://api.github.com/repos/klyachin/juju/issues/events{/number}","events_url":"https://api.github.com/repos/klyachin/juju/events","assignees_url":"https://api.github.com/repos/klyachin/juju/assignees{/user}","branches_url":"https://api.github.com/repos/klyachin/juju/branches{/branch}","tags_url":"https://api.github.com/repos/klyachin/juju/tags","blobs_url":"https://api.github.com/repos/klyachin/juju/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/klyachin/juju/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/klyachin/juju/git/refs{/sha}","trees_url":"https://api.github.com/repos/klyachin/juju/git/trees{/sha}","statuses_url":"https://api.github.com/repos/klyachin/juju/statuses/{sha}","languages_url":"https://api.github.com/repos/klyachin/juju/languages","stargazers_url":"https://api.github.com/repos/klyachin/juju/stargazers","contributors_url":"https://api.github.com/repos/klyachin/juju/contributors","subscribers_url":"https://api.github.com/repos/klyachin/juju/subscribers","subscription_url":"https://api.github.com/repos/klyachin/juju/subscription","commits_url":"https://api.github.com/repos/klyachin/juju/commits{/sha}","git_commits_url":"https://api.github.com/repos/klyachin/juju/git/commits{/sha}","comments_url":"https://api.github.com/repos/klyachin/juju/comments{/number}","issue_comment_url":"https://api.github.com/repos/klyachin/juju/issues/comments/{number}","contents_url":"https://api.github.com/repos/klyachin/juju/contents/{+path}","compare_url":"https://api.github.com/repos/klyachin/juju/compare/{base}...{head}","merges_url":"https://api.github.com/repos/klyachin/juju/merges","archive_url":"https://api.github.com/repos/klyachin/juju/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/klyachin/juju/downloads","issues_url":"https://api.github.com/repos/klyachin/juju/issues{/number}","pulls_url":"https://api.github.com/repos/klyachin/juju/pulls{/number}","milestones_url":"https://api.github.com/repos/klyachin/juju/milestones{/number}","notifications_url":"https://api.github.com/repos/klyachin/juju/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/klyachin/juju/labels{/name}","releases_url":"https://api.github.com/repos/klyachin/juju/releases{/id}","created_at":"2014-06-04T16:13:13Z","updated_at":"2014-06-26T10:45:38Z","pushed_at":"2014-07-11T06:50:50Z","git_url":"git://github.com/klyachin/juju.git","ssh_url":"git@github.com:klyachin/juju.git","clone_url":"https://github.com/klyachin/juju.git","svn_url":"https://github.com/klyachin/juju","homepage":"juju.ubuntu.com","size":24834,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"juju:master","ref":"master","sha":"1a00392d214953ab9a2718ad6338f96fe660147f","user":{"login":"juju","id":4604548,"avatar_url":"https://avatars.githubusercontent.com/u/4604548?","gravatar_id":"b095d1e26e5705abe0ad2de7d87aac2e","url":"https://api.github.com/users/juju","html_url":"https://github.com/juju","followers_url":"https://api.github.com/users/juju/followers","following_url":"https://api.github.com/users/juju/following{/other_user}","gists_url":"https://api.github.com/users/juju/gists{/gist_id}","starred_url":"https://api.github.com/users/juju/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juju/subscriptions","organizations_url":"https://api.github.com/users/juju/orgs","repos_url":"https://api.github.com/users/juju/repos","events_url":"https://api.github.com/users/juju/events{/privacy}","received_events_url":"https://api.github.com/users/juju/received_events","type":"Organization","site_admin":false},"repo":{"id":20445947,"name":"juju","full_name":"juju/juju","owner":{"login":"juju","id":4604548,"avatar_url":"https://avatars.githubusercontent.com/u/4604548?","gravatar_id":"b095d1e26e5705abe0ad2de7d87aac2e","url":"https://api.github.com/users/juju","html_url":"https://github.com/juju","followers_url":"https://api.github.com/users/juju/followers","following_url":"https://api.github.com/users/juju/following{/other_user}","gists_url":"https://api.github.com/users/juju/gists{/gist_id}","starred_url":"https://api.github.com/users/juju/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juju/subscriptions","organizations_url":"https://api.github.com/users/juju/orgs","repos_url":"https://api.github.com/users/juju/repos","events_url":"https://api.github.com/users/juju/events{/privacy}","received_events_url":"https://api.github.com/users/juju/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/juju/juju","description":"juju is devops distilled","fork":false,"url":"https://api.github.com/repos/juju/juju","forks_url":"https://api.github.com/repos/juju/juju/forks","keys_url":"https://api.github.com/repos/juju/juju/keys{/key_id}","collaborators_url":"https://api.github.com/repos/juju/juju/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/juju/juju/teams","hooks_url":"https://api.github.com/repos/juju/juju/hooks","issue_events_url":"https://api.github.com/repos/juju/juju/issues/events{/number}","events_url":"https://api.github.com/repos/juju/juju/events","assignees_url":"https://api.github.com/repos/juju/juju/assignees{/user}","branches_url":"https://api.github.com/repos/juju/juju/branches{/branch}","tags_url":"https://api.github.com/repos/juju/juju/tags","blobs_url":"https://api.github.com/repos/juju/juju/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/juju/juju/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/juju/juju/git/refs{/sha}","trees_url":"https://api.github.com/repos/juju/juju/git/trees{/sha}","statuses_url":"https://api.github.com/repos/juju/juju/statuses/{sha}","languages_url":"https://api.github.com/repos/juju/juju/languages","stargazers_url":"https://api.github.com/repos/juju/juju/stargazers","contributors_url":"https://api.github.com/repos/juju/juju/contributors","subscribers_url":"https://api.github.com/repos/juju/juju/subscribers","subscription_url":"https://api.github.com/repos/juju/juju/subscription","commits_url":"https://api.github.com/repos/juju/juju/commits{/sha}","git_commits_url":"https://api.github.com/repos/juju/juju/git/commits{/sha}","comments_url":"https://api.github.com/repos/juju/juju/comments{/number}","issue_comment_url":"https://api.github.com/repos/juju/juju/issues/comments/{number}","contents_url":"https://api.github.com/repos/juju/juju/contents/{+path}","compare_url":"https://api.github.com/repos/juju/juju/compare/{base}...{head}","merges_url":"https://api.github.com/repos/juju/juju/merges","archive_url":"https://api.github.com/repos/juju/juju/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/juju/juju/downloads","issues_url":"https://api.github.com/repos/juju/juju/issues{/number}","pulls_url":"https://api.github.com/repos/juju/juju/pulls{/number}","milestones_url":"https://api.github.com/repos/juju/juju/milestones{/number}","notifications_url":"https://api.github.com/repos/juju/juju/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/juju/juju/labels{/name}","releases_url":"https://api.github.com/repos/juju/juju/releases{/id}","created_at":"2014-06-03T14:28:10Z","updated_at":"2014-07-06T23:12:43Z","pushed_at":"2014-07-10T17:04:34Z","git_url":"git://github.com/juju/juju.git","ssh_url":"git@github.com:juju/juju.git","clone_url":"https://github.com/juju/juju.git","svn_url":"https://github.com/juju/juju","homepage":"juju.ubuntu.com","size":30930,"stargazers_count":176,"watchers_count":176,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":41,"mirror_url":null,"open_issues_count":39,"forks":41,"open_issues":39,"watchers":176,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/juju/juju/pulls/121"},"html":{"href":"https://github.com/juju/juju/pull/121"},"issue":{"href":"https://api.github.com/repos/juju/juju/issues/121"},"comments":{"href":"https://api.github.com/repos/juju/juju/issues/121/comments"},"review_comments":{"href":"https://api.github.com/repos/juju/juju/pulls/121/comments"},"review_comment":{"href":"https://api.github.com/repos/juju/juju/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/juju/juju/pulls/121/commits"},"statuses":{"href":"https://api.github.com/repos/juju/juju/statuses/963ce5007ff21586988d91bcab5d6e2fe1246d05"}}}}