feature: add ignoreNotFound option (#518)

* add ignoreNotFound option

* update README
This commit is contained in:
John-Michael Faircloth 2024-02-01 08:42:56 -06:00 committed by GitHub
parent d523bb05b2
commit efab57ede0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 49 additions and 3 deletions

View file

@ -1,6 +1,8 @@
const jsonata = require("jsonata");
const { WILDCARD } = require("./constants");
const { normalizeOutputKey } = require("./utils");
const core = require('@actions/core');
/**
* @typedef {Object} SecretRequest
* @property {string} path
@ -21,7 +23,7 @@ const { normalizeOutputKey } = require("./utils");
* @param {import('got').Got} client
* @return {Promise<SecretResponse<TRequest>[]>}
*/
async function getSecrets(secretRequests, client) {
async function getSecrets(secretRequests, client, ignoreNotFound) {
const responseCache = new Map();
let results = [];
@ -42,7 +44,14 @@ async function getSecrets(secretRequests, client) {
} catch (error) {
const {response} = error;
if (response?.statusCode === 404) {
throw Error(`Unable to retrieve result for "${path}" because it was not found: ${response.body.trim()}`)
notFoundMsg = `Unable to retrieve result for "${path}" because it was not found: ${response.body.trim()}`;
const ignoreNotFound = (core.getInput('ignoreNotFound', { required: false }) || 'false').toLowerCase() != 'false';
if (ignoreNotFound) {
core.error(`${notFoundMsg}`);
continue;
} else {
throw Error(notFoundMsg)
}
}
throw error
}