UNPKG

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