5
0
Fork 0
mirror of https://github.com/hashicorp/vault-action.git synced 2025-11-08 07:36:56 +00:00

Use selectAndAppendResults for wildcard

This commit is contained in:
Keat Tang 2023-09-08 14:55:59 +10:00
parent 4c238e2453
commit 11c0abf682

View file

@ -59,6 +59,7 @@ async function getSecrets(secretRequests, client) {
for (let key in keys) { for (let key in keys) {
let newRequest = Object.assign({},secretRequest); let newRequest = Object.assign({},secretRequest);
newRequest.selector = key; newRequest.selector = key;
if (secretRequest.selector === secretRequest.outputVarName) { if (secretRequest.selector === secretRequest.outputVarName) {
newRequest.outputVarName = key; newRequest.outputVarName = key;
newRequest.envVarName = key; newRequest.envVarName = key;
@ -67,29 +68,20 @@ async function getSecrets(secretRequests, client) {
newRequest.outputVarName = secretRequest.outputVarName+key; newRequest.outputVarName = secretRequest.outputVarName+key;
newRequest.envVarName = secretRequest.envVarName+key; newRequest.envVarName = secretRequest.envVarName+key;
} }
newRequest.outputVarName = normalizeOutputKey(newRequest.outputVarName); newRequest.outputVarName = normalizeOutputKey(newRequest.outputVarName);
newRequest.envVarName = normalizeOutputKey(newRequest.envVarName,true); newRequest.envVarName = normalizeOutputKey(newRequest.envVarName,true);
selector = key; selector = key;
//This code (with exception of parsing body again and using newRequest instead of secretRequest) should match the else code for a single key results = await selectAndAppendResults(
if (!selector.match(/.*[\.].*/)) { selector,
selector = '"' + selector + '"' body,
} cachedResponse,
selector = "data." + selector newRequest,
results
if (body.data["data"] != undefined) { );
selector = "data." + selector
}
const value = await selectData(body, selector);
results.push({
request: newRequest,
value,
cachedResponse
});
} }
} }
else { else {
results = await selectAndAppendResults( results = await selectAndAppendResults(