Repository navigation
Expand file tree
/
Copy pathupgrade.ts
More file actions
42 lines (36 loc) · 1.61 KB
/
Copy pathupgrade.ts
File metadata and controls
42 lines (36 loc) · 1.61 KB
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
import {Command, flags} from '@heroku-cli/command'
import * as color from '@heroku/heroku-cli-util/color'
import {Args, ux} from '@oclif/core'
import tsheredoc from 'tsheredoc'
import ConfirmCommand from '../../lib/confirm-command.js'
import redisApi, {RedisApiResponse} from '../../lib/redis/api.js'
const heredoc = tsheredoc
export default class Upgrade extends Command {
static args = {
database: Args.string({description: 'name of the Key-Value Store database. If omitted, it defaults to the primary database associated with the app.'}),
}
static description = 'perform in-place version upgrade'
static flags = {
app: flags.app({required: true}),
confirm: flags.string({char: 'c'}),
remote: flags.remote(),
version: flags.string({char: 'v', required: true}),
}
static topic = 'redis'
public async run(): Promise<void> {
const {args, flags} = await this.parse(Upgrade)
const {app, confirm, version} = flags
const {database} = args
const addon = await redisApi(app, database, false, this.heroku).getRedisAddon()
const warning = heredoc(`
WARNING: Irreversible action.
Redis database will be upgraded to ${color.code(version)}. This cannot be undone.
`)
const confirmCommand = new ConfirmCommand()
await confirmCommand.confirm(app, confirm, warning)
ux.action.start(`Requesting upgrade of ${color.addon(addon.name || '')} to ${version}`)
const {body: response} = await redisApi(app, database, false, this.heroku)
.request<RedisApiResponse>(`/redis/v0/databases/${addon.id}/upgrade`, 'POST', {version})
ux.action.stop(response.message)
}
}