Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

Make sync function for Codefresh

Tuan Dange8fdaf571c5b
diff --git a/backend/src/integrations/sync.ts b/backend/src/integrations/sync.ts
index 93eaf22be0..26c447056d 100644
--- a/backend/src/integrations/sync.ts
+++ b/backend/src/integrations/sync.ts
@@ -225,7 +225,6 @@ const syncSecrets = async ({
case INTEGRATION_CODEFRESH:
await syncSecretsCodefresh({
integration,
- // integrationAuth,
secrets,
accessToken,
});
@@ -1923,17 +1922,13 @@ const syncSecretsCloudflarePages = async ({
);
}
-
/**
- * Sync/push [secrets] to codefresh with name [integration.app]
+ * Sync/push [secrets] to Codefresh with name [integration.app]
* @param {Object} obj
* @param {IIntegration} obj.integration - integration details
* @param {Object} obj.secrets - secrets to push to integration (object where keys are secret keys and values are secret values)
- * @param {String} obj.accessToken - access token for Supabase integration
+ * @param {String} obj.accessToken - access token for Codefresh integration
*/
-
-
-
const syncSecretsCodefresh = async ({
integration,
secrets,
@@ -1943,89 +1938,21 @@ const syncSecretsCodefresh = async ({
secrets: any;
accessToken: string;
}) => {
- // get variables from codefresh.
-
- // there is no endpoint to get secrets from codefresh
- // const getSecretsRes = (
- // await standardRequest.get(
- // `${INTEGRATION_CODEFRESH_API_URL}/api/pipelines/utils/extractVariables`,
- // {
- // headers: {
- // "Authorization": `Bearer ${accessToken}`,
- // "Accept-Encoding": "application/json",
- // },
- // }
- // )
- // )
- // .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 codefresh
- // // -> add secret
-
- // await standardRequest.post(
- // `${INTEGRATION_CODEFRESH_API_URL}/api/pipelines`,
- // {
- // spec: {
- // variables: [
- // {
- // key,
- // value: secrets[key],
- // }
- // ]
-
- // },
- // },
- // {
- // headers: {
- // "Authorization": `Bearer ${accessToken}`,
- // "Accept": "application/json",
- // "Content-Type": "application/json",
- // },
- // }
- // );
- // } else {
- // // case: secret exists in checkly
- // // -> update/set secret
-
- // if (secrets[key] !== getSecretsRes[key]) {
- // await standardRequest.put(
- // `${INTEGRATION_CODEFRESH_API_URL}/v1/variables/${key}`,
- // {
- // value: secrets[key],
- // },
- // {
- // headers: {
- // "Authorization": `Bearer ${accessToken}`,
- // "Content-Type": "application/json",
- // "Accept": "application/json",
- // },
- // }
- // );
- // }
- // }
- // }
-
- // for await (const key of Object.keys(getSecretsRes)) {
- // if (!(key in secrets)) {
- // // delete secret
- // await standardRequest.delete(
- // `${INTEGRATION_CODEFRESH_API_URL}/v1/variables/${key}`,
- // {
- // headers: {
- // "Authorization": `Bearer ${accessToken}`,
- // "Accept": "application/json",
- // },
- // }
- // );
- // }
- // }
+ await standardRequest.patch(
+ `${INTEGRATION_CODEFRESH_API_URL}/projects/${integration.appId}`,
+ {
+ variables: Object.keys(secrets).map((key) => ({
+ key,
+ value: secrets[key]
+ }))
+ },
+ {
+ headers: {
+ Authorization: `Bearer ${accessToken}`,
+ "Accept": "application/json",
+ },
+ }
+ );
};
export { syncSecrets };
diff --git a/backend/src/variables/integration.ts b/backend/src/variables/integration.ts
index 5eb50b583e..13e89a324a 100644
--- a/backend/src/variables/integration.ts
+++ b/backend/src/variables/integration.ts
@@ -25,7 +25,6 @@ export const INTEGRATION_SUPABASE = 'supabase';
export const INTEGRATION_CHECKLY = 'checkly';
export const INTEGRATION_HASHICORP_VAULT = 'hashicorp-vault';
export const INTEGRATION_CLOUDFLARE_PAGES = 'cloudflare-pages';
-// chisom
export const INTEGRATION_CODEFRESH = 'codefresh';
export const INTEGRATION_SET = new Set([
diff --git a/frontend/src/pages/integrations/codefresh/authorize.tsx b/frontend/src/pages/integrations/codefresh/authorize.tsx
index aebfd21391..17416ffaba 100644
--- a/frontend/src/pages/integrations/codefresh/authorize.tsx
+++ b/frontend/src/pages/integrations/codefresh/authorize.tsx
@@ -23,8 +23,8 @@ export default function CodefreshCreateIntegrationPage() {
const integrationAuth = await saveIntegrationAccessToken({
workspaceId: localStorage.getItem("projectData.id"),
integration: "codefresh",
- accessToken: apiKey,
accessId: null,
+ accessToken: apiKey,
url: null,
namespace: null
});
diff --git a/frontend/src/views/IntegrationsPage/components/IntegrationsSection/IntegrationsSection.tsx b/frontend/src/views/IntegrationsPage/components/IntegrationsSection/IntegrationsSection.tsx
index 65d1dc1caa..1fe734c966 100644
--- a/frontend/src/views/IntegrationsPage/components/IntegrationsSection/IntegrationsSection.tsx
+++ b/frontend/src/views/IntegrationsPage/components/IntegrationsSection/IntegrationsSection.tsx
@@ -32,8 +32,6 @@ export const IntegrationsSection = ({
const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([
"deleteConfirmation"
] as const);
-
- console.log(integrationSlugNameMapping, integrations, '>>>chisom')
return (
<div className="mb-8">
<div className="mx-4 mb-4 mt-6 flex flex-col items-start justify-between px-2 text-xl">