File tree Expand file tree Collapse file tree 5 files changed +34
-16
lines changed Expand file tree Collapse file tree 5 files changed +34
-16
lines changed Original file line number Diff line number Diff line change @@ -199,17 +199,18 @@ Monitor for changes to sync to vault
199
199
200
200
```
201
201
USAGE
202
- $ vstool monitor [-h] [--broker-api-url <value>] [--broker-token <value>] [--vault-token <value>]
203
- [--vault-addr <value>] [--root <value>...]
202
+ $ vstool monitor [-h] [--broker-api-url <value>] [--broker-token <value>] [--monitor-interval <value>]
203
+ [--vault-token <value>] [--vault- addr <value>] [--root <value>...]
204
204
205
205
FLAGS
206
- -h, --help Show CLI help.
207
- --broker-api-url=<value> [default: https://broker.io.nrs.gov.bc.ca/] The broker api base url
208
- --broker-token=<value> The broker JWT
209
- --root=<value>... [default: ] The root to constrict the policy sync to. Some roots can be further
210
- constricted such as -root=apps -root=cool-app-war
211
- --vault-addr=<value> [default: http://127.0.0.1:8200] The vault address
212
- --vault-token=<value> [default: myroot] The vault token
206
+ -h, --help Show CLI help.
207
+ --broker-api-url=<value> [default: https://broker.io.nrs.gov.bc.ca/] The broker api base url
208
+ --broker-token=<value> The broker JWT
209
+ --monitor-interval=<value> [default: 60000] The duration between each monitor check in milliseconds
210
+ --root=<value>... [default: ] The root to constrict the policy sync to. Some roots can be further
211
+ constricted such as -root=apps -root=cool-app-war
212
+ --vault-addr=<value> [default: http://127.0.0.1:8200] The vault address
213
+ --vault-token=<value> [default: myroot] The vault token
213
214
214
215
DESCRIPTION
215
216
Monitor for changes to sync to vault
Original file line number Diff line number Diff line change 1
1
import { inject , injectable } from 'inversify' ;
2
2
import winston from 'winston' ;
3
- import { TYPES } from '../inversify.types' ;
4
3
import { exhaustMap , timer } from 'rxjs' ;
4
+ import { TYPES } from '../inversify.types' ;
5
5
import VaultPolicyController from '../vault/vault-policy.controller' ;
6
6
import VaultGroupController from '../vault/vault-group.controller' ;
7
7
import VaultApproleController from '../vault/vault-approle.controller' ;
@@ -24,8 +24,16 @@ export default class BrokerMonitorController {
24
24
private vaultPolicyController : VaultPolicyController ,
25
25
) { }
26
26
27
- public async monitor ( root : string [ ] ) {
28
- const source$ = timer ( 0 , 60000 ) ;
27
+ /**
28
+ * Monitor vault and sync changes
29
+ * @param root The policy roots to monitor
30
+ * @param monitorIntervalDuration The duration between each monitor check in milliseconds
31
+ */
32
+ public async monitor (
33
+ root : string [ ] ,
34
+ monitorIntervalDuration : number ,
35
+ ) : Promise < void > {
36
+ const source$ = timer ( 0 , monitorIntervalDuration ) ;
29
37
30
38
source$
31
39
. pipe (
Original file line number Diff line number Diff line change 5
5
brokerApiUrl ,
6
6
brokerToken ,
7
7
help ,
8
+ monitorIntervalDuration ,
8
9
root ,
9
10
vaultAddr ,
10
11
vaultToken ,
@@ -23,6 +24,7 @@ export default class Monitor extends Command {
23
24
...help ,
24
25
...brokerApiUrl ,
25
26
...brokerToken ,
27
+ ...monitorIntervalDuration ,
26
28
...vaultToken ,
27
29
...vaultAddr ,
28
30
...root ,
@@ -42,6 +44,6 @@ export default class Monitor extends Command {
42
44
43
45
await vsContainer
44
46
. get < BrokerMonitorController > ( TYPES . BrokerMonitorController )
45
- . monitor ( flags . root ) ;
47
+ . monitor ( flags . root , flags [ 'monitor-interval' ] ) ;
46
48
}
47
49
}
Original file line number Diff line number Diff line change @@ -20,6 +20,14 @@ export const brokerToken = {
20
20
} ) ,
21
21
} ;
22
22
23
+ export const monitorIntervalDuration = {
24
+ 'monitor-interval' : Flags . integer ( {
25
+ description : 'The duration between each monitor check in milliseconds' ,
26
+ default : 60 * 1000 ,
27
+ env : 'MONITOR_INTERVAL_DURATION' ,
28
+ } ) ,
29
+ } ;
30
+
23
31
export const secretShares = {
24
32
'secret-shares' : Flags . integer ( {
25
33
description : 'The number of shares to split the master key into' ,
@@ -33,7 +41,6 @@ export const secretThreshold = {
33
41
default : 1 ,
34
42
} ) ,
35
43
} ;
36
-
37
44
export const vaultAddr = {
38
45
'vault-addr' : Flags . string ( {
39
46
default : 'http://127.0.0.1:8200' ,
Original file line number Diff line number Diff line change 1
1
import { Container } from 'inversify' ;
2
+ import nv from 'node-vault' ;
3
+ import winston from 'winston' ;
2
4
import { logger } from './logger' ;
3
5
import { TYPES } from './inversify.types' ;
4
6
import { AppService } from './services/app.service' ;
5
7
import VaultPolicyController from './vault/vault-policy.controller' ;
6
8
import { vaultFactory } from './vault/vault.factory' ;
7
- import nv from 'node-vault' ;
8
9
import { ConfigService } from './services/config.service' ;
9
- import winston from 'winston' ;
10
10
import VaultGroupController from './vault/vault-group.controller' ;
11
11
import EnvironmentUtil from './util/environment.util' ;
12
12
import HclUtil from './util/hcl.util' ;
You can’t perform that action at this time.
0 commit comments