mirror of
https://github.com/hashicorp/vault-action.git
synced 2025-11-07 15:16:56 +00:00
Removed unused code
This commit is contained in:
parent
5ecd962b6d
commit
ef3b3ccce1
3 changed files with 26 additions and 10 deletions
5
.vscode/settings.json
vendored
5
.vscode/settings.json
vendored
|
|
@ -1,3 +1,4 @@
|
|||
{
|
||||
"markdown-toc.depthFrom": 2
|
||||
}
|
||||
"markdown-toc.depthFrom": 2,
|
||||
"editor.formatOnSave": false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
const jsonata = require("jsonata");
|
||||
const { normalizeOutputKey, wildcard} = require('./action');
|
||||
const { wildcard } = require('./action');
|
||||
const { normalizeOutputKey } = require('./utils');
|
||||
/**
|
||||
* @typedef {Object} SecretRequest
|
||||
* @property {string} path
|
||||
|
|
@ -75,22 +76,17 @@ async function getSecrets(secretRequests, client) {
|
|||
selector = '"' + selector + '"'
|
||||
}
|
||||
selector = "data." + selector
|
||||
//body = JSON.parse(body)
|
||||
|
||||
if (body.data["data"] != undefined) {
|
||||
selector = "data." + selector
|
||||
}
|
||||
const value = selectData(body, selector);
|
||||
const value = await selectData(body, selector);
|
||||
results.push({
|
||||
request: newRequest,
|
||||
value,
|
||||
cachedResponse
|
||||
});
|
||||
|
||||
//DEBUG
|
||||
//console.log("After", newRequest, value);
|
||||
|
||||
// used cachedResponse for first entry in wildcard list and set to true for the rest
|
||||
cachedResponse = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
19
src/utils.js
Normal file
19
src/utils.js
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
/**
|
||||
* Replaces any dot chars to __ and removes non-ascii charts
|
||||
* @param {string} dataKey
|
||||
* @param {boolean=} isEnvVar
|
||||
*/
|
||||
function normalizeOutputKey(dataKey, isEnvVar = false) {
|
||||
let outputKey = dataKey
|
||||
.replace(".", "__")
|
||||
.replace(new RegExp("-", "g"), "")
|
||||
.replace(/[^\p{L}\p{N}_-]/gu, "");
|
||||
if (isEnvVar) {
|
||||
outputKey = outputKey.toUpperCase();
|
||||
}
|
||||
return outputKey;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
normalizeOutputKey
|
||||
};
|
||||
Loading…
Reference in a new issue