UNPKG

1.26 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/trusted-ips')(heroku)
12 let space = context.flags.space || context.args.space
13 if (!space) throw new Error('Space name required.\nUSAGE: heroku trusted-ips my-space')
14 let rules = yield lib.getRules(space)
15 if (context.flags.json) displayJSON(rules)
16 else lib.displayRules(space, rules)
17}
18
19module.exports = {
20 topic: 'trusted-ips',
21 description: 'list trusted IP ranges for a space',
22 help: `
23Trusted IP ranges are only available on Private Spaces.
24
25The space name is a required parameter. Newly created spaces will have 0.0.0.0/0 set by default
26allowing all traffic to applications in the space. More than one CIDR block can be provided at
27a time to the commands listed below. For example 1.2.3.4/20 and 5.6.7.8/20 can be added with:
28 `,
29 needsApp: false,
30 needsAuth: true,
31 args: [{name: 'space', optional: true, hidden: true}],
32 flags: [
33 {name: 'space', char: 's', hasValue: true, description: 'space to get inbound rules from'},
34 {name: 'json', description: 'output in json format'}
35 ],
36 run: cli.command(co.wrap(run))
37}