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