GitHub PullRequestEvent at 2014-10-10 17:08:38
Repository: terraform
Actor: catsby
Payload: {"action":"opened","number":389,"pull_request":{"url":"https://api.github.com/repos/hashicorp/terraform/pulls/389","id":22574432,"html_url":"https://github.com/hashicorp/terraform/pull/389","diff_url":"https://github.com/hashicorp/terraform/pull/389.diff","patch_url":"https://github.com/hashicorp/terraform/pull/389.patch","issue_url":"https://api.github.com/repos/hashicorp/terraform/issues/389","number":389,"state":"open","locked":false,"title":"Starting point for adding Organization app support for Heroku Provider","user":{"login":"catsby","id":61721,"avatar_url":"https://avatars.githubusercontent.com/u/61721?v=2","gravatar_id":"","url":"https://api.github.com/users/catsby","html_url":"https://github.com/catsby","followers_url":"https://api.github.com/users/catsby/followers","following_url":"https://api.github.com/users/catsby/following{/other_user}","gists_url":"https://api.github.com/users/catsby/gists{/gist_id}","starred_url":"https://api.github.com/users/catsby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/catsby/subscriptions","organizations_url":"https://api.github.com/users/catsby/orgs","repos_url":"https://api.github.com/users/catsby/repos","events_url":"https://api.github.com/users/catsby/events{/privacy}","received_events_url":"https://api.github.com/users/catsby/received_events","type":"User","site_admin":false},"body":"This is a hack-ish first pass at adding Organization app support ([1][1],[2][2]) to the Heroku Provider. \r\n\r\nThis PR is meant as a starting point for discussion because frankly it's ugly :) \r\n\r\nWith this PR, you can create an app under and Organization by adding the org name to the resource:\r\n\r\n```\r\nresource \"heroku_app\" \"web\" {\r\n  name         = \"catsby-test-app\"\r\n  region       = \"us\"\r\n  organization = \"catsby\"\r\n}\r\n```\r\n\r\n```diff\r\n \treturn &schema.Resource{\r\n-\t\tCreate: resourceHerokuAppCreate,\r\n+\t\tCreate: switchHerokuAppCreate,\r\n```\r\n\r\nThe intent here is to conditionally return the right method to create the app, depending on if the `organization` field was found in the schema. The name is not the best :/ \r\n\r\nFor the actual conditional logic:\r\n\r\n```diff\r\n+\tif len(isOrg.(string)) != 0 {\r\n```\r\n\r\nThis seems horrible, but a previous check for `nil` was wrong because the `organization` field seems to get the default string value `\"\"` (I think).\r\n\r\n```diff\r\n+func resourceHerokuOrgAppCreate(d *schema.ResourceData, meta interface{}) error {\r\n```\r\n\r\nI copy-pasted 99% of this method from `resourceHerokuAppCreate`, only adding/changing org specific things, so there's ugly duplication. Still being a Go novice, I wasn't sure how to separate the similar logic and change the methods to be specific to their cases.\r\n\r\nI wasn't sure how far to go with the Organization support, as [there are other fields like `locked`, `joined`][3], etc. Maybe the `organization` should be a map in the configuration, like so?\r\n\r\n```\r\nresource \"heroku_app\" \"web\" {\r\n  name         = \"catsby-test-app\"\r\n  region       = \"us\"\r\n  organization {\r\n    name = \"catsby\"\r\n    locked = true\r\n  }\r\n}\r\n```\r\n\r\nI would really like feedback and guidance on DRY/cleanup suggestions here, as well as guidance on how to write a test for this. I've verified it *works*, but I'm not sure where to start on the testing :/ \r\n\r\n[1]: https://devcenter.heroku.com/categories/organization-accounts\r\n[2]: https://devcenter.heroku.com/articles/platform-api-reference#organization-app\r\n[3]: https://github.com/cyberdelia/heroku-go/blob/master/v3/heroku.go#L1317","created_at":"2014-10-10T17:08:35Z","updated_at":"2014-10-10T17:08:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9777c5bcf1f2effb019acceb48e41628a66130e2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/hashicorp/terraform/pulls/389/commits","review_comments_url":"https://api.github.com/repos/hashicorp/terraform/pulls/389/comments","review_comment_url":"https://api.github.com/repos/hashicorp/terraform/pulls/comments/{number}","comments_url":"https://api.github.com/repos/hashicorp/terraform/issues/389/comments","statuses_url":"https://api.github.com/repos/hashicorp/terraform/statuses/15e7b89fe32a69885a95531d9987ae70e93c9729","head":{"label":"catsby:heroku-go-orgs","ref":"heroku-go-orgs","sha":"15e7b89fe32a69885a95531d9987ae70e93c9729","user":{"login":"catsby","id":61721,"avatar_url":"https://avatars.githubusercontent.com/u/61721?v=2","gravatar_id":"","url":"https://api.github.com/users/catsby","html_url":"https://github.com/catsby","followers_url":"https://api.github.com/users/catsby/followers","following_url":"https://api.github.com/users/catsby/following{/other_user}","gists_url":"https://api.github.com/users/catsby/gists{/gist_id}","starred_url":"https://api.github.com/users/catsby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/catsby/subscriptions","organizations_url":"https://api.github.com/users/catsby/orgs","repos_url":"https://api.github.com/users/catsby/repos","events_url":"https://api.github.com/users/catsby/events{/privacy}","received_events_url":"https://api.github.com/users/catsby/received_events","type":"User","site_admin":false},"repo":{"id":22405888,"name":"terraform","full_name":"catsby/terraform","owner":{"login":"catsby","id":61721,"avatar_url":"https://avatars.githubusercontent.com/u/61721?v=2","gravatar_id":"","url":"https://api.github.com/users/catsby","html_url":"https://github.com/catsby","followers_url":"https://api.github.com/users/catsby/followers","following_url":"https://api.github.com/users/catsby/following{/other_user}","gists_url":"https://api.github.com/users/catsby/gists{/gist_id}","starred_url":"https://api.github.com/users/catsby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/catsby/subscriptions","organizations_url":"https://api.github.com/users/catsby/orgs","repos_url":"https://api.github.com/users/catsby/repos","events_url":"https://api.github.com/users/catsby/events{/privacy}","received_events_url":"https://api.github.com/users/catsby/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/catsby/terraform","description":"Terraform is a tool for building, changing, and combining infrastructure safely and efficiently.","fork":true,"url":"https://api.github.com/repos/catsby/terraform","forks_url":"https://api.github.com/repos/catsby/terraform/forks","keys_url":"https://api.github.com/repos/catsby/terraform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/catsby/terraform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/catsby/terraform/teams","hooks_url":"https://api.github.com/repos/catsby/terraform/hooks","issue_events_url":"https://api.github.com/repos/catsby/terraform/issues/events{/number}","events_url":"https://api.github.com/repos/catsby/terraform/events","assignees_url":"https://api.github.com/repos/catsby/terraform/assignees{/user}","branches_url":"https://api.github.com/repos/catsby/terraform/branches{/branch}","tags_url":"https://api.github.com/repos/catsby/terraform/tags","blobs_url":"https://api.github.com/repos/catsby/terraform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/catsby/terraform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/catsby/terraform/git/refs{/sha}","trees_url":"https://api.github.com/repos/catsby/terraform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/catsby/terraform/statuses/{sha}","languages_url":"https://api.github.com/repos/catsby/terraform/languages","stargazers_url":"https://api.github.com/repos/catsby/terraform/stargazers","contributors_url":"https://api.github.com/repos/catsby/terraform/contributors","subscribers_url":"https://api.github.com/repos/catsby/terraform/subscribers","subscription_url":"https://api.github.com/repos/catsby/terraform/subscription","commits_url":"https://api.github.com/repos/catsby/terraform/commits{/sha}","git_commits_url":"https://api.github.com/repos/catsby/terraform/git/commits{/sha}","comments_url":"https://api.github.com/repos/catsby/terraform/comments{/number}","issue_comment_url":"https://api.github.com/repos/catsby/terraform/issues/comments/{number}","contents_url":"https://api.github.com/repos/catsby/terraform/contents/{+path}","compare_url":"https://api.github.com/repos/catsby/terraform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/catsby/terraform/merges","archive_url":"https://api.github.com/repos/catsby/terraform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/catsby/terraform/downloads","issues_url":"https://api.github.com/repos/catsby/terraform/issues{/number}","pulls_url":"https://api.github.com/repos/catsby/terraform/pulls{/number}","milestones_url":"https://api.github.com/repos/catsby/terraform/milestones{/number}","notifications_url":"https://api.github.com/repos/catsby/terraform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/catsby/terraform/labels{/name}","releases_url":"https://api.github.com/repos/catsby/terraform/releases{/id}","created_at":"2014-07-30T03:14:01Z","updated_at":"2014-08-12T02:36:34Z","pushed_at":"2014-10-10T16:55:03Z","git_url":"git://github.com/catsby/terraform.git","ssh_url":"git@github.com:catsby/terraform.git","clone_url":"https://github.com/catsby/terraform.git","svn_url":"https://github.com/catsby/terraform","homepage":"http://www.terraform.io","size":16648,"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":"hashicorp:master","ref":"master","sha":"1acb546d740cc8834b8757f1d25f0024ec2d9134","user":{"login":"hashicorp","id":761456,"avatar_url":"https://avatars.githubusercontent.com/u/761456?v=2","gravatar_id":"","url":"https://api.github.com/users/hashicorp","html_url":"https://github.com/hashicorp","followers_url":"https://api.github.com/users/hashicorp/followers","following_url":"https://api.github.com/users/hashicorp/following{/other_user}","gists_url":"https://api.github.com/users/hashicorp/gists{/gist_id}","starred_url":"https://api.github.com/users/hashicorp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hashicorp/subscriptions","organizations_url":"https://api.github.com/users/hashicorp/orgs","repos_url":"https://api.github.com/users/hashicorp/repos","events_url":"https://api.github.com/users/hashicorp/events{/privacy}","received_events_url":"https://api.github.com/users/hashicorp/received_events","type":"Organization","site_admin":false},"repo":{"id":17728164,"name":"terraform","full_name":"hashicorp/terraform","owner":{"login":"hashicorp","id":761456,"avatar_url":"https://avatars.githubusercontent.com/u/761456?v=2","gravatar_id":"","url":"https://api.github.com/users/hashicorp","html_url":"https://github.com/hashicorp","followers_url":"https://api.github.com/users/hashicorp/followers","following_url":"https://api.github.com/users/hashicorp/following{/other_user}","gists_url":"https://api.github.com/users/hashicorp/gists{/gist_id}","starred_url":"https://api.github.com/users/hashicorp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hashicorp/subscriptions","organizations_url":"https://api.github.com/users/hashicorp/orgs","repos_url":"https://api.github.com/users/hashicorp/repos","events_url":"https://api.github.com/users/hashicorp/events{/privacy}","received_events_url":"https://api.github.com/users/hashicorp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hashicorp/terraform","description":"Terraform is a tool for building, changing, and combining infrastructure safely and efficiently.","fork":false,"url":"https://api.github.com/repos/hashicorp/terraform","forks_url":"https://api.github.com/repos/hashicorp/terraform/forks","keys_url":"https://api.github.com/repos/hashicorp/terraform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hashicorp/terraform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hashicorp/terraform/teams","hooks_url":"https://api.github.com/repos/hashicorp/terraform/hooks","issue_events_url":"https://api.github.com/repos/hashicorp/terraform/issues/events{/number}","events_url":"https://api.github.com/repos/hashicorp/terraform/events","assignees_url":"https://api.github.com/repos/hashicorp/terraform/assignees{/user}","branches_url":"https://api.github.com/repos/hashicorp/terraform/branches{/branch}","tags_url":"https://api.github.com/repos/hashicorp/terraform/tags","blobs_url":"https://api.github.com/repos/hashicorp/terraform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hashicorp/terraform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hashicorp/terraform/git/refs{/sha}","trees_url":"https://api.github.com/repos/hashicorp/terraform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hashicorp/terraform/statuses/{sha}","languages_url":"https://api.github.com/repos/hashicorp/terraform/languages","stargazers_url":"https://api.github.com/repos/hashicorp/terraform/stargazers","contributors_url":"https://api.github.com/repos/hashicorp/terraform/contributors","subscribers_url":"https://api.github.com/repos/hashicorp/terraform/subscribers","subscription_url":"https://api.github.com/repos/hashicorp/terraform/subscription","commits_url":"https://api.github.com/repos/hashicorp/terraform/commits{/sha}","git_commits_url":"https://api.github.com/repos/hashicorp/terraform/git/commits{/sha}","comments_url":"https://api.github.com/repos/hashicorp/terraform/comments{/number}","issue_comment_url":"https://api.github.com/repos/hashicorp/terraform/issues/comments/{number}","contents_url":"https://api.github.com/repos/hashicorp/terraform/contents/{+path}","compare_url":"https://api.github.com/repos/hashicorp/terraform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hashicorp/terraform/merges","archive_url":"https://api.github.com/repos/hashicorp/terraform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hashicorp/terraform/downloads","issues_url":"https://api.github.com/repos/hashicorp/terraform/issues{/number}","pulls_url":"https://api.github.com/repos/hashicorp/terraform/pulls{/number}","milestones_url":"https://api.github.com/repos/hashicorp/terraform/milestones{/number}","notifications_url":"https://api.github.com/repos/hashicorp/terraform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hashicorp/terraform/labels{/name}","releases_url":"https://api.github.com/repos/hashicorp/terraform/releases{/id}","created_at":"2014-03-13T22:25:48Z","updated_at":"2014-10-10T15:35:55Z","pushed_at":"2014-10-10T17:03:36Z","git_url":"git://github.com/hashicorp/terraform.git","ssh_url":"git@github.com:hashicorp/terraform.git","clone_url":"https://github.com/hashicorp/terraform.git","svn_url":"https://github.com/hashicorp/terraform","homepage":"http://www.terraform.io","size":26407,"stargazers_count":1525,"watchers_count":1525,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":131,"mirror_url":null,"open_issues_count":68,"forks":131,"open_issues":68,"watchers":1525,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hashicorp/terraform/pulls/389"},"html":{"href":"https://github.com/hashicorp/terraform/pull/389"},"issue":{"href":"https://api.github.com/repos/hashicorp/terraform/issues/389"},"comments":{"href":"https://api.github.com/repos/hashicorp/terraform/issues/389/comments"},"review_comments":{"href":"https://api.github.com/repos/hashicorp/terraform/pulls/389/comments"},"review_comment":{"href":"https://api.github.com/repos/hashicorp/terraform/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/hashicorp/terraform/pulls/389/commits"},"statuses":{"href":"https://api.github.com/repos/hashicorp/terraform/statuses/15e7b89fe32a69885a95531d9987ae70e93c9729"}},"merged":false,"mergeable":true,"mergeable_state":"clean","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":59,"deletions":1,"changed_files":1}}