-
Notifications
You must be signed in to change notification settings - Fork 1
/
robokit.js
41 lines (39 loc) · 1.29 KB
/
robokit.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
async function start () {
require('dotenv').config()
const vault = new (require('./app/vault/vault-api'))(process.env.VAULT_ADDR)
process.on('uncaughtException', (err) => {
console.error(err)
})
vault.k8sLogin(
process.env.VAULT_ROLE,
process.env.VAULT_JWT_PATH)
.then(async token => {
vault.read(token.client_token, process.env.VAULT_SECRETS_PATH)
.then(async values => {
for (var key in values) {
process.env[key] = values[key]
}
const options = {
id: process.env.APP_ID,
port: process.env.PORT || 3000,
secret: process.env.WEBHOOK_SECRET,
cert: process.env.PRIVATE_KEY,
webhookProxy: process.env.WEBHOOK_PROXY_URL
}
const p = require('probot')
const probot = p.createProbot(options)
const robokit = require('./index.js')
probot.setup([robokit])
probot.start()
}).catch(err => {
console.log(`ERROR reading variables from vault \n
VAULT_SECRETS_PATH:${process.env.VAULT_SECRETS_PATH}\n
VAULT_ADDR:${process.env.VAULT_ADDR}
error:` + err.message)
})
}).catch(err => {
console.log('k8sLogin failed with error:')
console.error(err)
})
}
start()