mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-15 10:35:17 +00:00
Requested changes
This commit is contained in:
@@ -459,10 +459,9 @@ const getAppsFlyio = async ({ accessToken }: { accessToken: string }) => {
|
||||
* Return list of projects for CircleCI integration
|
||||
*/
|
||||
const getAppsCircleCI = async ({ accessToken }: { accessToken: string }) => {
|
||||
// Fetch collaborations (v2 API)
|
||||
const collaborations = (
|
||||
await request.get<{ id: string; name: string; slug: string }[]>(
|
||||
`${IntegrationUrls.CIRCLECI_API_URL}/v2/me/collaborations`,
|
||||
const res = (
|
||||
await request.get<{ reponame: string; username: string; vcs_url: string }[]>(
|
||||
`${IntegrationUrls.CIRCLECI_API_URL}/v1.1/projects`,
|
||||
{
|
||||
headers: {
|
||||
"Circle-Token": accessToken,
|
||||
@@ -472,9 +471,10 @@ const getAppsCircleCI = async ({ accessToken }: { accessToken: string }) => {
|
||||
)
|
||||
).data;
|
||||
|
||||
const apps = collaborations.map((a) => ({
|
||||
name: a.name,
|
||||
appId: a.id
|
||||
const apps = res.map((a) => ({
|
||||
owner: a.username, // username maps to unique organization name in CircleCI
|
||||
name: a.reponame, // reponame maps to project name within an organization in CircleCI
|
||||
appId: a.vcs_url.split("/").pop() // vcs_url maps to the project id in CircleCI
|
||||
}));
|
||||
|
||||
return apps;
|
||||
|
||||
@@ -143,12 +143,6 @@ export type TBitbucketWorkspace = {
|
||||
updated_on: string;
|
||||
};
|
||||
|
||||
export enum CircleCiVcsType {
|
||||
GitHub = "GitHub",
|
||||
CircleCI = "CircleCI",
|
||||
BitBucket = "BitBucket"
|
||||
}
|
||||
|
||||
export type TNorthflankSecretGroup = {
|
||||
id: string;
|
||||
name: string;
|
||||
|
||||
@@ -35,7 +35,7 @@ import { TCreateManySecretsRawFn, TUpdateManySecretsRawFn } from "@app/services/
|
||||
|
||||
import { TIntegrationDALFactory } from "../integration/integration-dal";
|
||||
import { IntegrationMetadataSchema } from "../integration/integration-schema";
|
||||
import { CircleCiVcsType, TIntegrationsWithEnvironment } from "./integration-auth-types";
|
||||
import { TIntegrationsWithEnvironment } from "./integration-auth-types";
|
||||
import {
|
||||
IntegrationInitialSyncBehavior,
|
||||
IntegrationMappingBehavior,
|
||||
@@ -1929,8 +1929,9 @@ const syncSecretsCircleCI = async ({
|
||||
secrets: Record<string, { value: string; comment?: string }>;
|
||||
accessToken: string;
|
||||
}) => {
|
||||
const circleciOrganizationDetail = (
|
||||
await request.get<{ slug: string; name: string }[]>(`${IntegrationUrls.CIRCLECI_API_URL}/v2/me/collaborations`, {
|
||||
let projectSlug: string | null = null;
|
||||
const projectDetails = (
|
||||
await request.get<{ slug: string }>(`${IntegrationUrls.CIRCLECI_API_URL}/v2/project/${integration.appId}`, {
|
||||
headers: {
|
||||
"Circle-Token": accessToken,
|
||||
"Accept-Encoding": "application/json"
|
||||
@@ -1938,30 +1939,7 @@ const syncSecretsCircleCI = async ({
|
||||
})
|
||||
).data;
|
||||
|
||||
let projectSlug: string | null = null;
|
||||
if (!integration.owner) {
|
||||
projectSlug = `${circleciOrganizationDetail[0].slug}/${integration.app}`;
|
||||
} else {
|
||||
const projectDetails = (
|
||||
await request.get<{ vcs_info: { provider: CircleCiVcsType } }>(
|
||||
`${IntegrationUrls.CIRCLECI_API_URL}/v2/project/${integration.app}`,
|
||||
{
|
||||
headers: {
|
||||
"Circle-Token": accessToken,
|
||||
"Accept-Encoding": "application/json"
|
||||
}
|
||||
}
|
||||
)
|
||||
).data;
|
||||
|
||||
const vcsProviderMap: Record<CircleCiVcsType, string> = {
|
||||
[CircleCiVcsType.GitHub]: "gh",
|
||||
[CircleCiVcsType.BitBucket]: "bb",
|
||||
[CircleCiVcsType.CircleCI]: "circleci"
|
||||
};
|
||||
|
||||
projectSlug = `${vcsProviderMap[projectDetails.vcs_info.provider]}/${integration.owner}/${integration.app}`;
|
||||
}
|
||||
projectSlug = `${projectDetails.slug}`;
|
||||
|
||||
// sync secrets to CircleCI
|
||||
await Promise.all(
|
||||
|
||||
Reference in New Issue
Block a user