mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-15 11:38:55 +00:00
Added Qovery integration
This commit is contained in:
@@ -9,6 +9,8 @@ import {
|
||||
Environment,
|
||||
IntegrationAuth,
|
||||
NorthflankSecretGroup,
|
||||
Org,
|
||||
Project,
|
||||
Service,
|
||||
Team,
|
||||
TeamCityBuildConfig} from "./types";
|
||||
@@ -27,6 +29,31 @@ const integrationAuthKeys = {
|
||||
integrationAuthId: string;
|
||||
appId: string;
|
||||
}) => [{ integrationAuthId, appId }, "integrationAuthVercelBranches"] as const,
|
||||
getIntegrationAuthQoveryOrgs: (integrationAuthId: string) =>
|
||||
[{ integrationAuthId }, "integrationAuthQoveryOrgs"] as const,
|
||||
getIntegrationAuthQoveryProjects: ({
|
||||
integrationAuthId,
|
||||
orgId
|
||||
}: {
|
||||
integrationAuthId: string;
|
||||
orgId: string;
|
||||
}) => [{ integrationAuthId, orgId }, "integrationAuthQoveryProjects"] as const,
|
||||
getIntegrationAuthQoveryEnvironments: ({
|
||||
integrationAuthId,
|
||||
projectId
|
||||
}: {
|
||||
integrationAuthId: string;
|
||||
projectId: string;
|
||||
}) => [{ integrationAuthId, projectId }, "integrationAuthQoveryEnvironments"] as const,
|
||||
getIntegrationAuthQoveryScopes: ({
|
||||
integrationAuthId,
|
||||
environmentId,
|
||||
scope
|
||||
}: {
|
||||
integrationAuthId: string;
|
||||
environmentId: string;
|
||||
scope: "Job" | "Application" | "Container";
|
||||
}) => [{ integrationAuthId, environmentId, scope }, "integrationAuthQoveryScopes"] as const,
|
||||
getIntegrationAuthRailwayEnvironments: ({
|
||||
integrationAuthId,
|
||||
appId
|
||||
@@ -120,6 +147,115 @@ const fetchIntegrationAuthVercelBranches = async ({
|
||||
return branches;
|
||||
};
|
||||
|
||||
const fetchIntegrationAuthQoveryOrgs = async (integrationAuthId: string) => {
|
||||
const {
|
||||
data: { orgs }
|
||||
} = await apiRequest.get<{ orgs: Org[] }>(
|
||||
`/api/v1/integration-auth/${integrationAuthId}/qovery/orgs`
|
||||
);
|
||||
|
||||
return orgs;
|
||||
};
|
||||
|
||||
const fetchIntegrationAuthQoveryProjects = async ({
|
||||
integrationAuthId,
|
||||
orgId
|
||||
}: {
|
||||
integrationAuthId: string;
|
||||
orgId: string;
|
||||
}) => {
|
||||
const {
|
||||
data: { projects }
|
||||
} = await apiRequest.get<{ projects: Project[] }>(
|
||||
`/api/v1/integration-auth/${integrationAuthId}/qovery/projects`,
|
||||
{
|
||||
params: {
|
||||
orgId
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
return projects;
|
||||
};
|
||||
|
||||
const fetchIntegrationAuthQoveryEnvironments = async ({
|
||||
integrationAuthId,
|
||||
projectId
|
||||
}: {
|
||||
integrationAuthId: string;
|
||||
projectId: string;
|
||||
}) => {
|
||||
const {
|
||||
data: { environments }
|
||||
} = await apiRequest.get<{ environments: Environment[] }>(
|
||||
`/api/v1/integration-auth/${integrationAuthId}/qovery/environments`,
|
||||
{
|
||||
params: {
|
||||
projectId
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
return environments;
|
||||
};
|
||||
|
||||
const fetchIntegrationAuthQoveryScopes = async ({
|
||||
integrationAuthId,
|
||||
environmentId,
|
||||
scope
|
||||
}: {
|
||||
integrationAuthId: string;
|
||||
environmentId: string;
|
||||
scope: "Job" | "Application" | "Container";
|
||||
}) => {
|
||||
if (scope === "Application") {
|
||||
const {
|
||||
data: { apps }
|
||||
} = await apiRequest.get<{ apps: App[] }>(
|
||||
`/api/v1/integration-auth/${integrationAuthId}/qovery/apps`,
|
||||
{
|
||||
params: {
|
||||
environmentId
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
return apps;
|
||||
}
|
||||
|
||||
if (scope === "Container") {
|
||||
const {
|
||||
data: { containers }
|
||||
} = await apiRequest.get<{ containers: App[] }>(
|
||||
`/api/v1/integration-auth/${integrationAuthId}/qovery/containers`,
|
||||
{
|
||||
params: {
|
||||
environmentId
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
return containers;
|
||||
}
|
||||
|
||||
if (scope === "Job") {
|
||||
const {
|
||||
data: { jobs }
|
||||
} = await apiRequest.get<{ jobs: App[] }>(
|
||||
`/api/v1/integration-auth/${integrationAuthId}/qovery/jobs`,
|
||||
{
|
||||
params: {
|
||||
environmentId
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
return jobs;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
};
|
||||
|
||||
const fetchIntegrationAuthRailwayEnvironments = async ({
|
||||
integrationAuthId,
|
||||
appId
|
||||
@@ -269,6 +405,82 @@ export const useGetIntegrationAuthVercelBranches = ({
|
||||
});
|
||||
};
|
||||
|
||||
export const useGetIntegrationAuthQoveryOrgs = (integrationAuthId: string) => {
|
||||
return useQuery({
|
||||
queryKey: integrationAuthKeys.getIntegrationAuthQoveryOrgs(integrationAuthId),
|
||||
queryFn: () =>
|
||||
fetchIntegrationAuthQoveryOrgs(integrationAuthId),
|
||||
enabled: true
|
||||
});
|
||||
};
|
||||
|
||||
export const useGetIntegrationAuthQoveryProjects = ({
|
||||
integrationAuthId,
|
||||
orgId
|
||||
}: {
|
||||
integrationAuthId: string;
|
||||
orgId: string;
|
||||
}) => {
|
||||
return useQuery({
|
||||
queryKey: integrationAuthKeys.getIntegrationAuthQoveryProjects({
|
||||
integrationAuthId,
|
||||
orgId
|
||||
}),
|
||||
queryFn: () =>
|
||||
fetchIntegrationAuthQoveryProjects({
|
||||
integrationAuthId,
|
||||
orgId
|
||||
}),
|
||||
enabled: true
|
||||
});
|
||||
};
|
||||
|
||||
export const useGetIntegrationAuthQoveryEnvironments = ({
|
||||
integrationAuthId,
|
||||
projectId
|
||||
}: {
|
||||
integrationAuthId: string;
|
||||
projectId: string;
|
||||
}) => {
|
||||
return useQuery({
|
||||
queryKey: integrationAuthKeys.getIntegrationAuthQoveryEnvironments({
|
||||
integrationAuthId,
|
||||
projectId
|
||||
}),
|
||||
queryFn: () =>
|
||||
fetchIntegrationAuthQoveryEnvironments({
|
||||
integrationAuthId,
|
||||
projectId
|
||||
}),
|
||||
enabled: true
|
||||
});
|
||||
};
|
||||
|
||||
export const useGetIntegrationAuthQoveryScopes = ({
|
||||
integrationAuthId,
|
||||
environmentId,
|
||||
scope
|
||||
}: {
|
||||
integrationAuthId: string;
|
||||
environmentId: string;
|
||||
scope: "Job" | "Application" | "Container";
|
||||
}) => {
|
||||
return useQuery({
|
||||
queryKey: integrationAuthKeys.getIntegrationAuthQoveryScopes({
|
||||
integrationAuthId,
|
||||
environmentId,
|
||||
scope
|
||||
}),
|
||||
queryFn: () =>
|
||||
fetchIntegrationAuthQoveryScopes({
|
||||
integrationAuthId,
|
||||
environmentId,
|
||||
scope
|
||||
}),
|
||||
enabled: true
|
||||
});
|
||||
};
|
||||
|
||||
export const useGetIntegrationAuthRailwayEnvironments = ({
|
||||
integrationAuthId,
|
||||
appId
|
||||
|
||||
@@ -26,6 +26,21 @@ export type Environment = {
|
||||
environmentId: string;
|
||||
};
|
||||
|
||||
export type Container = {
|
||||
name: string;
|
||||
containerId: string;
|
||||
};
|
||||
|
||||
export type Org = {
|
||||
name: string;
|
||||
orgId: string;
|
||||
};
|
||||
|
||||
export type Project = {
|
||||
name: string;
|
||||
projectId: string;
|
||||
};
|
||||
|
||||
export type Service = {
|
||||
name: string;
|
||||
serviceId: string;
|
||||
|
||||
@@ -59,6 +59,13 @@ export const useCreateIntegration = () => {
|
||||
metadata?: {
|
||||
secretPrefix?: string;
|
||||
secretSuffix?: string;
|
||||
org?: string;
|
||||
orgId?: string;
|
||||
project?: string;
|
||||
projectId?: string;
|
||||
environment?: string;
|
||||
environmentId?: string;
|
||||
scope?: string;
|
||||
}
|
||||
}) => {
|
||||
const { data: { integration } } = await apiRequest.post("/api/v1/integration", {
|
||||
|
||||
@@ -32,5 +32,9 @@ export type TIntegration = {
|
||||
__v: number;
|
||||
metadata?: {
|
||||
secretSuffix?: string;
|
||||
scope: string;
|
||||
org: string;
|
||||
project: string;
|
||||
environment: string;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user