Skip to content
This repository was archived by the owner on Jul 26, 2022. It is now read-only.

Commit de20a1b

Browse files
pmuirFlydiverny
andauthored
feat: support isBinary for GCP (#353)
* feat: support isBinary for GCP Fixes #352 Signed-off-by: Pete Muir <[email protected]> * chore: jsdoc Co-authored-by: Markus Maga <[email protected]>
1 parent 1d9d237 commit de20a1b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/backends/gcp-secrets-manager-backend.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,19 @@ class GCPSecretsManagerBackend extends KVBackend {
1717
/**
1818
* Get secret property value from GCP Secrets Manager.
1919
* @param {string} key - Key used to store secret property value in GCP Secrets Manager.
20+
* @param {boolean} keyOptions.isBinary - Is the secret base64 encoded? Set to true to handle as binary.
2021
* @returns {Promise} Promise object representing secret property value.
2122
*/
22-
async _get ({ key }) {
23+
async _get ({ key, keyOptions }) {
2324
this._logger.info(`fetching secret ${key} from GCP Secret Manager`)
2425
const version = await this._client.accessSecretVersion({
2526
name: key
2627
})
2728
const secret = { value: version[0].payload.data.toString('utf8') }
29+
// Handle binary files - this is useful when you've stored a base64 encoded string
30+
if (keyOptions && keyOptions.isBinary) {
31+
return Buffer.from(secret.value, 'base64')
32+
}
2833
return JSON.stringify(secret)
2934
}
3035
}

0 commit comments

Comments
 (0)