{"action":"created","comment":{"url":"https://api.github.com/repos/airware/vili/pulls/comments/71962525","id":71962525,"diff_hunk":"@@ -0,0 +1,142 @@\n+package environments\n+\n+import (\n+\t\"errors\"\n+\t\"sort\"\n+\t\"sync\"\n+\n+\t\"github.com/airware/vili/kube\"\n+\t\"github.com/airware/vili/kube/v1\"\n+)\n+\n+var environments []Environment\n+var rwMutex sync.RWMutex\n+\n+// Environment describes an environment backed by a kubernetes namespace\n+type Environment struct {\n+\tName      string `json:\"name\"`\n+\tProtected bool   `json:\"protected\"`\n+\tProd      bool   `json:\"prod\"`\n+\tApproval  bool   `json:\"approval\"`\n+}\n+\n+// Init initializes the global environments list\n+func Init(envs []Environment) {\n+\trwMutex.Lock()\n+\tenvironments = []Environment{}\n+\tfor _, env := range envs {\n+\t\tenvironments = append(environments, env)\n+\t}\n+\tsort.Sort(byName(environments))\n+\trwMutex.Unlock()\n+}\n+\n+// Environments returns a snapshot of all of the known environments\n+func Environments() (ret []Environment) {\n+\trwMutex.RLock()\n+\tfor _, env := range environments {\n+\t\tret = append(ret, env)\n+\t}\n+\trwMutex.RUnlock()\n+\treturn\n+}\n+\n+// Create creates a new environment with `name`\n+func Create(name string) error {\n+\t_, status, err := kube.Namespaces.Create(&v1.Namespace{","path":"environments/environments.go","position":null,"original_position":46,"commit_id":"2aa3448c8072c669bb2985037ae19dd1afeeb250","original_commit_id":"fcc2aa675adc2066bdf1923bc5796b094d0d9621","user":{"login":"BrianBland","id":2295742,"avatar_url":"https://avatars.githubusercontent.com/u/2295742?v=3","gravatar_id":"","url":"https://api.github.com/users/BrianBland","html_url":"https://github.com/BrianBland","followers_url":"https://api.github.com/users/BrianBland/followers","following_url":"https://api.github.com/users/BrianBland/following{/other_user}","gists_url":"https://api.github.com/users/BrianBland/gists{/gist_id}","starred_url":"https://api.github.com/users/BrianBland/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BrianBland/subscriptions","organizations_url":"https://api.github.com/users/BrianBland/orgs","repos_url":"https://api.github.com/users/BrianBland/repos","events_url":"https://api.github.com/users/BrianBland/events{/privacy}","received_events_url":"https://api.github.com/users/BrianBland/received_events","type":"User","site_admin":false},"body":"Yeah it won't accept invalid or duplicate namespaces, returning an `*unversioned.Status`","created_at":"2016-07-23T00:28:53Z","updated_at":"2016-07-23T00:28:53Z","html_url":"https://github.com/airware/vili/pull/21#discussion_r71962525","pull_request_url":"https://api.github.com/repos/airware/vili/pulls/21","_links":{"self":{"href":"https://api.github.com/repos/airware/vili/pulls/comments/71962525"},"html":{"href":"https://github.com/airware/vili/pull/21#discussion_r71962525"},"pull_request":{"href":"https://api.github.com/repos/airware/vili/pulls/21"}}},"pull_request":{"url":"https://api.github.com/repos/airware/vili/pulls/21","id":78398167,"html_url":"https://github.com/airware/vili/pull/21","diff_url":"https://github.com/airware/vili/pull/21.diff","patch_url":"https://github.com/airware/vili/pull/21.patch","issue_url":"https://api.github.com/repos/airware/vili/issues/21","number":21,"state":"open","locked":false,"title":"Add preliminary environment management","user":{"login":"BrianBland","id":2295742,"avatar_url":"https://avatars.githubusercontent.com/u/2295742?v=3","gravatar_id":"","url":"https://api.github.com/users/BrianBland","html_url":"https://github.com/BrianBland","followers_url":"https://api.github.com/users/BrianBland/followers","following_url":"https://api.github.com/users/BrianBland/following{/other_user}","gists_url":"https://api.github.com/users/BrianBland/gists{/gist_id}","starred_url":"https://api.github.com/users/BrianBland/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BrianBland/subscriptions","organizations_url":"https://api.github.com/users/BrianBland/orgs","repos_url":"https://api.github.com/users/BrianBland/repos","events_url":"https://api.github.com/users/BrianBland/events{/privacy}","received_events_url":"https://api.github.com/users/BrianBland/received_events","type":"User","site_admin":false},"body":"Add a Create Environment prompt in the environments dropdown.\r\nAdd an \"X\" delete icon to each environment in the same dropdown.\r\nDisallow deleting explicitly-defined (\"protected\") environments in the API.\r\n\r\nTODO:\r\n- [x] Don't display the \"remove environment\" button for explicitly-defined environments\r\n- [x] Modals instead of prompts for create/remove environment","created_at":"2016-07-21T22:27:46Z","updated_at":"2016-07-23T00:28:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"dbec09e61b068d5c24e30f2713007bd76dd4c7c2","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/airware/vili/pulls/21/commits","review_comments_url":"https://api.github.com/repos/airware/vili/pulls/21/comments","review_comment_url":"https://api.github.com/repos/airware/vili/pulls/comments{/number}","comments_url":"https://api.github.com/repos/airware/vili/issues/21/comments","statuses_url":"https://api.github.com/repos/airware/vili/statuses/2aa3448c8072c669bb2985037ae19dd1afeeb250","head":{"label":"BrianBland:environment-management","ref":"environment-management","sha":"2aa3448c8072c669bb2985037ae19dd1afeeb250","user":{"login":"BrianBland","id":2295742,"avatar_url":"https://avatars.githubusercontent.com/u/2295742?v=3","gravatar_id":"","url":"https://api.github.com/users/BrianBland","html_url":"https://github.com/BrianBland","followers_url":"https://api.github.com/users/BrianBland/followers","following_url":"https://api.github.com/users/BrianBland/following{/other_user}","gists_url":"https://api.github.com/users/BrianBland/gists{/gist_id}","starred_url":"https://api.github.com/users/BrianBland/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BrianBland/subscriptions","organizations_url":"https://api.github.com/users/BrianBland/orgs","repos_url":"https://api.github.com/users/BrianBland/repos","events_url":"https://api.github.com/users/BrianBland/events{/privacy}","received_events_url":"https://api.github.com/users/BrianBland/received_events","type":"User","site_admin":false},"repo":{"id":61677618,"name":"vili","full_name":"BrianBland/vili","owner":{"login":"BrianBland","id":2295742,"avatar_url":"https://avatars.githubusercontent.com/u/2295742?v=3","gravatar_id":"","url":"https://api.github.com/users/BrianBland","html_url":"https://github.com/BrianBland","followers_url":"https://api.github.com/users/BrianBland/followers","following_url":"https://api.github.com/users/BrianBland/following{/other_user}","gists_url":"https://api.github.com/users/BrianBland/gists{/gist_id}","starred_url":"https://api.github.com/users/BrianBland/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BrianBland/subscriptions","organizations_url":"https://api.github.com/users/BrianBland/orgs","repos_url":"https://api.github.com/users/BrianBland/repos","events_url":"https://api.github.com/users/BrianBland/events{/privacy}","received_events_url":"https://api.github.com/users/BrianBland/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/BrianBland/vili","description":"","fork":true,"url":"https://api.github.com/repos/BrianBland/vili","forks_url":"https://api.github.com/repos/BrianBland/vili/forks","keys_url":"https://api.github.com/repos/BrianBland/vili/keys{/key_id}","collaborators_url":"https://api.github.com/repos/BrianBland/vili/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/BrianBland/vili/teams","hooks_url":"https://api.github.com/repos/BrianBland/vili/hooks","issue_events_url":"https://api.github.com/repos/BrianBland/vili/issues/events{/number}","events_url":"https://api.github.com/repos/BrianBland/vili/events","assignees_url":"https://api.github.com/repos/BrianBland/vili/assignees{/user}","branches_url":"https://api.github.com/repos/BrianBland/vili/branches{/branch}","tags_url":"https://api.github.com/repos/BrianBland/vili/tags","blobs_url":"https://api.github.com/repos/BrianBland/vili/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/BrianBland/vili/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/BrianBland/vili/git/refs{/sha}","trees_url":"https://api.github.com/repos/BrianBland/vili/git/trees{/sha}","statuses_url":"https://api.github.com/repos/BrianBland/vili/statuses/{sha}","languages_url":"https://api.github.com/repos/BrianBland/vili/languages","stargazers_url":"https://api.github.com/repos/BrianBland/vili/stargazers","contributors_url":"https://api.github.com/repos/BrianBland/vili/contributors","subscribers_url":"https://api.github.com/repos/BrianBland/vili/subscribers","subscription_url":"https://api.github.com/repos/BrianBland/vili/subscription","commits_url":"https://api.github.com/repos/BrianBland/vili/commits{/sha}","git_commits_url":"https://api.github.com/repos/BrianBland/vili/git/commits{/sha}","comments_url":"https://api.github.com/repos/BrianBland/vili/comments{/number}","issue_comment_url":"https://api.github.com/repos/BrianBland/vili/issues/comments{/number}","contents_url":"https://api.github.com/repos/BrianBland/vili/contents/{+path}","compare_url":"https://api.github.com/repos/BrianBland/vili/compare/{base}...{head}","merges_url":"https://api.github.com/repos/BrianBland/vili/merges","archive_url":"https://api.github.com/repos/BrianBland/vili/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/BrianBland/vili/downloads","issues_url":"https://api.github.com/repos/BrianBland/vili/issues{/number}","pulls_url":"https://api.github.com/repos/BrianBland/vili/pulls{/number}","milestones_url":"https://api.github.com/repos/BrianBland/vili/milestones{/number}","notifications_url":"https://api.github.com/repos/BrianBland/vili/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/BrianBland/vili/labels{/name}","releases_url":"https://api.github.com/repos/BrianBland/vili/releases{/id}","deployments_url":"https://api.github.com/repos/BrianBland/vili/deployments","created_at":"2016-06-22T00:56:08Z","updated_at":"2016-06-22T00:56:09Z","pushed_at":"2016-07-23T00:07:38Z","git_url":"git://github.com/BrianBland/vili.git","ssh_url":"git@github.com:BrianBland/vili.git","clone_url":"https://github.com/BrianBland/vili.git","svn_url":"https://github.com/BrianBland/vili","homepage":"https://makers.airware.com/open-source/vili/","size":8415,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"airware:master","ref":"master","sha":"10013ec3cf49deca73ec48d7e52822533b0d0778","user":{"login":"airware","id":10148070,"avatar_url":"https://avatars.githubusercontent.com/u/10148070?v=3","gravatar_id":"","url":"https://api.github.com/users/airware","html_url":"https://github.com/airware","followers_url":"https://api.github.com/users/airware/followers","following_url":"https://api.github.com/users/airware/following{/other_user}","gists_url":"https://api.github.com/users/airware/gists{/gist_id}","starred_url":"https://api.github.com/users/airware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/airware/subscriptions","organizations_url":"https://api.github.com/users/airware/orgs","repos_url":"https://api.github.com/users/airware/repos","events_url":"https://api.github.com/users/airware/events{/privacy}","received_events_url":"https://api.github.com/users/airware/received_events","type":"Organization","site_admin":false},"repo":{"id":52051957,"name":"vili","full_name":"airware/vili","owner":{"login":"airware","id":10148070,"avatar_url":"https://avatars.githubusercontent.com/u/10148070?v=3","gravatar_id":"","url":"https://api.github.com/users/airware","html_url":"https://github.com/airware","followers_url":"https://api.github.com/users/airware/followers","following_url":"https://api.github.com/users/airware/following{/other_user}","gists_url":"https://api.github.com/users/airware/gists{/gist_id}","starred_url":"https://api.github.com/users/airware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/airware/subscriptions","organizations_url":"https://api.github.com/users/airware/orgs","repos_url":"https://api.github.com/users/airware/repos","events_url":"https://api.github.com/users/airware/events{/privacy}","received_events_url":"https://api.github.com/users/airware/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/airware/vili","description":"","fork":false,"url":"https://api.github.com/repos/airware/vili","forks_url":"https://api.github.com/repos/airware/vili/forks","keys_url":"https://api.github.com/repos/airware/vili/keys{/key_id}","collaborators_url":"https://api.github.com/repos/airware/vili/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/airware/vili/teams","hooks_url":"https://api.github.com/repos/airware/vili/hooks","issue_events_url":"https://api.github.com/repos/airware/vili/issues/events{/number}","events_url":"https://api.github.com/repos/airware/vili/events","assignees_url":"https://api.github.com/repos/airware/vili/assignees{/user}","branches_url":"https://api.github.com/repos/airware/vili/branches{/branch}","tags_url":"https://api.github.com/repos/airware/vili/tags","blobs_url":"https://api.github.com/repos/airware/vili/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/airware/vili/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/airware/vili/git/refs{/sha}","trees_url":"https://api.github.com/repos/airware/vili/git/trees{/sha}","statuses_url":"https://api.github.com/repos/airware/vili/statuses/{sha}","languages_url":"https://api.github.com/repos/airware/vili/languages","stargazers_url":"https://api.github.com/repos/airware/vili/stargazers","contributors_url":"https://api.github.com/repos/airware/vili/contributors","subscribers_url":"https://api.github.com/repos/airware/vili/subscribers","subscription_url":"https://api.github.com/repos/airware/vili/subscription","commits_url":"https://api.github.com/repos/airware/vili/commits{/sha}","git_commits_url":"https://api.github.com/repos/airware/vili/git/commits{/sha}","comments_url":"https://api.github.com/repos/airware/vili/comments{/number}","issue_comment_url":"https://api.github.com/repos/airware/vili/issues/comments{/number}","contents_url":"https://api.github.com/repos/airware/vili/contents/{+path}","compare_url":"https://api.github.com/repos/airware/vili/compare/{base}...{head}","merges_url":"https://api.github.com/repos/airware/vili/merges","archive_url":"https://api.github.com/repos/airware/vili/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/airware/vili/downloads","issues_url":"https://api.github.com/repos/airware/vili/issues{/number}","pulls_url":"https://api.github.com/repos/airware/vili/pulls{/number}","milestones_url":"https://api.github.com/repos/airware/vili/milestones{/number}","notifications_url":"https://api.github.com/repos/airware/vili/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/airware/vili/labels{/name}","releases_url":"https://api.github.com/repos/airware/vili/releases{/id}","deployments_url":"https://api.github.com/repos/airware/vili/deployments","created_at":"2016-02-19T01:23:30Z","updated_at":"2016-07-19T10:15:30Z","pushed_at":"2016-07-23T00:07:39Z","git_url":"git://github.com/airware/vili.git","ssh_url":"git@github.com:airware/vili.git","clone_url":"https://github.com/airware/vili.git","svn_url":"https://github.com/airware/vili","homepage":"https://makers.airware.com/open-source/vili/","size":8408,"stargazers_count":28,"watchers_count":28,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":3,"forks":5,"open_issues":3,"watchers":28,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/airware/vili/pulls/21"},"html":{"href":"https://github.com/airware/vili/pull/21"},"issue":{"href":"https://api.github.com/repos/airware/vili/issues/21"},"comments":{"href":"https://api.github.com/repos/airware/vili/issues/21/comments"},"review_comments":{"href":"https://api.github.com/repos/airware/vili/pulls/21/comments"},"review_comment":{"href":"https://api.github.com/repos/airware/vili/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/airware/vili/pulls/21/commits"},"statuses":{"href":"https://api.github.com/repos/airware/vili/statuses/2aa3448c8072c669bb2985037ae19dd1afeeb250"}}}}
{"actor":{"display_login":"BrianBland"}}