Fix(Azure Key Vault): Ignore disabled secrets

This commit is contained in:
McPizza0
2024-11-26 23:22:07 +01:00
parent 92ce05283b
commit 6cf2488326
@@ -516,12 +516,18 @@ const syncSecretsAzureKeyVault = async ({
if (!lastSlashIndex) { if (!lastSlashIndex) {
lastSlashIndex = getAzureKeyVaultSecret.id.lastIndexOf("/"); lastSlashIndex = getAzureKeyVaultSecret.id.lastIndexOf("/");
} }
if (!getAzureKeyVaultSecret.attributes.enabled) return null;
const azureKeyVaultSecret = await request.get(`${getAzureKeyVaultSecret.id}?api-version=7.3`, { let azureKeyVaultSecret;
try {
azureKeyVaultSecret = await request.get(`${getAzureKeyVaultSecret.id}?api-version=7.3`, {
headers: { headers: {
Authorization: `Bearer ${accessToken}` Authorization: `Bearer ${accessToken}`
} }
}); });
} catch (err) {
throw new Error(`Failed to fetch Azure Key Vault secret: ${(err as Error).message}`);
}
return { return {
...azureKeyVaultSecret.data, ...azureKeyVaultSecret.data,
@@ -529,7 +535,9 @@ const syncSecretsAzureKeyVault = async ({
}; };
}) })
) )
).reduce( )
.filter((secret) => secret !== null)
.reduce(
(obj, secret) => ({ (obj, secret) => ({
...obj, ...obj,
[secret.key]: secret [secret.key]: secret