mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
Added suffixes to integrations
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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: {
|
||||
|
||||
@@ -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
|
||||
});
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -35,3 +35,9 @@ Select which Infisical environment secrets you want to sync to Checkly and press
|
||||
|
||||

|
||||

|
||||
|
||||
<Info>
|
||||
In the new version of the Checkly integration, you are able to specify suffixes that depend on the secrets' environment and path.
|
||||
If you choose to do so, you should utilize such suffixes for ALL Checkly integrations – otherwise the integration system
|
||||
might run into issues with deleting secrets from the wrong environments.
|
||||
</Info>
|
||||
|
||||
@@ -40,7 +40,8 @@ export const useCreateIntegration = () => {
|
||||
owner,
|
||||
path,
|
||||
region,
|
||||
secretPath
|
||||
secretPath,
|
||||
secretSuffix
|
||||
}: {
|
||||
integrationAuthId: string;
|
||||
isActive: boolean;
|
||||
@@ -55,6 +56,7 @@ export const useCreateIntegration = () => {
|
||||
owner: string | null;
|
||||
path: string | null;
|
||||
region: string | null;
|
||||
secretSuffix: string;
|
||||
}) => {
|
||||
const { data: { integration } } = await apiRequest.post("/api/v1/integration", {
|
||||
integrationAuthId,
|
||||
@@ -69,7 +71,8 @@ export const useCreateIntegration = () => {
|
||||
owner,
|
||||
path,
|
||||
region,
|
||||
secretPath
|
||||
secretPath,
|
||||
secretSuffix
|
||||
});
|
||||
|
||||
return integration;
|
||||
|
||||
@@ -27,6 +27,7 @@ export type TIntegration = {
|
||||
integration: string;
|
||||
integrationAuth: string;
|
||||
secretPath: string;
|
||||
secretSuffix: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
__v: number;
|
||||
|
||||
@@ -35,6 +35,7 @@ export default function ChecklyCreateIntegrationPage() {
|
||||
|
||||
const [selectedSourceEnvironment, setSelectedSourceEnvironment] = useState("");
|
||||
const [secretPath, setSecretPath] = useState("/");
|
||||
const [secretSuffix, setSecretSuffix] = useState("");
|
||||
|
||||
const [targetApp, setTargetApp] = useState("");
|
||||
const [targetAppId, setTargetAppId] = useState("");
|
||||
@@ -78,7 +79,8 @@ export default function ChecklyCreateIntegrationPage() {
|
||||
owner: null,
|
||||
path: null,
|
||||
region: null,
|
||||
secretPath
|
||||
secretPath,
|
||||
secretSuffix
|
||||
});
|
||||
|
||||
setIsLoading(false);
|
||||
@@ -148,6 +150,13 @@ export default function ChecklyCreateIntegrationPage() {
|
||||
)}
|
||||
</Select>
|
||||
</FormControl>
|
||||
<FormControl label="Append the Secret Name with..." className="mt-4 px-6">
|
||||
<Input
|
||||
value={secretSuffix}
|
||||
onChange={(evt) => setSecretSuffix(evt.target.value)}
|
||||
placeholder="Provide a suffix for secret names, default is no suffix"
|
||||
/>
|
||||
</FormControl>
|
||||
<Button
|
||||
onClick={handleButtonClick}
|
||||
color="mineshaft"
|
||||
|
||||
@@ -115,6 +115,14 @@ export const IntegrationsSection = ({
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{(integration.integration === "checkly") && (
|
||||
<div className="ml-2 flex flex-col">
|
||||
<FormLabel label="Secret Suffix" />
|
||||
<div className="rounded-md border border-mineshaft-700 bg-mineshaft-900 px-3 py-2 font-inter text-sm text-bunker-200">
|
||||
{integration.secretSuffix || "-"}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex cursor-default items-center">
|
||||
<div className="ml-2 opacity-80 duration-200 hover:opacity-100">
|
||||
|
||||
Reference in New Issue
Block a user