1 | 'use strict'
|
2 |
|
3 | let cli = require('heroku-cli-util')
|
4 | let co = require('co')
|
5 |
|
6 | function * run (context, heroku) {
|
7 | let app = context.app
|
8 | let attachment = yield heroku.get(`/apps/${app}/addon-attachments/${context.args.attachment_name}`)
|
9 |
|
10 | yield cli.action(
|
11 | `Detaching ${cli.color.attachment(attachment.name)} to ${cli.color.addon(attachment.addon.name)} from ${cli.color.app(app)}`,
|
12 | heroku.request({
|
13 | path: `/addon-attachments/${attachment.id}`,
|
14 | method: 'DELETE'
|
15 | })
|
16 | )
|
17 |
|
18 | yield cli.action(
|
19 | `Unsetting ${cli.color.attachment(attachment.name)} config vars and restarting ${cli.color.app(app)}`,
|
20 | {success: false},
|
21 | co(function * () {
|
22 | let releases = yield heroku.request({
|
23 | path: `/apps/${app}/releases`,
|
24 | partial: true,
|
25 | headers: { 'Range': 'version ..; max=1, order=desc' }
|
26 | })
|
27 | cli.action.done(`done, v${releases[0].version}`)
|
28 | })
|
29 | )
|
30 | }
|
31 |
|
32 | module.exports = {
|
33 | topic: 'addons',
|
34 | command: 'detach',
|
35 | description: 'detach an add-on resource from an app',
|
36 | needsAuth: true,
|
37 | needsApp: true,
|
38 | args: [{name: 'attachment_name'}],
|
39 | run: cli.command({preauth: true}, co.wrap(run))
|
40 | }
|