mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
Remove Sentry, part-try-catch from sync Checkly
This commit is contained in:
@@ -201,10 +201,6 @@ const syncSecrets = async ({
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch (err) {
|
|
||||||
Sentry.setUser(null);
|
|
||||||
Sentry.captureException(err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1686,85 +1682,79 @@ const syncSecretsCheckly = async ({
|
|||||||
secrets: any;
|
secrets: any;
|
||||||
accessToken: string;
|
accessToken: string;
|
||||||
}) => {
|
}) => {
|
||||||
try {
|
// get secrets from travis-ci
|
||||||
// get secrets from travis-ci
|
const getSecretsRes = (
|
||||||
const getSecretsRes = (
|
await standardRequest.get(
|
||||||
await standardRequest.get(
|
`${INTEGRATION_CHECKLY_API_URL}/v1/variables`,
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
"Authorization": `Bearer ${accessToken}`,
|
||||||
|
"Accept-Encoding": "application/json",
|
||||||
|
"X-Checkly-Account": integration.appId
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.data
|
||||||
|
.reduce((obj: any, secret: any) => ({
|
||||||
|
...obj,
|
||||||
|
[secret.key]: secret.value
|
||||||
|
}), {});
|
||||||
|
|
||||||
|
// add secrets
|
||||||
|
for await (const key of Object.keys(secrets)) {
|
||||||
|
if (!(key in getSecretsRes)) {
|
||||||
|
// case: secret does not exist in checkly
|
||||||
|
// -> add secret
|
||||||
|
await standardRequest.post(
|
||||||
`${INTEGRATION_CHECKLY_API_URL}/v1/variables`,
|
`${INTEGRATION_CHECKLY_API_URL}/v1/variables`,
|
||||||
|
{
|
||||||
|
key,
|
||||||
|
value: secrets[key] ? secrets[key] : 'EMPTY'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
"Authorization": `Bearer ${accessToken}`,
|
"Authorization": `Bearer ${accessToken}`,
|
||||||
"Accept-Encoding": "application/json",
|
"Accept": "application/json",
|
||||||
|
"Content-Type": "application/json",
|
||||||
"X-Checkly-Account": integration.appId
|
"X-Checkly-Account": integration.appId
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
)
|
);
|
||||||
)
|
} else {
|
||||||
.data
|
// case: secret exists in checkly
|
||||||
.reduce((obj: any, secret: any) => ({
|
// -> update/set secret
|
||||||
...obj,
|
await standardRequest.put(
|
||||||
[secret.key]: secret.value
|
`${INTEGRATION_CHECKLY_API_URL}/v1/variables/${key}`,
|
||||||
}), {});
|
{
|
||||||
|
value: secrets[key] ? secrets[key] : 'EMPTY'
|
||||||
// add secrets
|
},
|
||||||
for await (const key of Object.keys(secrets)) {
|
{
|
||||||
if (!(key in getSecretsRes)) {
|
headers: {
|
||||||
// case: secret does not exist in checkly
|
"Authorization": `Bearer ${accessToken}`,
|
||||||
// -> add secret
|
"Content-Type": "application/json",
|
||||||
await standardRequest.post(
|
"Accept": "application/json",
|
||||||
`${INTEGRATION_CHECKLY_API_URL}/v1/variables`,
|
"X-Checkly-Account": integration.appId
|
||||||
{
|
|
||||||
key,
|
|
||||||
value: secrets[key] ? secrets[key] : 'EMPTY'
|
|
||||||
},
|
},
|
||||||
{
|
}
|
||||||
headers: {
|
);
|
||||||
"Authorization": `Bearer ${accessToken}`,
|
|
||||||
"Accept": "application/json",
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-Checkly-Account": integration.appId
|
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
// case: secret exists in checkly
|
|
||||||
// -> update/set secret
|
|
||||||
await standardRequest.put(
|
|
||||||
`${INTEGRATION_CHECKLY_API_URL}/v1/variables/${key}`,
|
|
||||||
{
|
|
||||||
value: secrets[key] ? secrets[key] : 'EMPTY'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
headers: {
|
|
||||||
"Authorization": `Bearer ${accessToken}`,
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"Accept": "application/json",
|
|
||||||
"X-Checkly-Account": integration.appId
|
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for await (const key of Object.keys(getSecretsRes)) {
|
for await (const key of Object.keys(getSecretsRes)) {
|
||||||
if (!(key in secrets)){
|
if (!(key in secrets)){
|
||||||
// delete secret
|
// delete secret
|
||||||
await standardRequest.delete(
|
await standardRequest.delete(
|
||||||
`${INTEGRATION_CHECKLY_API_URL}/v1/variables/${key}`,
|
`${INTEGRATION_CHECKLY_API_URL}/v1/variables/${key}`,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
"Authorization": `Bearer ${accessToken}`,
|
"Authorization": `Bearer ${accessToken}`,
|
||||||
"Accept": "application/json",
|
"Accept": "application/json",
|
||||||
"X-Checkly-Account": integration.appId
|
"X-Checkly-Account": integration.appId
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (err) {
|
|
||||||
Sentry.setUser(null);
|
|
||||||
Sentry.captureException(err);
|
|
||||||
throw new Error("Failed to sync secrets to Checkly");
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user