Created
February 2, 2020 18:40
-
-
Save PatrickKalkman/fc8b2c68a28e011f037127056ad095b1 to your computer and use it in GitHub Desktop.
Reading secrets from the file system
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// dependencies | |
const fs = require('fs'); | |
const log = require('../log'); | |
const dockerSecret = {}; | |
dockerSecret.read = function read(secretNameAndPath) { | |
try { | |
return fs.readFileSync(`${secretNameAndPath}`, 'utf8'); | |
} catch(err) { | |
if (err.code !== 'ENOENT') { | |
log.error(`An error occurred while trying to read the secret: ${secretNameAndPath}. Err: ${err}`); | |
} else { | |
log.debug(`Could not find the secret, probably not running in swarm mode: ${secretNameAndPath}. Err: ${err}`); | |
} | |
return false; | |
} | |
}; | |
module.exports = dockerSecret; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment