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;
headers: { try {
Authorization: `Bearer ${accessToken}` azureKeyVaultSecret = await request.get(`${getAzureKeyVaultSecret.id}?api-version=7.3`, {
} headers: {
}); 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,13 +535,15 @@ const syncSecretsAzureKeyVault = async ({
}; };
}) })
) )
).reduce( )
(obj, secret) => ({ .filter((secret) => secret !== null)
...obj, .reduce(
[secret.key]: secret (obj, secret) => ({
}), ...obj,
{} [secret.key]: secret
); }),
{}
);
const setSecrets: { const setSecrets: {
key: string; key: string;