1 | 'use strict'
|
2 |
|
3 | let cli = require('heroku-cli-util')
|
4 | let co = require('co')
|
5 |
|
6 | function displayJSON (rules) {
|
7 | cli.log(JSON.stringify(rules, null, 2))
|
8 | }
|
9 |
|
10 | function * 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 |
|
19 | module.exports = {
|
20 | topic: 'outbound-rules',
|
21 | description: 'list Outbound Rules for a space',
|
22 | help: `
|
23 | Outbound Rules are only available on Private Spaces.
|
24 |
|
25 | Newly created spaces will have an "Allow All" rule set by default
|
26 | allowing all egress dyno traffic outside of the space. You can
|
27 | remove this default rule to completely stop your private dynos from
|
28 | talking to the world.
|
29 |
|
30 | You 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 | }
|