mirror of
https://github.com/hashicorp/vault-action.git
synced 2025-11-08 23:56:55 +00:00
* waiting for result of evaluate to account for jsonata v2 changes
This commit is contained in:
parent
1be4af3494
commit
9a3a2ee48b
1 changed files with 4 additions and 4 deletions
|
|
@ -55,7 +55,7 @@ async function getSecrets(secretRequests, client) {
|
||||||
selector = "data." + selector
|
selector = "data." + selector
|
||||||
}
|
}
|
||||||
|
|
||||||
const value = selectData(body, selector);
|
const value = await selectData(body, selector);
|
||||||
results.push({
|
results.push({
|
||||||
request: secretRequest,
|
request: secretRequest,
|
||||||
value,
|
value,
|
||||||
|
|
@ -70,12 +70,12 @@ async function getSecrets(secretRequests, client) {
|
||||||
* @param {object} data
|
* @param {object} data
|
||||||
* @param {string} selector
|
* @param {string} selector
|
||||||
*/
|
*/
|
||||||
function selectData(data, selector) {
|
async function selectData(data, selector) {
|
||||||
const ata = jsonata(selector);
|
const ata = jsonata(selector);
|
||||||
let result = JSON.stringify(ata.evaluate(data));
|
let result = JSON.stringify(await ata.evaluate(data));
|
||||||
// Compat for custom engines
|
// Compat for custom engines
|
||||||
if (!result && ((ata.ast().type === "path" && ata.ast()['steps'].length === 1) || ata.ast().type === "string") && selector !== 'data' && 'data' in data) {
|
if (!result && ((ata.ast().type === "path" && ata.ast()['steps'].length === 1) || ata.ast().type === "string") && selector !== 'data' && 'data' in data) {
|
||||||
result = JSON.stringify(jsonata(`data.${selector}`).evaluate(data));
|
result = JSON.stringify(await jsonata(`data.${selector}`).evaluate(data));
|
||||||
} else if (!result) {
|
} else if (!result) {
|
||||||
throw Error(`Unable to retrieve result for ${selector}. No match data was found. Double check your Key or Selector.`);
|
throw Error(`Unable to retrieve result for ${selector}. No match data was found. Double check your Key or Selector.`);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue