Skip to content

Commit

Permalink
Update: return error if key doesnt exist in secret (#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
alewitt2 authored Sep 8, 2020
1 parent 6d7b17d commit 703f006
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/BaseController.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,11 @@ module.exports = class BaseController {

async getSecretData(name, key, ns, returnAsBuffer = false) {
let res = await this.kubeResourceMeta.request({ uri: `/api/v1/namespaces/${ns || this.namespace}/secrets/${name}`, json: true });
let secret = Buffer.from(objectPath.get(res, ['data', key], ''), 'base64');
let base64KeyData = objectPath.get(res, ['data', key]);
if (base64KeyData === undefined) {
return Promise.reject(`key '${key}' in secret '${name}' from namespace '${ns}' not found`);
}
let secret = Buffer.from(base64KeyData, 'base64');
return returnAsBuffer ? secret : secret.toString();
}
// ===========================================
Expand Down

0 comments on commit 703f006

Please sign in to comment.