mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-05 19:26:38 +00:00
Replace Promise.all with for-await Vercel getting envars
This commit is contained in:
@@ -558,44 +558,80 @@ const syncSecretsVercel = async ({
|
|||||||
: {}),
|
: {}),
|
||||||
};
|
};
|
||||||
|
|
||||||
const res = (
|
// const res = (
|
||||||
await Promise.all(
|
// await Promise.all(
|
||||||
(
|
// (
|
||||||
await axios.get(
|
// await axios.get(
|
||||||
`${INTEGRATION_VERCEL_API_URL}/v9/projects/${integration.app}/env`,
|
// `${INTEGRATION_VERCEL_API_URL}/v9/projects/${integration.app}/env`,
|
||||||
|
// {
|
||||||
|
// params,
|
||||||
|
// headers: {
|
||||||
|
// Authorization: `Bearer ${accessToken}`,
|
||||||
|
// 'Accept-Encoding': 'application/json'
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// ))
|
||||||
|
// .data
|
||||||
|
// .envs
|
||||||
|
// .filter((secret: VercelSecret) => secret.target.includes(integration.targetEnvironment))
|
||||||
|
// .map(async (secret: VercelSecret) => {
|
||||||
|
// if (secret.type === 'encrypted') {
|
||||||
|
// // case: secret is encrypted -> need to decrypt
|
||||||
|
// const decryptedSecret = (await axios.get(
|
||||||
|
// `${INTEGRATION_VERCEL_API_URL}/v9/projects/${integration.app}/env/${secret.id}`,
|
||||||
|
// {
|
||||||
|
// params,
|
||||||
|
// headers: {
|
||||||
|
// Authorization: `Bearer ${accessToken}`,
|
||||||
|
// 'Accept-Encoding': 'application/json'
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// )).data;
|
||||||
|
|
||||||
|
// return decryptedSecret;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return secret;
|
||||||
|
// }))).reduce((obj: any, secret: any) => ({
|
||||||
|
// ...obj,
|
||||||
|
// [secret.key]: secret
|
||||||
|
// }), {});
|
||||||
|
|
||||||
|
const vercelSecrets: VercelSecret[] = (await axios.get(
|
||||||
|
`${INTEGRATION_VERCEL_API_URL}/v9/projects/${integration.app}/env`,
|
||||||
|
{
|
||||||
|
params,
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${accessToken}`,
|
||||||
|
'Accept-Encoding': 'application/json'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
))
|
||||||
|
.data
|
||||||
|
.envs
|
||||||
|
.filter((secret: VercelSecret) => secret.target.includes(integration.targetEnvironment));
|
||||||
|
|
||||||
|
const res: { [key: string]: VercelSecret } = {};
|
||||||
|
|
||||||
|
for await (const vercelSecret of vercelSecrets) {
|
||||||
|
if (vercelSecret.type === 'encrypted') {
|
||||||
|
// case: secret is encrypted -> need to decrypt
|
||||||
|
const decryptedSecret = (await axios.get(
|
||||||
|
`${INTEGRATION_VERCEL_API_URL}/v9/projects/${integration.app}/env/${vercelSecret.id}`,
|
||||||
{
|
{
|
||||||
params,
|
params,
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${accessToken}`,
|
Authorization: `Bearer ${accessToken}`,
|
||||||
'Accept-Encoding': 'application/json'
|
'Accept-Encoding': 'application/json'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
))
|
)).data;
|
||||||
.data
|
|
||||||
.envs
|
|
||||||
.filter((secret: VercelSecret) => secret.target.includes(integration.targetEnvironment))
|
|
||||||
.map(async (secret: VercelSecret) => {
|
|
||||||
if (secret.type === 'encrypted') {
|
|
||||||
// case: secret is encrypted -> need to decrypt
|
|
||||||
const decryptedSecret = (await axios.get(
|
|
||||||
`${INTEGRATION_VERCEL_API_URL}/v9/projects/${integration.app}/env/${secret.id}`,
|
|
||||||
{
|
|
||||||
params,
|
|
||||||
headers: {
|
|
||||||
Authorization: `Bearer ${accessToken}`,
|
|
||||||
'Accept-Encoding': 'application/json'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)).data;
|
|
||||||
|
|
||||||
return decryptedSecret;
|
res[vercelSecret.key] = decryptedSecret;
|
||||||
}
|
} else {
|
||||||
|
res[vercelSecret.key] = vercelSecret;
|
||||||
return secret;
|
}
|
||||||
}))).reduce((obj: any, secret: any) => ({
|
}
|
||||||
...obj,
|
|
||||||
[secret.key]: secret
|
|
||||||
}), {});
|
|
||||||
|
|
||||||
const updateSecrets: VercelSecret[] = [];
|
const updateSecrets: VercelSecret[] = [];
|
||||||
const deleteSecrets: VercelSecret[] = [];
|
const deleteSecrets: VercelSecret[] = [];
|
||||||
|
|||||||
Reference in New Issue
Block a user