ts: lib/config/dockerSecret.js

Signed-off-by: Raccoon <raccoon@hackmd.io>
This commit is contained in:
Raccoon 2021-06-12 07:10:14 +08:00
parent 3b52b19dc9
commit 10e77f34a5
No known key found for this signature in database
GPG Key ID: 06770355DC9ECD38

View File

@ -1,18 +1,17 @@
'use strict'
const fs = require('fs')
const path = require('path')
import * as fs from "fs";
import * as path from "path";
const basePath = path.resolve('/var/run/secrets/')
function getSecret (secret) {
function getSecret(secret) {
const filePath = path.join(basePath, secret)
if (fs.existsSync(filePath)) return fs.readFileSync(filePath)
return undefined
}
let dockerSecretConfig: any = {}
if (fs.existsSync(basePath)) {
module.exports = {
dockerSecretConfig = {
dbURL: getSecret('dburl'),
// ssl path
sslKeyPath: getSecret('sslkeypath'),
@ -77,3 +76,5 @@ if (fs.existsSync(basePath)) {
}
}
}
export = dockerSecretConfig