Added suffixes to integrations

This commit is contained in:
Vladyslav Matsiiako
2023-08-29 22:17:48 -07:00
parent 85e5822ece
commit f6be86a26b
10 changed files with 50 additions and 6 deletions
@@ -30,7 +30,8 @@ export const createIntegration = async (req: Request, res: Response) => {
owner,
path,
region,
secretPath
secretPath,
secretSuffix
} = req.body;
const folders = await Folder.findOne({
@@ -64,6 +65,7 @@ export const createIntegration = async (req: Request, res: Response) => {
path,
region,
secretPath,
secretSuffix,
integration: req.integrationAuth.integration,
integrationAuth: new Types.ObjectId(integrationAuthId)
}).save();
+1 -1
View File
@@ -2066,7 +2066,7 @@ const syncSecretsCheckly = async ({
}
for await (const key of Object.keys(getSecretsRes)) {
if (!(key in secrets)) {
if (!(key in secrets) && key.endsWith(integration?.secretSuffix)) {
// delete secret
await standardRequest.delete(`${INTEGRATION_CHECKLY_API_URL}/v1/variables/${key}`, {
headers: {
+6
View File
@@ -45,6 +45,7 @@ export interface IIntegration {
path: string;
region: string;
secretPath: string;
secretSuffix: string;
integration:
| "azure-key-vault"
| "aws-parameter-store"
@@ -183,6 +184,11 @@ const integrationSchema = new Schema<IIntegration>(
type: String,
required: true,
default: "/",
},
secretSuffix: {
type: String,
required: false,
default: "",
}
},
{
@@ -36,6 +36,14 @@ syncSecretsToThirdPartyServices.process(async (job: Job) => {
secretPath: integration.secretPath
});
const suffixedSecrets: any = {};
if (integration?.secretSuffix) {
for (const key in secrets) {
const newKey = key + integration?.secretSuffix;
suffixedSecrets[newKey] = secrets[key];
}
}
const integrationAuth = await IntegrationAuth.findById(integration.integrationAuth);
if (!integrationAuth) throw new Error("Failed to find integration auth");
@@ -49,7 +57,7 @@ syncSecretsToThirdPartyServices.process(async (job: Job) => {
await syncSecrets({
integration,
integrationAuth,
secrets,
secrets: Object.keys(suffixedSecrets).length !== 0 ? suffixedSecrets : secrets,
accessId: access.accessId === undefined ? null : access.accessId,
accessToken: access.accessToken
});
+1
View File
@@ -29,6 +29,7 @@ router.post(
body("isActive").exists().isBoolean(),
body("appId").trim(),
body("secretPath").default("/").isString().trim(),
body("secretSuffix").default("").isString().trim(),
body("sourceEnvironment").trim(),
body("targetEnvironment").trim(),
body("targetEnvironmentId").trim(),