updated texts and comments

This commit is contained in:
Maidul Islam
2024-05-14 23:46:24 -04:00
committed by =
parent d4555f9698
commit c6352cc970
3 changed files with 32 additions and 10 deletions

View File

@@ -396,13 +396,34 @@ export const decryptSecretRaw = (
};
};
export const getAllNestedSecretReferences = (value: string) => {
const references = Array.from(value.matchAll(INTERPOLATION_SYNTAX_REG), (m) => m[1]);
/**
* Grabs and processes nested secret references from a string
*
* This function looks for patterns that match the interpolation syntax in the input string.
* It filters out references that include nested paths, splits them into environment and
* secret path parts, and then returns an array of objects with the environment and the
* joined secret path.
*
* @param {string} maybeSecretReference - The string that has the potential secret references.
* @returns {Array<{ environment: string, secretPath: string }>} - An array of objects
* with the environment and joined secret path.
*
* @example
* const value = "Hello ${dev.someFolder.OtherFolder.SECRET_NAME} and ${prod.anotherFolder.SECRET_NAME}";
* const result = getAllNestedSecretReferences(value);
* // result will be:
* // [
* // { environment: 'dev', secretPath: '/someFolder/OtherFolder' },
* // { environment: 'prod', secretPath: '/anotherFolder' }
* // ]
*/
export const getAllNestedSecretReferences = (maybeSecretReference: string) => {
const references = Array.from(maybeSecretReference.matchAll(INTERPOLATION_SYNTAX_REG), (m) => m[1]);
return references
.filter((el) => el.includes("."))
.map((el) => {
const [environment, ...secretPath] = el.split(".");
return { environment, secretPath: path.join("/", ...secretPath.slice(0, -1)) };
const [environment, ...secretPathList] = el.split(".");
return { environment, secretPath: path.join("/", ...secretPathList.slice(0, -1)) };
});
};

View File

@@ -1562,10 +1562,12 @@ export const secretServiceFactory = ({
actorOrgId
);
if (!hasRole(ProjectMembershipRole.Admin)) throw new BadRequestError({ message: "Only admins are allowed" });
if (!hasRole(ProjectMembershipRole.Admin))
throw new BadRequestError({ message: "Only admins are allowed to take this action" });
const botKey = await projectBotService.getBotKey(projectId);
if (!botKey) throw new BadRequestError({ message: "Kindly upgrade your project", name: "bot_not_found_error" });
if (!botKey)
throw new BadRequestError({ message: "Please upgrade your project first", name: "bot_not_found_error" });
await secretDAL.transaction(async (tx) => {
const secrets = await secretDAL.findAllProjectSecretValues(projectId, tx);
@@ -1584,7 +1586,7 @@ export const secretServiceFactory = ({
);
});
return { message: "Successfully backfilled secret references." };
return { message: "Successfully backfilled secret references" };
};
return {

View File

@@ -25,11 +25,10 @@ export const BackfillSecretReferenceSecretion = () => {
return (
<div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
<div className="flex w-full items-center justify-between">
<p className="text-xl font-semibold">Resync Secret References</p>
<p className="text-xl font-semibold">Sync Secret References</p>
</div>
<p className="mb-4 mt-2 max-w-2xl text-sm text-gray-400">
Trigger this to reindex all your inline secret references to map integration
synchronization.
This will index all secret references, enabling integrations to be triggered when their values change going forward.
</p>
<Button
variant="outline_bg"