1 | 'use strict'
|
2 |
|
3 | let co = require('co')
|
4 | let cli = require('heroku-cli-util')
|
5 |
|
6 | let flags = require('../../lib/flags.js')
|
7 | let endpoints = require('../../lib/endpoints.js')
|
8 | let formatEndpoint = require('../../lib/format_endpoint.js')
|
9 |
|
10 | function * run (context, heroku) {
|
11 | let endpoint = yield flags(context, heroku)
|
12 |
|
13 | let formattedEndpoint = formatEndpoint(endpoint)
|
14 |
|
15 | yield cli.confirmApp(context.app, context.flags.confirm, `Potentially Destructive Action\nThis command will remove the endpoint ${formattedEndpoint} from ${cli.color.app(context.app)}.`)
|
16 |
|
17 | let actions = yield {
|
18 | action: cli.action(`Removing SSL certificate ${formattedEndpoint} from ${cli.color.app(context.app)}`, {}, heroku.request({
|
19 | path: endpoint._meta.path,
|
20 | method: 'DELETE',
|
21 | headers: {'Accept': `application/vnd.heroku+json; version=3.${endpoint._meta.variant}`}
|
22 | })),
|
23 | hasAddon: endpoints.hasAddon(context.app, heroku)
|
24 | }
|
25 |
|
26 | if (actions.hasAddon) {
|
27 | cli.log('NOTE: Billing is still active. Remove SSL Endpoint add-on to stop billing.')
|
28 | }
|
29 | }
|
30 |
|
31 | module.exports = {
|
32 | topic: 'certs',
|
33 | command: 'remove',
|
34 | flags: [
|
35 | {name: 'confirm', hasValue: true, hidden: true},
|
36 | {name: 'name', hasValue: true, description: 'name to remove'},
|
37 | {name: 'endpoint', hasValue: true, description: 'endpoint to remove'}
|
38 | ],
|
39 | description: 'remove an SSL certificate from an app',
|
40 | needsApp: true,
|
41 | needsAuth: true,
|
42 | run: cli.command(co.wrap(run))
|
43 | }
|