Created
January 19, 2021 15:40
-
-
Save mrsimonemms/c3d1d219c5f50aa663d91ebd69a59929 to your computer and use it in GitHub Desktop.
Getting OpenFaaS secrets
This file contains 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
const { promises: fs } = require('fs'); | |
/** | |
* Get Secret | |
* | |
* Get a secret | |
* | |
* @link https://docs.openfaas.com/reference/secrets/#use-the-secret-in-your-function | |
* @param {string} secretName | |
* @returns {Promise<string>} | |
*/ | |
async function getSecret(secretName) { | |
try { | |
return await fs.readFile(`/var/openfaas/secrets/${secretName}`, 'utf8'); | |
} catch (err) { | |
/* Legacy/Docker Compose location */ | |
return fs.readFile(`/run/secrets/${secretName}`, 'utf8'); | |
} | |
} |
This file contains 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
import { promises as fs } from 'fs'; | |
/** | |
* Get Secret | |
* | |
* Get a secret | |
* | |
* @link https://docs.openfaas.com/reference/secrets/#use-the-secret-in-your-function | |
* @param {string} secretName | |
* @returns {Promise<string>} | |
*/ | |
async function getSecret(secretName) { | |
try { | |
return await fs.readFile(`/var/openfaas/secrets/${secretName}`, 'utf8'); | |
} catch { | |
/* Legacy/Docker Compose location */ | |
return fs.readFile(`/run/secrets/${secretName}`, 'utf8'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment