UNPKG

865 BJavaScriptView Raw
1const cli = require('heroku-cli-util')
2const log = require('../lib/log')
3const Sanbashi = require('../lib/sanbashi')
4
5module.exports = function (topic) {
6 return {
7 topic: topic,
8 command: 'logout',
9 flags: [{name: 'verbose', char: 'v', hasValue: false}],
10 description: 'logout from the Heroku Container Registry',
11 needsApp: false,
12 needsAuth: false,
13 run: cli.command(logout)
14 }
15}
16
17async function logout (context, heroku) {
18 let herokuHost = process.env.HEROKU_HOST || 'heroku.com'
19 let registry = `registry.${ herokuHost }`
20
21 try {
22 let user = await dockerLogout(registry, context.flags.verbose)
23 }
24 catch (err) {
25 cli.error(`Error: docker logout exited with ${ err }`)
26 }
27}
28
29function dockerLogout (registry, verbose) {
30 let args = [
31 'logout',
32 registry
33 ]
34 log(verbose, args)
35 return Sanbashi.cmd('docker', args)
36}