Repository navigation
Expand file tree
/
Copy pathpull.ts
More file actions
49 lines (41 loc) · 1.68 KB
/
Copy pathpull.ts
File metadata and controls
49 lines (41 loc) · 1.68 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
43
44
45
46
47
48
49
import {Command, flags, vars} from '@heroku-cli/command'
import * as Heroku from '@heroku-cli/schema'
import {color, hux} from '@heroku/heroku-cli-util'
import {debug} from '../../lib/container/debug.js'
import {DockerHelper} from '../../lib/container/docker-helper.js'
import {ensureContainerStack} from '../../lib/container/helpers.js'
export default class Pull extends Command {
static description = 'pulls an image from an app\'s process type'
static examples = [
`${color.command('heroku container:pull web')} # Pulls the web image from the app`,
`${color.command('heroku container:pull web worker')} # Pulls both the web and worker images from the app`,
`${color.command('heroku container:pull web:latest')} # Pulls the latest tag from the web image`,
]
static flags = {
app: flags.app({required: true}),
remote: flags.remote(),
verbose: flags.boolean({char: 'v'}),
}
static strict = false
static topic = 'container'
static usage = 'container:pull -a APP [-v] PROCESS_TYPE...'
dockerHelper = new DockerHelper()
async run() {
const {argv, flags} = await this.parse(Pull)
const {app, verbose} = flags
if (argv.length === 0) {
this.error(`Error: Requires one or more process types\n${Pull.examples.join('\n')}`)
}
const {body: appBody} = await this.heroku.get<Heroku.App>(`/apps/${app}`)
ensureContainerStack(appBody, 'pull')
const registry = `registry.${vars.host}`
if (verbose) {
debug.enabled = true
}
for (const process of argv as string[]) {
const tag = `${registry}/${app}/${process}`
hux.styledHeader(`Pulling ${process} as ${tag}`)
await this.dockerHelper.pullImage(tag)
}
}
}