1 | 'use strict'
|
2 |
|
3 | let cli = require('heroku-cli-util')
|
4 | let co = require('co')
|
5 |
|
6 | function * run (context, heroku) {
|
7 | let lib = require('../../lib/peering')(heroku)
|
8 | let space = context.flags.space || context.args.space
|
9 | if (!space) throw new Error('Space name required.\nUSAGE: heroku spaces:peerings:destroy pcx-12345678 --space my-space')
|
10 | let pcxID = context.flags.pcxid || context.args.pcxid
|
11 | yield cli.confirmApp(pcxID, context.flags.confirm, `Destructive Action
|
12 | This command will attempt to destroy the peering connection ${cli.color.bold.red(pcxID)}`)
|
13 | yield lib.destroyPeeringRequest(space, pcxID)
|
14 | cli.log(`Tearing down peering connection ${cli.color.cyan.bold(pcxID)}`)
|
15 | }
|
16 |
|
17 | module.exports = {
|
18 | topic: 'spaces',
|
19 | command: 'peerings:destroy',
|
20 | description: 'destroys an active peering connection in a private space',
|
21 | help: `
|
22 | Example:
|
23 | $ heroku peerings:destroy pcx-4bd27022 --confirm pcx-4bd27022 --space example-space
|
24 | Tearing down peering connection pcx-4bd27022
|
25 | `,
|
26 | needsApp: false,
|
27 | needsAuth: true,
|
28 | args: [{name: 'pcxid', optional: true, hidden: true}],
|
29 | flags: [
|
30 | {name: 'pcxid', char: 'p', hasValue: true, description: 'PCX ID of a pending peering'},
|
31 | {name: 'space', char: 's', hasValue: true, description: 'space to get peering info from'},
|
32 | {name: 'confirm', hasValue: true, description: 'set to PCX ID to bypass confirm prompt'}
|
33 | ],
|
34 | run: cli.command(co.wrap(run))
|
35 | }
|