Skip to content

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

merge conflict resolve

Aashish-Upadhyay-101d537bd2f5840
diff --cc backend/src/integrations/apps.ts
index 90889b6232,b1db6f227b..43e8aa64d2
--- a/backend/src/integrations/apps.ts
+++ b/backend/src/integrations/apps.ts
@@@ -413,56 -401,4 +408,56 @@@ const getAppsTravisCI = async ({ access
return apps;
}
+/**
+ * Return list of repositories for GitLab integration
+ * @param {Object} obj
+ * @param {String} obj.accessToken - access token for GitLab API
+ * @returns {Object[]} apps - names of GitLab sites
+ * @returns {String} apps.name - name of GitLab site
+ */
+const getAppsGitlab = async ({ accessToken }: {accessToken: string}) => {
+ let apps;
+ console.log(accessToken);
+
+ try {
+ const { id } = (
- await axios.get(
++ await request.get(
+ `${INTEGRATION_GITLAB_API_URL}/v4/user`,
+ {
+ headers: {
+ "Authorization": `Bearer ${accessToken}`,
+ "Accept-Encoding": "application/json",
+ },
+ }
+ )
+ ).data;
+
+ const res = (
- await axios.get(
++ await request.get(
+ `${INTEGRATION_GITLAB_API_URL}/v4/users/${id}/projects`,
+ {
+ headers: {
+ "Authorization": `Bearer ${accessToken}`,
+ "Accept-Encoding": "application/json",
+ },
+ }
+ )
+ ).data;
+
+ apps = res?.map((a: any) => {
+ return {
+ name: a?.name,
+ appId: `${a?.id}`,
+ }
+ });
+ }catch (err) {
+ Sentry.setUser(null);
+ Sentry.captureException(err);
+ throw new Error("Failed to get GitLab repos");
+ }
+
+ console.log(apps);
+ return apps;
+}
+
export { getApps };
diff --cc backend/src/integrations/sync.ts
index a2d48f7aa5,ca3b23bbdf..c3db64b39c
--- a/backend/src/integrations/sync.ts
+++ b/backend/src/integrations/sync.ts
@@@ -1431,101 -1419,10 +1429,101 @@@ const syncSecretsTravisCI = async (
);
}
}
- }catch (err) {
+ } catch (err) {
Sentry.setUser(null);
Sentry.captureException(err);
- throw new Error("Failed to sync secrets to CircleCI");
- throw new Error("Failed to sync secrets to TravisCI");
++ throw new Error("Failed to sync secrets to GitLab");
+ }
+}
+
+/**
+ * Sync/push [secrets] to GitLab repo with name [integration.app]
+ * @param {Object} obj
+ * @param {IIntegration} obj.integration - integration details
+ * @param {IIntegrationAuth} obj.integrationAuth - integration auth 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 GitLab integration
+ */
+const syncSecretsGitLab = async ({
+ integration,
+ secrets,
+ accessToken,
+}: {
+ integration: IIntegration;
+ secrets: any;
+ accessToken: string;
+}) => {
+ try {
+ // get secrets from gitlab
+ const getSecretsRes = (
- await axios.get(
++ await request.get(
+ `${INTEGRATION_GITLAB_API_URL}/v4/projects/${integration?.appId}/variables`,
+ {
+ headers: {
+ "Authorization": `Bearer ${accessToken}`,
+ "Accept-Encoding": "application/json",
+ },
+ }
+ )
+ ).data;
+
+ for (const key of Object.keys(secrets)) {
+ const existingSecret = getSecretsRes.find((s: any) => s.key == key);
+ if (!existingSecret) {
- await axios.post(
++ await request.post(
+ `${INTEGRATION_GITLAB_API_URL}/v4/projects/${integration?.appId}/variables`,
+ {
+ key: key,
+ value: secrets[key],
+ protected: false,
+ masked: false,
+ raw: false,
+ environment_scope:'*'
+ },
+ {
+ headers: {
+ "Authorization": `Bearer ${accessToken}`,
+ "Content-Type": "application/json",
+ "Accept-Encoding": "application/json",
+ },
+ }
+ )
+ }else {
+ // udpate secret
- await axios.put(
++ await request.put(
+ `${INTEGRATION_GITLAB_API_URL}/v4/projects/${integration?.appId}/variables/${existingSecret.key}`,
+ {
+ ...existingSecret,
+ value: secrets[existingSecret.key]
+ },
+ {
+ headers: {
+ "Authorization": `Bearer ${accessToken}`,
+ "Content-Type": "application/json",
+ "Accept-Encoding": "application/json",
+ },
+ }
+ )
+ }
+ }
+
+ // delete secrets
+ for (let sec of getSecretsRes) {
+ if (!(sec.key in secrets)) {
- await axios.delete(
++ await request.delete(
+ `${INTEGRATION_GITLAB_API_URL}/v4/projects/${integration?.appId}/variables/${sec.key}`,
+ {
+ headers: {
+ "Authorization": `Bearer ${accessToken}`,
+ },
+ }
+ );
+ }
+ }
+ }catch (err) {
+ Sentry.setUser(null);
+ Sentry.captureException(err);
+ throw new Error("Failed to sync secrets to GitLab");
}
}