{"action":"created","comment":{"url":"https://api.github.com/repos/convox/rack/pulls/comments/72587651","id":72587651,"diff_hunk":"@@ -0,0 +1,220 @@\n+package manifest\n+\n+import (\n+\t\"crypto/sha256\"\n+\t\"encoding/base32\"\n+\t\"fmt\"\n+\t\"html/template\"\n+\t\"os\"\n+\t\"strconv\"\n+\t\"strings\"\n+\t// \"github.com/convox/rack/api/models\"\n+)\n+\n+type ManifestBalancer struct {\n+\tEntry  Service\n+\tPublic bool\n+}\n+\n+func (m Manifest) Balancers() []ManifestBalancer {\n+\tbalancers := []ManifestBalancer{}\n+\n+\tfor _, entry := range m.Services {\n+\t\tif len(entry.Ports) > 0 {\n+\t\t\tbalancers = append(balancers, ManifestBalancer{\n+\t\t\t\tEntry:  entry,\n+\t\t\t\tPublic: len(entry.InternalPorts()) == 0,\n+\t\t\t})\n+\t\t}\n+\t}\n+\n+\treturn balancers\n+}\n+\n+func (m Manifest) GetBalancer(name string) *ManifestBalancer {\n+\tfor _, mb := range m.Balancers() {\n+\t\tif mb.Entry.Name == name {\n+\t\t\treturn &mb\n+\t\t}\n+\t}\n+\n+\treturn nil\n+}\n+\n+func (m Manifest) HasExternalPorts() bool {\n+\tif len(m.Services) == 0 {\n+\t\treturn true // special case to pre-initialize ELB at app create\n+\t}\n+\n+\tfor _, me := range m.Services {\n+\t\tif len(me.ExternalPorts()) > 0 {\n+\t\t\treturn true\n+\t\t}\n+\t}\n+\n+\treturn false\n+}\n+\n+func (m Manifest) HasProcesses() bool {\n+\treturn len(m.Services) > 0\n+}\n+\n+func (mb ManifestBalancer) ExternalPorts() []Port {\n+\treturn mb.Entry.ExternalPorts()\n+}\n+\n+func (mb ManifestBalancer) FirstPort() string {\n+\tif ports := mb.PortMappings(); len(ports) > 0 {\n+\t\treturn strconv.Itoa(ports[0].Balancer)\n+\t}\n+\n+\treturn \"\"\n+}\n+\n+func (mb ManifestBalancer) LoadBalancerName(bound bool, appName string) template.HTML {\n+\t// Bound apps do not use the StackName directly and ignore Entry.primary\n+\t// and use AppName-EntryName-RackAppEntryHash format\n+\tif bound {\n+\t\thash := sha256.Sum256([]byte(fmt.Sprintf(\"%s:%s:%s\", os.Getenv(\"RACK\"), appName, mb.Entry.Name)))\n+\t\tprefix := fmt.Sprintf(\"%s-%s\", appName, mb.Entry.Name)\n+\t\tsuffix := \"-\" + base32.StdEncoding.EncodeToString(hash[:])[:7]\n+\t\tif !mb.Public {\n+\t\t\tsuffix += \"-i\"\n+\t\t}\n+\t\t// ELB name must be 32 chars or less\n+\t\tif len(prefix) > 32-len(suffix) {\n+\t\t\tprefix = prefix[:32-len(suffix)]\n+\t\t}\n+\t\treturn template.HTML(`\"` + prefix + suffix + `\"`)\n+\t}\n+\n+\t//Unbound apps use legacy StackName or StackName-ProcessName format\n+\t//TODO I'm not sure this will be set at the time of calling\n+\tif mb.Entry.Primary {\n+\t\treturn template.HTML(`{ \"Ref\": \"AWS::StackName\" }`)\n+\t}\n+\n+\tif mb.Public {\n+\t\treturn template.HTML(fmt.Sprintf(`{ \"Fn::Join\": [ \"-\", [ { \"Ref\": \"AWS::StackName\" }, \"%s\" ] ] }`, mb.ProcessName()))\n+\t}\n+\n+\treturn template.HTML(fmt.Sprintf(`{ \"Fn::Join\": [ \"-\", [ { \"Ref\": \"AWS::StackName\" }, \"%s\", \"i\" ] ] }`, mb.ProcessName()))\n+}\n+\n+func (mb ManifestBalancer) InternalPorts() []Port {","path":"manifest/balancer.go","position":104,"original_position":104,"commit_id":"e59c126ac011bca3fce66c298a11c4ff7efa3943","original_commit_id":"e59c126ac011bca3fce66c298a11c4ff7efa3943","user":{"login":"houndci-bot","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci-bot","html_url":"https://github.com/houndci-bot","followers_url":"https://api.github.com/users/houndci-bot/followers","following_url":"https://api.github.com/users/houndci-bot/following{/other_user}","gists_url":"https://api.github.com/users/houndci-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci-bot/subscriptions","organizations_url":"https://api.github.com/users/houndci-bot/orgs","repos_url":"https://api.github.com/users/houndci-bot/repos","events_url":"https://api.github.com/users/houndci-bot/events{/privacy}","received_events_url":"https://api.github.com/users/houndci-bot/received_events","type":"User","site_admin":false},"body":"exported method ManifestBalancer.InternalPorts should have comment or be unexported","created_at":"2016-07-28T09:04:06Z","updated_at":"2016-07-28T09:04:06Z","html_url":"https://github.com/convox/rack/pull/885#discussion_r72587651","pull_request_url":"https://api.github.com/repos/convox/rack/pulls/885","_links":{"self":{"href":"https://api.github.com/repos/convox/rack/pulls/comments/72587651"},"html":{"href":"https://github.com/convox/rack/pull/885#discussion_r72587651"},"pull_request":{"href":"https://api.github.com/repos/convox/rack/pulls/885"}}},"pull_request":{"url":"https://api.github.com/repos/convox/rack/pulls/885","id":78110257,"html_url":"https://github.com/convox/rack/pull/885","diff_url":"https://github.com/convox/rack/pull/885.diff","patch_url":"https://github.com/convox/rack/pull/885.patch","issue_url":"https://api.github.com/repos/convox/rack/issues/885","number":885,"state":"open","locked":false,"title":"[WIP] One manifest to rule them all","user":{"login":"awsmsrc","id":994907,"avatar_url":"https://avatars.githubusercontent.com/u/994907?v=3","gravatar_id":"","url":"https://api.github.com/users/awsmsrc","html_url":"https://github.com/awsmsrc","followers_url":"https://api.github.com/users/awsmsrc/followers","following_url":"https://api.github.com/users/awsmsrc/following{/other_user}","gists_url":"https://api.github.com/users/awsmsrc/gists{/gist_id}","starred_url":"https://api.github.com/users/awsmsrc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/awsmsrc/subscriptions","organizations_url":"https://api.github.com/users/awsmsrc/orgs","repos_url":"https://api.github.com/users/awsmsrc/repos","events_url":"https://api.github.com/users/awsmsrc/events{/privacy}","received_events_url":"https://api.github.com/users/awsmsrc/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-07-20T08:53:45Z","updated_at":"2016-07-28T09:04:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1b561b0412347a55fc9775a62da84c201d8a0b0e","assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/convox/rack/milestones/17","html_url":"https://github.com/convox/rack/milestones/One%20Manifest%20Refactor","labels_url":"https://api.github.com/repos/convox/rack/milestones/17/labels","id":1905288,"number":17,"title":"One Manifest Refactor","description":"","creator":{"login":"MiguelMoll","id":643960,"avatar_url":"https://avatars.githubusercontent.com/u/643960?v=3","gravatar_id":"","url":"https://api.github.com/users/MiguelMoll","html_url":"https://github.com/MiguelMoll","followers_url":"https://api.github.com/users/MiguelMoll/followers","following_url":"https://api.github.com/users/MiguelMoll/following{/other_user}","gists_url":"https://api.github.com/users/MiguelMoll/gists{/gist_id}","starred_url":"https://api.github.com/users/MiguelMoll/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MiguelMoll/subscriptions","organizations_url":"https://api.github.com/users/MiguelMoll/orgs","repos_url":"https://api.github.com/users/MiguelMoll/repos","events_url":"https://api.github.com/users/MiguelMoll/events{/privacy}","received_events_url":"https://api.github.com/users/MiguelMoll/received_events","type":"User","site_admin":false},"open_issues":4,"closed_issues":4,"state":"open","created_at":"2016-07-26T16:06:10Z","updated_at":"2016-07-28T08:40:16Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/convox/rack/pulls/885/commits","review_comments_url":"https://api.github.com/repos/convox/rack/pulls/885/comments","review_comment_url":"https://api.github.com/repos/convox/rack/pulls/comments{/number}","comments_url":"https://api.github.com/repos/convox/rack/issues/885/comments","statuses_url":"https://api.github.com/repos/convox/rack/statuses/e59c126ac011bca3fce66c298a11c4ff7efa3943","head":{"label":"convox:one_manifest_to_rule_them_all","ref":"one_manifest_to_rule_them_all","sha":"e59c126ac011bca3fce66c298a11c4ff7efa3943","user":{"login":"convox","id":10547780,"avatar_url":"https://avatars.githubusercontent.com/u/10547780?v=3","gravatar_id":"","url":"https://api.github.com/users/convox","html_url":"https://github.com/convox","followers_url":"https://api.github.com/users/convox/followers","following_url":"https://api.github.com/users/convox/following{/other_user}","gists_url":"https://api.github.com/users/convox/gists{/gist_id}","starred_url":"https://api.github.com/users/convox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/convox/subscriptions","organizations_url":"https://api.github.com/users/convox/orgs","repos_url":"https://api.github.com/users/convox/repos","events_url":"https://api.github.com/users/convox/events{/privacy}","received_events_url":"https://api.github.com/users/convox/received_events","type":"Organization","site_admin":false},"repo":{"id":42454540,"name":"rack","full_name":"convox/rack","owner":{"login":"convox","id":10547780,"avatar_url":"https://avatars.githubusercontent.com/u/10547780?v=3","gravatar_id":"","url":"https://api.github.com/users/convox","html_url":"https://github.com/convox","followers_url":"https://api.github.com/users/convox/followers","following_url":"https://api.github.com/users/convox/following{/other_user}","gists_url":"https://api.github.com/users/convox/gists{/gist_id}","starred_url":"https://api.github.com/users/convox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/convox/subscriptions","organizations_url":"https://api.github.com/users/convox/orgs","repos_url":"https://api.github.com/users/convox/repos","events_url":"https://api.github.com/users/convox/events{/privacy}","received_events_url":"https://api.github.com/users/convox/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/convox/rack","description":"Open-source PaaS on AWS","fork":false,"url":"https://api.github.com/repos/convox/rack","forks_url":"https://api.github.com/repos/convox/rack/forks","keys_url":"https://api.github.com/repos/convox/rack/keys{/key_id}","collaborators_url":"https://api.github.com/repos/convox/rack/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/convox/rack/teams","hooks_url":"https://api.github.com/repos/convox/rack/hooks","issue_events_url":"https://api.github.com/repos/convox/rack/issues/events{/number}","events_url":"https://api.github.com/repos/convox/rack/events","assignees_url":"https://api.github.com/repos/convox/rack/assignees{/user}","branches_url":"https://api.github.com/repos/convox/rack/branches{/branch}","tags_url":"https://api.github.com/repos/convox/rack/tags","blobs_url":"https://api.github.com/repos/convox/rack/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/convox/rack/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/convox/rack/git/refs{/sha}","trees_url":"https://api.github.com/repos/convox/rack/git/trees{/sha}","statuses_url":"https://api.github.com/repos/convox/rack/statuses/{sha}","languages_url":"https://api.github.com/repos/convox/rack/languages","stargazers_url":"https://api.github.com/repos/convox/rack/stargazers","contributors_url":"https://api.github.com/repos/convox/rack/contributors","subscribers_url":"https://api.github.com/repos/convox/rack/subscribers","subscription_url":"https://api.github.com/repos/convox/rack/subscription","commits_url":"https://api.github.com/repos/convox/rack/commits{/sha}","git_commits_url":"https://api.github.com/repos/convox/rack/git/commits{/sha}","comments_url":"https://api.github.com/repos/convox/rack/comments{/number}","issue_comment_url":"https://api.github.com/repos/convox/rack/issues/comments{/number}","contents_url":"https://api.github.com/repos/convox/rack/contents/{+path}","compare_url":"https://api.github.com/repos/convox/rack/compare/{base}...{head}","merges_url":"https://api.github.com/repos/convox/rack/merges","archive_url":"https://api.github.com/repos/convox/rack/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/convox/rack/downloads","issues_url":"https://api.github.com/repos/convox/rack/issues{/number}","pulls_url":"https://api.github.com/repos/convox/rack/pulls{/number}","milestones_url":"https://api.github.com/repos/convox/rack/milestones{/number}","notifications_url":"https://api.github.com/repos/convox/rack/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/convox/rack/labels{/name}","releases_url":"https://api.github.com/repos/convox/rack/releases{/id}","deployments_url":"https://api.github.com/repos/convox/rack/deployments","created_at":"2015-09-14T14:41:30Z","updated_at":"2016-07-28T03:11:27Z","pushed_at":"2016-07-28T09:03:44Z","git_url":"git://github.com/convox/rack.git","ssh_url":"git@github.com:convox/rack.git","clone_url":"https://github.com/convox/rack.git","svn_url":"https://github.com/convox/rack","homepage":"https://convox.com","size":53656,"stargazers_count":1237,"watchers_count":1237,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":81,"mirror_url":null,"open_issues_count":145,"forks":81,"open_issues":145,"watchers":1237,"default_branch":"master"}},"base":{"label":"convox:master","ref":"master","sha":"e16821d35889bcc9aa9227c14de981587550cfea","user":{"login":"convox","id":10547780,"avatar_url":"https://avatars.githubusercontent.com/u/10547780?v=3","gravatar_id":"","url":"https://api.github.com/users/convox","html_url":"https://github.com/convox","followers_url":"https://api.github.com/users/convox/followers","following_url":"https://api.github.com/users/convox/following{/other_user}","gists_url":"https://api.github.com/users/convox/gists{/gist_id}","starred_url":"https://api.github.com/users/convox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/convox/subscriptions","organizations_url":"https://api.github.com/users/convox/orgs","repos_url":"https://api.github.com/users/convox/repos","events_url":"https://api.github.com/users/convox/events{/privacy}","received_events_url":"https://api.github.com/users/convox/received_events","type":"Organization","site_admin":false},"repo":{"id":42454540,"name":"rack","full_name":"convox/rack","owner":{"login":"convox","id":10547780,"avatar_url":"https://avatars.githubusercontent.com/u/10547780?v=3","gravatar_id":"","url":"https://api.github.com/users/convox","html_url":"https://github.com/convox","followers_url":"https://api.github.com/users/convox/followers","following_url":"https://api.github.com/users/convox/following{/other_user}","gists_url":"https://api.github.com/users/convox/gists{/gist_id}","starred_url":"https://api.github.com/users/convox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/convox/subscriptions","organizations_url":"https://api.github.com/users/convox/orgs","repos_url":"https://api.github.com/users/convox/repos","events_url":"https://api.github.com/users/convox/events{/privacy}","received_events_url":"https://api.github.com/users/convox/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/convox/rack","description":"Open-source PaaS on AWS","fork":false,"url":"https://api.github.com/repos/convox/rack","forks_url":"https://api.github.com/repos/convox/rack/forks","keys_url":"https://api.github.com/repos/convox/rack/keys{/key_id}","collaborators_url":"https://api.github.com/repos/convox/rack/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/convox/rack/teams","hooks_url":"https://api.github.com/repos/convox/rack/hooks","issue_events_url":"https://api.github.com/repos/convox/rack/issues/events{/number}","events_url":"https://api.github.com/repos/convox/rack/events","assignees_url":"https://api.github.com/repos/convox/rack/assignees{/user}","branches_url":"https://api.github.com/repos/convox/rack/branches{/branch}","tags_url":"https://api.github.com/repos/convox/rack/tags","blobs_url":"https://api.github.com/repos/convox/rack/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/convox/rack/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/convox/rack/git/refs{/sha}","trees_url":"https://api.github.com/repos/convox/rack/git/trees{/sha}","statuses_url":"https://api.github.com/repos/convox/rack/statuses/{sha}","languages_url":"https://api.github.com/repos/convox/rack/languages","stargazers_url":"https://api.github.com/repos/convox/rack/stargazers","contributors_url":"https://api.github.com/repos/convox/rack/contributors","subscribers_url":"https://api.github.com/repos/convox/rack/subscribers","subscription_url":"https://api.github.com/repos/convox/rack/subscription","commits_url":"https://api.github.com/repos/convox/rack/commits{/sha}","git_commits_url":"https://api.github.com/repos/convox/rack/git/commits{/sha}","comments_url":"https://api.github.com/repos/convox/rack/comments{/number}","issue_comment_url":"https://api.github.com/repos/convox/rack/issues/comments{/number}","contents_url":"https://api.github.com/repos/convox/rack/contents/{+path}","compare_url":"https://api.github.com/repos/convox/rack/compare/{base}...{head}","merges_url":"https://api.github.com/repos/convox/rack/merges","archive_url":"https://api.github.com/repos/convox/rack/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/convox/rack/downloads","issues_url":"https://api.github.com/repos/convox/rack/issues{/number}","pulls_url":"https://api.github.com/repos/convox/rack/pulls{/number}","milestones_url":"https://api.github.com/repos/convox/rack/milestones{/number}","notifications_url":"https://api.github.com/repos/convox/rack/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/convox/rack/labels{/name}","releases_url":"https://api.github.com/repos/convox/rack/releases{/id}","deployments_url":"https://api.github.com/repos/convox/rack/deployments","created_at":"2015-09-14T14:41:30Z","updated_at":"2016-07-28T03:11:27Z","pushed_at":"2016-07-28T09:03:44Z","git_url":"git://github.com/convox/rack.git","ssh_url":"git@github.com:convox/rack.git","clone_url":"https://github.com/convox/rack.git","svn_url":"https://github.com/convox/rack","homepage":"https://convox.com","size":53656,"stargazers_count":1237,"watchers_count":1237,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":81,"mirror_url":null,"open_issues_count":145,"forks":81,"open_issues":145,"watchers":1237,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/convox/rack/pulls/885"},"html":{"href":"https://github.com/convox/rack/pull/885"},"issue":{"href":"https://api.github.com/repos/convox/rack/issues/885"},"comments":{"href":"https://api.github.com/repos/convox/rack/issues/885/comments"},"review_comments":{"href":"https://api.github.com/repos/convox/rack/pulls/885/comments"},"review_comment":{"href":"https://api.github.com/repos/convox/rack/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/convox/rack/pulls/885/commits"},"statuses":{"href":"https://api.github.com/repos/convox/rack/statuses/e59c126ac011bca3fce66c298a11c4ff7efa3943"}}}}
{"actor":{"display_login":"houndci-bot"}}