GitHub PullRequestReviewCommentEvent at 2014-04-23 19:56:14
Repository: fleet
Actor: jonboulle
Payload: {"comment":{"url":"https://api.github.com/repos/coreos/fleet/pulls/comments/11920356","id":11920356,"diff_hunk":"@@ -0,0 +1,66 @@\n+package machine\n+\n+import (\n+\t\"bufio\"\n+\t\"bytes\"\n+\t\"os/exec\"\n+\t\"runtime\"\n+\t\"strconv\"\n+)\n+\n+type MachineSpec struct {\n+\t// in hundreds, ie 100=1core, 50=0.5core, 200=2cores, etc\n+\tCores int\n+\t// in MB\n+\tMemory int\n+\t// in MB\n+\tDiskSpace int\n+}\n+\n+func ReadLocalSpec() (*MachineSpec, error) {\n+\tspec := new(MachineSpec)\n+\tspec.Cores = 100 * runtime.NumCPU()\n+\n+\t// TODO(uwedeportivo): determine disk space\n+\n+\tmem, err := readMemory()\n+\tif err != nil {\n+\t\treturn nil, err\n+\t}\n+\tspec.Memory = mem\n+\tspec.DiskSpace = 1024\n+\n+\treturn spec, nil\n+}\n+\n+func parseFreeMOutput(memstr []byte) (int, error) {\n+\tss := bufio.NewScanner(bytes.NewBuffer(memstr))\n+\tss.Split(bufio.ScanWords)\n+\tseenMemToken := false\n+\tmem := 0\n+\tfor ss.Scan() {\n+\t\ttoken := ss.Text()\n+\t\tif seenMemToken {\n+\t\t\tm, err := strconv.Atoi(token)\n+\t\t\tif err != nil {\n+\t\t\t\treturn 0, err\n+\t\t\t}\n+\t\t\tmem = m\n+\t\t\tbreak\n+\t\t} else if token == \"Mem:\" {\n+\t\t\tseenMemToken = true\n+\t\t}\n+\t}\n+\tif err := ss.Err(); err != nil {\n+\t\treturn 0, err\n+\t}\n+\treturn mem, nil\n+}\n+\n+func readMemory() (int, error) {","path":"machine/spec.go","position":60,"original_position":60,"commit_id":"bb435462dd45c58f65d6466c723e5dceb99526ae","original_commit_id":"bb435462dd45c58f65d6466c723e5dceb99526ae","user":{"login":"jonboulle","id":2601015,"avatar_url":"https://avatars.githubusercontent.com/u/2601015?","gravatar_id":"0f0b8b324fd58974000aacebb9b66c65","url":"https://api.github.com/users/jonboulle","html_url":"https://github.com/jonboulle","followers_url":"https://api.github.com/users/jonboulle/followers","following_url":"https://api.github.com/users/jonboulle/following{/other_user}","gists_url":"https://api.github.com/users/jonboulle/gists{/gist_id}","starred_url":"https://api.github.com/users/jonboulle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonboulle/subscriptions","organizations_url":"https://api.github.com/users/jonboulle/orgs","repos_url":"https://api.github.com/users/jonboulle/repos","events_url":"https://api.github.com/users/jonboulle/events{/privacy}","received_events_url":"https://api.github.com/users/jonboulle/received_events","type":"User","site_admin":false},"body":"ah, I see Brandon mentioned this earlier","created_at":"2014-04-23T19:56:14Z","updated_at":"2014-04-23T19:56:14Z","html_url":"https://github.com/coreos/fleet/pull/237#discussion_r11920356","pull_request_url":"https://api.github.com/repos/coreos/fleet/pulls/237","_links":{"self":{"href":"https://api.github.com/repos/coreos/fleet/pulls/comments/11920356"},"html":{"href":"https://github.com/coreos/fleet/pull/237#discussion_r11920356"},"pull_request":{"href":"https://api.github.com/repos/coreos/fleet/pulls/237"}}}}