{"action":"created","issue":{"url":"https://api.github.com/repos/Schibsted-Tech-Polska/HeroIn/issues/1","repository_url":"https://api.github.com/repos/Schibsted-Tech-Polska/HeroIn","labels_url":"https://api.github.com/repos/Schibsted-Tech-Polska/HeroIn/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/Schibsted-Tech-Polska/HeroIn/issues/1/comments","events_url":"https://api.github.com/repos/Schibsted-Tech-Polska/HeroIn/issues/1/events","html_url":"https://github.com/Schibsted-Tech-Polska/HeroIn/pull/1","id":181669095,"number":1,"title":"Addon attachment","user":{"login":"pmrukot","id":13131966,"avatar_url":"https://avatars.githubusercontent.com/u/13131966?v=3","gravatar_id":"","url":"https://api.github.com/users/pmrukot","html_url":"https://github.com/pmrukot","followers_url":"https://api.github.com/users/pmrukot/followers","following_url":"https://api.github.com/users/pmrukot/following{/other_user}","gists_url":"https://api.github.com/users/pmrukot/gists{/gist_id}","starred_url":"https://api.github.com/users/pmrukot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pmrukot/subscriptions","organizations_url":"https://api.github.com/users/pmrukot/orgs","repos_url":"https://api.github.com/users/pmrukot/repos","events_url":"https://api.github.com/users/pmrukot/events{/privacy}","received_events_url":"https://api.github.com/users/pmrukot/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-10-07T13:30:09Z","updated_at":"2016-10-30T10:18:56Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Schibsted-Tech-Polska/HeroIn/pulls/1","html_url":"https://github.com/Schibsted-Tech-Polska/HeroIn/pull/1","diff_url":"https://github.com/Schibsted-Tech-Polska/HeroIn/pull/1.diff","patch_url":"https://github.com/Schibsted-Tech-Polska/HeroIn/pull/1.patch"},"body":"**PREFACE:**\r\nThis PR is about making attaching add-ons automated process. Since heroku-client is not supporting it and Heroku API Reference says it has prototype status ([reference](https://devcenter.heroku.com/articles/platform-api-reference#add-on-attachment)) it needs to be done from Heroku client level, not app level.\r\n\r\n\r\n**CHANGES:**\r\nMain change is in `addons.js`. \r\n\r\nFirst we need to pass client from `heroin.js` so we can make a call to attach addon. Now, during creating/updating an add-on we have two cases:\r\n\r\n1) *[update-level]* Assuming we usually do not provide custom name and let Heroku generate it, our configuration object looks like:\r\n\r\nBefore attaching add-on:\r\n```\r\naddons: {\r\n   librato: {plan: 'librato:development'}\r\n}\r\n```\r\n\r\nAfter attaching add-on:\r\n```\r\naddons: {\r\n   librato: {plan: 'librato:development', name: ‘sample-reference-name’},\r\n}\r\n```\r\n\r\nWhen we are updating existing addon, and `plan` attribute of an addon stays the same, and we change a `name` attribute, HeroIn will attach an existing add-on from another app (which we passed), and delete the old one. \r\nName is assumed to be a reference-name of an add-on we would like to attach. If ref-name that does not exist is provided - an exception is caught and nothing happens.\r\nIt also works when we actually have a custom ref-name for add-on.\r\n\r\nOtherwise, If plan changed we just update addon (just as before)\r\n \r\n2) *[creation-level]* When addon does not exist and we would like to create an attached one, we expect app.addons.create() to throw an error since you cannot have two add-ons with same reference-name. Then the exception is caught and we make a call to attach an add-on.\r\n\r\n\r\n**OTHER CHANGES:**\r\n1) Passing herokuClient to `addons.js` so we can make a call to attach add-on.\r\n2) Add name parameter to add-object in `appConfigBuilder.js` so we can check if everything works correctly.\r\n\r\n\r\n**TESTS:**\r\nI modified main integration test. Before it created an application and updated it. Now it creates 3 applications.\r\n\r\nThe first one is created and updated just as before.\r\n\r\nSecond one covers our first case - we create an application with redis add-on, and then we are updating our add-on since we would like to have same redis add-on, but attached from the first app. *[update-level]*\r\n\r\nAnd the third one covers our second case - we create an application and attach an add-on immediately from the first app. *[creation-level]*\r\n\r\nAnd it seems I needed to change names of test applications in `pipelineIntegrationTests.js` since it was throwing an error that such names already exist + added `after` to delete applications after running tests."},"comment":{"url":"https://api.github.com/repos/Schibsted-Tech-Polska/HeroIn/issues/comments/257142835","html_url":"https://github.com/Schibsted-Tech-Polska/HeroIn/pull/1#issuecomment-257142835","issue_url":"https://api.github.com/repos/Schibsted-Tech-Polska/HeroIn/issues/1","id":257142835,"user":{"login":"kwasniew","id":1394682,"avatar_url":"https://avatars.githubusercontent.com/u/1394682?v=3","gravatar_id":"","url":"https://api.github.com/users/kwasniew","html_url":"https://github.com/kwasniew","followers_url":"https://api.github.com/users/kwasniew/followers","following_url":"https://api.github.com/users/kwasniew/following{/other_user}","gists_url":"https://api.github.com/users/kwasniew/gists{/gist_id}","starred_url":"https://api.github.com/users/kwasniew/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kwasniew/subscriptions","organizations_url":"https://api.github.com/users/kwasniew/orgs","repos_url":"https://api.github.com/users/kwasniew/repos","events_url":"https://api.github.com/users/kwasniew/events{/privacy}","received_events_url":"https://api.github.com/users/kwasniew/received_events","type":"User","site_admin":false},"created_at":"2016-10-30T10:18:56Z","updated_at":"2016-10-30T10:18:56Z","body":"Ah, I didn't see the notification before. I'd have done it straight away. Reviewing right now and will merge soon. "}}
{"actor":{"display_login":"kwasniew"}}