-
Notifications
You must be signed in to change notification settings - Fork 17
/
upgrade.js
61 lines (50 loc) · 1.73 KB
/
upgrade.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
55
56
57
58
59
60
61
'use strict'
let cli = require('heroku-cli-util')
let co = require('co')
let withCluster = require('../lib/clusters').withCluster
let request = require('../lib/clusters').request
const VERSION = 'v0'
function * upgradeCluster (context, heroku) {
yield withCluster(heroku, context.app, context.args.CLUSTER, function * (addon) {
yield cli.confirmApp(context.app, context.flags.confirm,
`This command will upgrade the brokers of the cluster to version ${context.flags.version}.`)
let msg = 'Upgrading '
if (context.args.CLUSTER) {
msg += context.args.CLUSTER + ' '
}
msg += `to version ${context.flags.version}`
cli.action.start(msg)
yield request(heroku, {
method: 'PUT',
body: {
version: context.flags.version
},
path: `/client/kafka/${VERSION}/clusters/${addon.id}/upgrade`
})
cli.action.done('started.\n\n')
cli.log('Upgrading versions on a cluster involves rolling restarts')
cli.log('and takes some time, depending on the size of the cluster')
cli.log()
cli.log('Use `heroku kafka:wait` to monitor the upgrade.')
})
}
module.exports = {
topic: 'kafka',
command: 'upgrade',
description: 'upgrades kafka broker version',
help: `
Upgrades the version running on the brokers
Example:
$ heroku kafka:upgrade --version 0.9
`,
needsApp: true,
needsAuth: true,
args: [
{ name: 'CLUSTER', optional: true }
],
flags: [
{ name: 'version', description: 'requested kafka version for upgrade', hasValue: true, required: true },
{ name: 'confirm', description: 'pass the app name to skip the manual confirmation prompt', hasValue: true }
],
run: cli.command({preauth: true}, co.wrap(upgradeCluster))
}