-
Notifications
You must be signed in to change notification settings - Fork 215
/
update.js
54 lines (44 loc) · 2.04 KB
/
update.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
'use strict'
let cli = require('heroku-cli-util')
let flags = require('../../lib/flags.js')
let displayWarnings = require('../../lib/display_warnings.js')
let formatEndpoint = require('../../lib/format_endpoint.js')
let certificateDetails = require('../../lib/certificate_details.js')
let getCertAndKey = require('../../lib/get_cert_and_key.js')
async function run(context, heroku) {
let endpoint = await flags(context, heroku)
let files = await getCertAndKey(context)
let formattedEndpoint = formatEndpoint(endpoint)
await cli.confirmApp(context.app, context.flags.confirm, `Potentially Destructive Action\nThis command will change the certificate of endpoint ${formattedEndpoint} from ${cli.color.app(context.app)}.`)
let cert = await cli.action(`Updating SSL certificate ${formattedEndpoint} for ${cli.color.app(context.app)}`, {}, heroku.request({
path: endpoint._meta.path,
method: 'PATCH',
headers: {Accept: `application/vnd.heroku+json; version=3.${endpoint._meta.variant}`},
body: {certificate_chain: files.crt, private_key: files.key},
}))
certificateDetails(cert, 'Updated certificate details:')
displayWarnings(cert)
}
module.exports = {
topic: 'certs',
command: 'update',
variableArgs: true,
args: [
{name: 'CRT', optional: false},
{name: 'KEY', optional: false},
],
flags: [
{name: 'bypass', description: 'bypass the trust chain completion step', hasValue: false},
{name: 'confirm', hasValue: true, hidden: true},
{name: 'name', hasValue: true, description: 'name to update'},
{name: 'endpoint', hasValue: true, description: 'endpoint to update'},
],
description: 'update an SSL certificate on an app',
help: 'Note: certificates with PEM encoding are also valid',
examples: `$ heroku certs:update example.com.crt example.com.key
If you require intermediate certificates, refer to this article on merging certificates to get a complete chain:
https://help.salesforce.com/s/articleView?id=000333504&type=1`,
needsApp: true,
needsAuth: true,
run: cli.command({preauth: true}, run),
}