UNPKG

1.43 kBJavaScriptView Raw
1'use strict'
2
3let cli = require('heroku-cli-util')
4let co = require('co')
5const { SpaceCompletion } = require('@heroku-cli/command/lib/completions')
6
7function displayJSON (rules) {
8 cli.log(JSON.stringify(rules, null, 2))
9}
10
11function * run (context, heroku) {
12 let lib = require('../../lib/outbound-rules')(heroku)
13 let space = context.flags.space || context.args.space
14 if (!space) throw new Error('Space name required.\nUSAGE: heroku outbound-rules --space my-space')
15 let rules = yield lib.getOutboundRules(space)
16 if (context.flags.json) displayJSON(rules)
17 else lib.displayRules(space, rules)
18}
19
20module.exports = {
21 topic: 'outbound-rules',
22 description: 'list Outbound Rules for a space',
23 help: `
24Outbound Rules are only available on Private Spaces.
25
26Newly created spaces will have an "Allow All" rule set by default
27allowing all egress dyno traffic outside of the space. You can
28remove this default rule to completely stop your private dynos from
29talking to the world.
30
31You can add specific rules that only allow your dyno to communicate with trusted hosts.
32 `,
33 needsApp: false,
34 needsAuth: true,
35 hidden: true,
36 args: [{ name: 'space', optional: true, hidden: true }],
37 flags: [
38 { name: 'space', char: 's', hasValue: true, description: 'space to get outbound rules from', completion: SpaceCompletion },
39 { name: 'json', description: 'output in json format' }
40 ],
41 run: cli.command(co.wrap(run))
42}