{"action":"created","comment":{"url":"https://api.github.com/repos/kinvolk/mountinfo-graph/pulls/comments/78187930","id":78187930,"diff_hunk":"@@ -0,0 +1,110 @@\n+package main\n+\n+import (\n+\t\"bufio\"\n+\t\"encoding/json\"\n+\t\"fmt\"\n+\t\"log\"\n+\t\"os\"\n+\t\"strings\"\n+)\n+\n+type Node struct {\n+\t*MountInfoLine\n+\tChildren []*Node `json:\"children,omitempty\"`\n+}\n+\n+type MountInfoLine struct {\n+\tMountID        string   `json:\"-\"`\n+\tParentID       string   `json:\"-\"`\n+\tMajorMinor     string   `json:\"-\"`\n+\tRoot           string   `json:\"-\"`\n+\tMountPoint     string   `json:\"name\"`\n+\tMountOptions   string   `json:\"-\"`\n+\tOptionalFields []string `json:\"-\"`\n+\tFileSystemType string   `json:\"-\"`\n+\tMountSource    string   `json:\"-\"`\n+\tSuperOptions   string   `json:\"-\"`\n+}\n+\n+func extractMountinfo(flp string) ([]*MountInfoLine, error) {\n+\tvar mi []*MountInfoLine\n+\n+\tmifl, err := os.Open(flp)\n+\tif err != nil {\n+\t\treturn nil, err\n+\t}\n+\tdefer mifl.Close()\n+\n+\tsc := bufio.NewScanner(mifl)\n+\tfor sc.Scan() {\n+\t\tline := strings.Split(sc.Text(), \" \")\n+\t\tlineLen := len(line)\n+\t\tif lineLen < 9 {\n+\t\t\treturn nil, fmt.Errorf(\"not enough fields in the mountinfo file: %v\", line)\n+\t\t}\n+\t\tmountinfo := &MountInfoLine{\n+\t\t\t// TODO: find a cleaner way of doing this\n+\t\t\tMountID:        line[0],\n+\t\t\tParentID:       line[1],\n+\t\t\tMajorMinor:     line[2],\n+\t\t\tRoot:           line[3],\n+\t\t\tMountPoint:     line[4],\n+\t\t\tMountOptions:   line[5],\n+\t\t\tFileSystemType: line[(lineLen-10)+7],","path":"read-file.go","position":54,"original_position":54,"commit_id":"306ee2a0fda0cd1624fe9da087a96ad6a0997f51","original_commit_id":"306ee2a0fda0cd1624fe9da087a96ad6a0997f51","user":{"login":"LiliC","id":6232346,"avatar_url":"https://avatars.githubusercontent.com/u/6232346?v=3","gravatar_id":"","url":"https://api.github.com/users/LiliC","html_url":"https://github.com/LiliC","followers_url":"https://api.github.com/users/LiliC/followers","following_url":"https://api.github.com/users/LiliC/following{/other_user}","gists_url":"https://api.github.com/users/LiliC/gists{/gist_id}","starred_url":"https://api.github.com/users/LiliC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LiliC/subscriptions","organizations_url":"https://api.github.com/users/LiliC/orgs","repos_url":"https://api.github.com/users/LiliC/repos","events_url":"https://api.github.com/users/LiliC/events{/privacy}","received_events_url":"https://api.github.com/users/LiliC/received_events","type":"User","site_admin":false},"body":"yes will look at a better implementation. Right now I'm calculating based on the number of optional fields and its not the most reliable I guess. ","created_at":"2016-09-09T14:19:36Z","updated_at":"2016-09-09T14:19:36Z","html_url":"https://github.com/kinvolk/mountinfo-graph/pull/1#discussion_r78187930","pull_request_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/kinvolk/mountinfo-graph/pulls/comments/78187930"},"html":{"href":"https://github.com/kinvolk/mountinfo-graph/pull/1#discussion_r78187930"},"pull_request":{"href":"https://api.github.com/repos/kinvolk/mountinfo-graph/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/kinvolk/mountinfo-graph/pulls/1","id":84642246,"html_url":"https://github.com/kinvolk/mountinfo-graph/pull/1","diff_url":"https://github.com/kinvolk/mountinfo-graph/pull/1.diff","patch_url":"https://github.com/kinvolk/mountinfo-graph/pull/1.patch","issue_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/issues/1","number":1,"state":"open","locked":false,"title":"WIP: initial code","user":{"login":"LiliC","id":6232346,"avatar_url":"https://avatars.githubusercontent.com/u/6232346?v=3","gravatar_id":"","url":"https://api.github.com/users/LiliC","html_url":"https://github.com/LiliC","followers_url":"https://api.github.com/users/LiliC/followers","following_url":"https://api.github.com/users/LiliC/following{/other_user}","gists_url":"https://api.github.com/users/LiliC/gists{/gist_id}","starred_url":"https://api.github.com/users/LiliC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LiliC/subscriptions","organizations_url":"https://api.github.com/users/LiliC/orgs","repos_url":"https://api.github.com/users/LiliC/repos","events_url":"https://api.github.com/users/LiliC/events{/privacy}","received_events_url":"https://api.github.com/users/LiliC/received_events","type":"User","site_admin":false},"body":"**What:** Parsing /mountinfo from different mount namespaces and representing the information as a graph using D3.\r\n\r\n**Current state:** it takes a mountinfo file, extracts all the mountinfo fields and creates connections to children. Exports this information to the d3 desired json format.\r\n\r\n\r\nJust asking for initial feedback, if I am going in the right direction. \r\n","created_at":"2016-09-09T12:28:41Z","updated_at":"2016-09-09T14:19:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a7260deeb6a7a6b6c0c6c9d180b829e726118778","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/pulls/1/commits","review_comments_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/pulls/1/comments","review_comment_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/issues/1/comments","statuses_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/statuses/306ee2a0fda0cd1624fe9da087a96ad6a0997f51","head":{"label":"kinvolk:lilic/initial-code","ref":"lilic/initial-code","sha":"306ee2a0fda0cd1624fe9da087a96ad6a0997f51","user":{"login":"kinvolk","id":14073052,"avatar_url":"https://avatars.githubusercontent.com/u/14073052?v=3","gravatar_id":"","url":"https://api.github.com/users/kinvolk","html_url":"https://github.com/kinvolk","followers_url":"https://api.github.com/users/kinvolk/followers","following_url":"https://api.github.com/users/kinvolk/following{/other_user}","gists_url":"https://api.github.com/users/kinvolk/gists{/gist_id}","starred_url":"https://api.github.com/users/kinvolk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kinvolk/subscriptions","organizations_url":"https://api.github.com/users/kinvolk/orgs","repos_url":"https://api.github.com/users/kinvolk/repos","events_url":"https://api.github.com/users/kinvolk/events{/privacy}","received_events_url":"https://api.github.com/users/kinvolk/received_events","type":"Organization","site_admin":false},"repo":{"id":67793304,"name":"mountinfo-graph","full_name":"kinvolk/mountinfo-graph","owner":{"login":"kinvolk","id":14073052,"avatar_url":"https://avatars.githubusercontent.com/u/14073052?v=3","gravatar_id":"","url":"https://api.github.com/users/kinvolk","html_url":"https://github.com/kinvolk","followers_url":"https://api.github.com/users/kinvolk/followers","following_url":"https://api.github.com/users/kinvolk/following{/other_user}","gists_url":"https://api.github.com/users/kinvolk/gists{/gist_id}","starred_url":"https://api.github.com/users/kinvolk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kinvolk/subscriptions","organizations_url":"https://api.github.com/users/kinvolk/orgs","repos_url":"https://api.github.com/users/kinvolk/repos","events_url":"https://api.github.com/users/kinvolk/events{/privacy}","received_events_url":"https://api.github.com/users/kinvolk/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/kinvolk/mountinfo-graph","description":"Generate graph from your mountinfo file","fork":false,"url":"https://api.github.com/repos/kinvolk/mountinfo-graph","forks_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/forks","keys_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/teams","hooks_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/hooks","issue_events_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/issues/events{/number}","events_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/events","assignees_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/assignees{/user}","branches_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/branches{/branch}","tags_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/tags","blobs_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/git/refs{/sha}","trees_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/statuses/{sha}","languages_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/languages","stargazers_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/stargazers","contributors_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/contributors","subscribers_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/subscribers","subscription_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/subscription","commits_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/commits{/sha}","git_commits_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/git/commits{/sha}","comments_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/comments{/number}","issue_comment_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/issues/comments{/number}","contents_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/contents/{+path}","compare_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/merges","archive_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/downloads","issues_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/issues{/number}","pulls_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/pulls{/number}","milestones_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/milestones{/number}","notifications_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/labels{/name}","releases_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/releases{/id}","deployments_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/deployments","created_at":"2016-09-09T11:22:43Z","updated_at":"2016-09-09T11:22:43Z","pushed_at":"2016-09-09T13:52:32Z","git_url":"git://github.com/kinvolk/mountinfo-graph.git","ssh_url":"git@github.com:kinvolk/mountinfo-graph.git","clone_url":"https://github.com/kinvolk/mountinfo-graph.git","svn_url":"https://github.com/kinvolk/mountinfo-graph","homepage":null,"size":5,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"kinvolk:master","ref":"master","sha":"52deae3d5e2494000494a3f484e47ac03a85d744","user":{"login":"kinvolk","id":14073052,"avatar_url":"https://avatars.githubusercontent.com/u/14073052?v=3","gravatar_id":"","url":"https://api.github.com/users/kinvolk","html_url":"https://github.com/kinvolk","followers_url":"https://api.github.com/users/kinvolk/followers","following_url":"https://api.github.com/users/kinvolk/following{/other_user}","gists_url":"https://api.github.com/users/kinvolk/gists{/gist_id}","starred_url":"https://api.github.com/users/kinvolk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kinvolk/subscriptions","organizations_url":"https://api.github.com/users/kinvolk/orgs","repos_url":"https://api.github.com/users/kinvolk/repos","events_url":"https://api.github.com/users/kinvolk/events{/privacy}","received_events_url":"https://api.github.com/users/kinvolk/received_events","type":"Organization","site_admin":false},"repo":{"id":67793304,"name":"mountinfo-graph","full_name":"kinvolk/mountinfo-graph","owner":{"login":"kinvolk","id":14073052,"avatar_url":"https://avatars.githubusercontent.com/u/14073052?v=3","gravatar_id":"","url":"https://api.github.com/users/kinvolk","html_url":"https://github.com/kinvolk","followers_url":"https://api.github.com/users/kinvolk/followers","following_url":"https://api.github.com/users/kinvolk/following{/other_user}","gists_url":"https://api.github.com/users/kinvolk/gists{/gist_id}","starred_url":"https://api.github.com/users/kinvolk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kinvolk/subscriptions","organizations_url":"https://api.github.com/users/kinvolk/orgs","repos_url":"https://api.github.com/users/kinvolk/repos","events_url":"https://api.github.com/users/kinvolk/events{/privacy}","received_events_url":"https://api.github.com/users/kinvolk/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/kinvolk/mountinfo-graph","description":"Generate graph from your mountinfo file","fork":false,"url":"https://api.github.com/repos/kinvolk/mountinfo-graph","forks_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/forks","keys_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/teams","hooks_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/hooks","issue_events_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/issues/events{/number}","events_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/events","assignees_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/assignees{/user}","branches_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/branches{/branch}","tags_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/tags","blobs_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/git/refs{/sha}","trees_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/statuses/{sha}","languages_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/languages","stargazers_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/stargazers","contributors_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/contributors","subscribers_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/subscribers","subscription_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/subscription","commits_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/commits{/sha}","git_commits_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/git/commits{/sha}","comments_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/comments{/number}","issue_comment_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/issues/comments{/number}","contents_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/contents/{+path}","compare_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/merges","archive_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/downloads","issues_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/issues{/number}","pulls_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/pulls{/number}","milestones_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/milestones{/number}","notifications_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/labels{/name}","releases_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/releases{/id}","deployments_url":"https://api.github.com/repos/kinvolk/mountinfo-graph/deployments","created_at":"2016-09-09T11:22:43Z","updated_at":"2016-09-09T11:22:43Z","pushed_at":"2016-09-09T13:52:32Z","git_url":"git://github.com/kinvolk/mountinfo-graph.git","ssh_url":"git@github.com:kinvolk/mountinfo-graph.git","clone_url":"https://github.com/kinvolk/mountinfo-graph.git","svn_url":"https://github.com/kinvolk/mountinfo-graph","homepage":null,"size":5,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kinvolk/mountinfo-graph/pulls/1"},"html":{"href":"https://github.com/kinvolk/mountinfo-graph/pull/1"},"issue":{"href":"https://api.github.com/repos/kinvolk/mountinfo-graph/issues/1"},"comments":{"href":"https://api.github.com/repos/kinvolk/mountinfo-graph/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/kinvolk/mountinfo-graph/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/kinvolk/mountinfo-graph/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kinvolk/mountinfo-graph/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/kinvolk/mountinfo-graph/statuses/306ee2a0fda0cd1624fe9da087a96ad6a0997f51"}}}}
{"actor":{"display_login":"LiliC"}}