mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
Update qovery integration
This commit is contained in:
@@ -406,7 +406,7 @@ export const getIntegrationAuthQoveryProjects = async (req: Request, res: Respon
|
||||
params: { integrationAuthId },
|
||||
query: { orgId }
|
||||
} = await validateRequest(reqValidator.GetIntegrationAuthQoveryProjectsV1, req);
|
||||
|
||||
|
||||
// TODO(akhilmhdh): remove class -> static function path and makes these into reusable independent functions
|
||||
const { integrationAuth, accessToken } = await getIntegrationAuthAccessHelper({
|
||||
integrationAuthId: new ObjectId(integrationAuthId)
|
||||
@@ -420,28 +420,37 @@ export const getIntegrationAuthQoveryProjects = async (req: Request, res: Respon
|
||||
ProjectPermissionActions.Read,
|
||||
ProjectPermissionSub.Integrations
|
||||
);
|
||||
|
||||
const { data } = await standardRequest.get(
|
||||
`${INTEGRATION_QOVERY_API_URL}/organization/${orgId}/project`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Token ${accessToken}`,
|
||||
"Accept": "application/json",
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
interface Project {
|
||||
name: string;
|
||||
projectId: string;
|
||||
}
|
||||
|
||||
interface QoveryProject {
|
||||
id: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
let projects: Project[] = [];
|
||||
|
||||
if (orgId && orgId !== "") {
|
||||
const { data } = await standardRequest.get(
|
||||
`${INTEGRATION_QOVERY_API_URL}/organization/${orgId}/project`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Token ${accessToken}`,
|
||||
"Accept": "application/json",
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
const projects = data.results.map((a: QoveryProject) => {
|
||||
return {
|
||||
name: a.name,
|
||||
projectId: a.id,
|
||||
};
|
||||
});
|
||||
projects = data.results.map((a: QoveryProject) => {
|
||||
return {
|
||||
name: a.name,
|
||||
projectId: a.id,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
return res.status(200).send({
|
||||
projects
|
||||
@@ -449,7 +458,7 @@ export const getIntegrationAuthQoveryProjects = async (req: Request, res: Respon
|
||||
};
|
||||
|
||||
/**
|
||||
* Return list of Qovery Environments for a specific projectId
|
||||
* Return list of Qovery environments for project with id [projectId]
|
||||
* @param req
|
||||
* @param res
|
||||
*/
|
||||
@@ -472,28 +481,37 @@ export const getIntegrationAuthQoveryEnvironments = async (req: Request, res: Re
|
||||
ProjectPermissionActions.Read,
|
||||
ProjectPermissionSub.Integrations
|
||||
);
|
||||
|
||||
const { data } = await standardRequest.get(
|
||||
`${INTEGRATION_QOVERY_API_URL}/project/${projectId}/environment`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Token ${accessToken}`,
|
||||
"Accept": "application/json",
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
interface Environment {
|
||||
name: string;
|
||||
environmentId: string;
|
||||
}
|
||||
|
||||
interface QoveryEnvironment {
|
||||
id: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
let environments: Environment[] = [];
|
||||
|
||||
if (projectId && projectId !== "" && projectId !== "none") { // TODO: fix
|
||||
const { data } = await standardRequest.get(
|
||||
`${INTEGRATION_QOVERY_API_URL}/project/${projectId}/environment`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Token ${accessToken}`,
|
||||
"Accept": "application/json",
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
const environments = data.results.map((a: QoveryEnvironment) => {
|
||||
return {
|
||||
name: a.name,
|
||||
environmentId: a.id,
|
||||
};
|
||||
});
|
||||
environments = data.results.map((a: QoveryEnvironment) => {
|
||||
return {
|
||||
name: a.name,
|
||||
environmentId: a.id,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
return res.status(200).send({
|
||||
environments
|
||||
@@ -501,7 +519,7 @@ export const getIntegrationAuthQoveryEnvironments = async (req: Request, res: Re
|
||||
};
|
||||
|
||||
/**
|
||||
* Return list of Qovery Apps for a specific environmentId
|
||||
* Return list of Qovery apps for environment with id [environmentId]
|
||||
* @param req
|
||||
* @param res
|
||||
*/
|
||||
@@ -524,28 +542,37 @@ export const getIntegrationAuthQoveryApps = async (req: Request, res: Response)
|
||||
ProjectPermissionActions.Read,
|
||||
ProjectPermissionSub.Integrations
|
||||
);
|
||||
|
||||
const { data } = await standardRequest.get(
|
||||
`${INTEGRATION_QOVERY_API_URL}/environment/${environmentId}/application`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Token ${accessToken}`,
|
||||
"Accept": "application/json",
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
interface App {
|
||||
name: string;
|
||||
appId: string;
|
||||
}
|
||||
|
||||
interface QoveryApp {
|
||||
id: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
let apps: App[] = [];
|
||||
|
||||
if (environmentId && environmentId !== "") {
|
||||
const { data } = await standardRequest.get(
|
||||
`${INTEGRATION_QOVERY_API_URL}/environment/${environmentId}/application`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Token ${accessToken}`,
|
||||
"Accept": "application/json",
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
const apps = data.results.map((a: QoveryApp) => {
|
||||
return {
|
||||
name: a.name,
|
||||
appId: a.id,
|
||||
};
|
||||
});
|
||||
apps = data.results.map((a: QoveryApp) => {
|
||||
return {
|
||||
name: a.name,
|
||||
appId: a.id,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
return res.status(200).send({
|
||||
apps
|
||||
@@ -553,7 +580,7 @@ export const getIntegrationAuthQoveryApps = async (req: Request, res: Response)
|
||||
};
|
||||
|
||||
/**
|
||||
* Return list of Qovery Containers for a specific environmentId
|
||||
* Return list of Qovery containers for environment with id [environmentId]
|
||||
* @param req
|
||||
* @param res
|
||||
*/
|
||||
@@ -576,28 +603,37 @@ export const getIntegrationAuthQoveryContainers = async (req: Request, res: Resp
|
||||
ProjectPermissionActions.Read,
|
||||
ProjectPermissionSub.Integrations
|
||||
);
|
||||
|
||||
const { data } = await standardRequest.get(
|
||||
`${INTEGRATION_QOVERY_API_URL}/environment/${environmentId}/container`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Token ${accessToken}`,
|
||||
"Accept": "application/json",
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
interface Container {
|
||||
name: string;
|
||||
appId: string;
|
||||
}
|
||||
|
||||
interface QoveryContainer {
|
||||
id: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
let containers: Container[] = [];
|
||||
|
||||
if (environmentId && environmentId !== "") {
|
||||
const { data } = await standardRequest.get(
|
||||
`${INTEGRATION_QOVERY_API_URL}/environment/${environmentId}/container`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Token ${accessToken}`,
|
||||
"Accept": "application/json",
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
const containers = data.results.map((a: QoveryContainer) => {
|
||||
return {
|
||||
name: a.name,
|
||||
appId: a.id,
|
||||
};
|
||||
});
|
||||
containers = data.results.map((a: QoveryContainer) => {
|
||||
return {
|
||||
name: a.name,
|
||||
appId: a.id,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
return res.status(200).send({
|
||||
containers
|
||||
@@ -605,7 +641,7 @@ export const getIntegrationAuthQoveryContainers = async (req: Request, res: Resp
|
||||
};
|
||||
|
||||
/**
|
||||
* Return list of Qovery Jobs for a specific environmentId
|
||||
* Return list of Qovery jobs for environment with id [environmentId]
|
||||
* @param req
|
||||
* @param res
|
||||
*/
|
||||
@@ -628,28 +664,37 @@ export const getIntegrationAuthQoveryJobs = async (req: Request, res: Response)
|
||||
ProjectPermissionActions.Read,
|
||||
ProjectPermissionSub.Integrations
|
||||
);
|
||||
|
||||
const { data } = await standardRequest.get(
|
||||
`${INTEGRATION_QOVERY_API_URL}/environment/${environmentId}/job`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Token ${accessToken}`,
|
||||
"Accept": "application/json",
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
interface Job {
|
||||
name: string;
|
||||
appId: string;
|
||||
}
|
||||
|
||||
interface QoveryJob {
|
||||
id: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
let jobs: Job[] = [];
|
||||
|
||||
if (environmentId && environmentId !== "") {
|
||||
const { data } = await standardRequest.get(
|
||||
`${INTEGRATION_QOVERY_API_URL}/environment/${environmentId}/job`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Token ${accessToken}`,
|
||||
"Accept": "application/json",
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
const jobs = data.results.map((a: QoveryJob) => {
|
||||
return {
|
||||
name: a.name,
|
||||
appId: a.id,
|
||||
};
|
||||
});
|
||||
jobs = data.results.map((a: QoveryJob) => {
|
||||
return {
|
||||
name: a.name,
|
||||
appId: a.id,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
return res.status(200).send({
|
||||
jobs
|
||||
|
||||
@@ -34,6 +34,7 @@ export const createIntegration = async (req: Request, res: Response) => {
|
||||
appId,
|
||||
owner,
|
||||
region,
|
||||
scope,
|
||||
targetService,
|
||||
targetServiceId,
|
||||
integrationAuthId,
|
||||
@@ -42,7 +43,7 @@ export const createIntegration = async (req: Request, res: Response) => {
|
||||
metadata
|
||||
}
|
||||
} = await validateRequest(reqValidator.CreateIntegrationV1, req);
|
||||
|
||||
|
||||
const integrationAuth = await IntegrationAuth.findById(integrationAuthId)
|
||||
.populate<{ workspace: IWorkspace }>("workspace")
|
||||
.select(
|
||||
@@ -90,6 +91,7 @@ export const createIntegration = async (req: Request, res: Response) => {
|
||||
owner,
|
||||
path,
|
||||
region,
|
||||
scope,
|
||||
secretPath,
|
||||
integration: integrationAuth.integration,
|
||||
integrationAuth: new Types.ObjectId(integrationAuthId),
|
||||
|
||||
@@ -2151,8 +2151,9 @@ const syncSecretsQovery = async ({
|
||||
secrets: Record<string, { value: string; comment?: string }>;
|
||||
accessToken: string;
|
||||
}) => {
|
||||
|
||||
const getSecretsRes = (
|
||||
await standardRequest.get(`${INTEGRATION_QOVERY_API_URL}/${integration.metadata?.scope?.toLowerCase()}/${integration.appId}/environmentVariable`, {
|
||||
await standardRequest.get(`${INTEGRATION_QOVERY_API_URL}/${integration.scope}/${integration.appId}/environmentVariable`, {
|
||||
headers: {
|
||||
Authorization: `Token ${accessToken}`,
|
||||
"Accept-Encoding": "application/json"
|
||||
@@ -2172,7 +2173,7 @@ const syncSecretsQovery = async ({
|
||||
// case: secret does not exist in qovery
|
||||
// -> add secret
|
||||
await standardRequest.post(
|
||||
`${INTEGRATION_QOVERY_API_URL}/${integration.metadata?.scope?.toLowerCase()}/${integration.appId}/environmentVariable`,
|
||||
`${INTEGRATION_QOVERY_API_URL}/${integration.scope}/${integration.appId}/environmentVariable`,
|
||||
{
|
||||
key,
|
||||
value: secrets[key].value
|
||||
@@ -2191,7 +2192,7 @@ const syncSecretsQovery = async ({
|
||||
|
||||
if (secrets[key].value !== getSecretsRes[key].value) {
|
||||
await standardRequest.put(
|
||||
`${INTEGRATION_QOVERY_API_URL}/${integration.metadata?.scope?.toLowerCase()}/${integration.appId}/environmentVariable/${getSecretsRes[key].id}`,
|
||||
`${INTEGRATION_QOVERY_API_URL}/${integration.scope}/${integration.appId}/environmentVariable/${getSecretsRes[key].id}`,
|
||||
{
|
||||
key,
|
||||
value: secrets[key].value
|
||||
|
||||
@@ -46,6 +46,7 @@ export interface IIntegration {
|
||||
targetServiceId: string;
|
||||
path: string;
|
||||
region: string;
|
||||
scope: string;
|
||||
secretPath: string;
|
||||
integration:
|
||||
| "azure-key-vault"
|
||||
@@ -121,11 +122,13 @@ const integrationSchema = new Schema<IIntegration>(
|
||||
},
|
||||
targetService: {
|
||||
// railway-specific service
|
||||
// qovery-specific project
|
||||
type: String,
|
||||
default: null,
|
||||
},
|
||||
targetServiceId: {
|
||||
// railway-specific service
|
||||
// qovery specific project
|
||||
type: String,
|
||||
default: null,
|
||||
},
|
||||
@@ -145,6 +148,11 @@ const integrationSchema = new Schema<IIntegration>(
|
||||
type: String,
|
||||
default: null,
|
||||
},
|
||||
scope: {
|
||||
// qovery-specific scope
|
||||
type: String,
|
||||
default: null
|
||||
},
|
||||
integration: {
|
||||
type: String,
|
||||
enum: [
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
|
||||
// TODO: in the future separate metadata
|
||||
// into distinct types by integration
|
||||
export type Metadata = {
|
||||
secretPrefix?: string;
|
||||
secretSuffix?: string;
|
||||
@@ -8,5 +5,4 @@ export type Metadata = {
|
||||
labelName: string;
|
||||
labelValue: string;
|
||||
}
|
||||
scope?: "Job" | "Application" | "Container";
|
||||
}
|
||||
@@ -76,6 +76,7 @@ export const CreateIntegrationV1 = z.object({
|
||||
owner: z.string().trim().optional(),
|
||||
path: z.string().trim().optional(),
|
||||
region: z.string().trim().optional(),
|
||||
scope: z.string().trim().optional(),
|
||||
metadata: z.object({
|
||||
secretPrefix: z.string().optional(),
|
||||
secretSuffix: z.string().optional(),
|
||||
@@ -83,13 +84,6 @@ export const CreateIntegrationV1 = z.object({
|
||||
labelName: z.string(),
|
||||
labelValue: z.string()
|
||||
}).optional(),
|
||||
org: z.string().optional(),
|
||||
orgId: z.string().optional(),
|
||||
project: z.string().optional(),
|
||||
projectId: z.string().optional(),
|
||||
environment: z.string().optional(),
|
||||
environmentId: z.string().optional(),
|
||||
scope: z.string().optional()
|
||||
}).optional()
|
||||
})
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user