mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-15 19:16:22 +00:00
feat(secret-sync): Add gitlab secret sync
This commit is contained in:
@@ -25,5 +25,6 @@ export enum AppConnection {
|
||||
OnePass = "1password",
|
||||
Heroku = "heroku",
|
||||
Render = "render",
|
||||
Flyio = "flyio"
|
||||
Flyio = "flyio",
|
||||
Gitlab = "gitlab"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from "./queries";
|
||||
export * from "./types";
|
||||
@@ -0,0 +1,65 @@
|
||||
import { useQuery, UseQueryOptions } from "@tanstack/react-query";
|
||||
|
||||
import { apiRequest } from "@app/config/request";
|
||||
|
||||
import { appConnectionKeys } from "../queries";
|
||||
import { TGitLabGroup, TGitLabProject } from "./types";
|
||||
|
||||
const gitlabConnectionKeys = {
|
||||
all: [...appConnectionKeys.all, "gitlab"] as const,
|
||||
listProjects: (connectionId: string, group?: string) =>
|
||||
[...gitlabConnectionKeys.all, "projects", connectionId, group] as const,
|
||||
listGroups: (connectionId: string) =>
|
||||
[...gitlabConnectionKeys.all, "groups", connectionId] as const
|
||||
};
|
||||
|
||||
export const useGitlabConnectionListProjects = (
|
||||
connectionId: string,
|
||||
group?: string,
|
||||
options?: Omit<
|
||||
UseQueryOptions<
|
||||
TGitLabProject[],
|
||||
unknown,
|
||||
TGitLabProject[],
|
||||
ReturnType<typeof gitlabConnectionKeys.listProjects>
|
||||
>,
|
||||
"queryKey" | "queryFn"
|
||||
>
|
||||
) => {
|
||||
return useQuery({
|
||||
queryKey: gitlabConnectionKeys.listProjects(connectionId, group),
|
||||
queryFn: async () => {
|
||||
const { data } = await apiRequest.get<TGitLabProject[]>(
|
||||
`/api/v1/app-connections/gitlab/${connectionId}/projects${group ? `?group=${group}` : ""}`
|
||||
);
|
||||
|
||||
return data;
|
||||
},
|
||||
...options
|
||||
});
|
||||
};
|
||||
|
||||
export const useGitlabConnectionListGroups = (
|
||||
connectionId: string,
|
||||
options?: Omit<
|
||||
UseQueryOptions<
|
||||
TGitLabGroup[],
|
||||
unknown,
|
||||
TGitLabGroup[],
|
||||
ReturnType<typeof gitlabConnectionKeys.listGroups>
|
||||
>,
|
||||
"queryKey" | "queryFn"
|
||||
>
|
||||
) => {
|
||||
return useQuery({
|
||||
queryKey: gitlabConnectionKeys.listGroups(connectionId),
|
||||
queryFn: async () => {
|
||||
const { data } = await apiRequest.get<TGitLabGroup[]>(
|
||||
`/api/v1/app-connections/gitlab/${connectionId}/groups`
|
||||
);
|
||||
|
||||
return data;
|
||||
},
|
||||
...options
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,9 @@
|
||||
export type TGitLabProject = {
|
||||
id: string;
|
||||
name: string;
|
||||
};
|
||||
|
||||
export type TGitLabGroup = {
|
||||
id: string;
|
||||
name: string;
|
||||
};
|
||||
@@ -123,6 +123,11 @@ export type TFlyioConnectionOption = TAppConnectionOptionBase & {
|
||||
app: AppConnection.Flyio;
|
||||
};
|
||||
|
||||
export type TGitlabConnectionOption = TAppConnectionOptionBase & {
|
||||
app: AppConnection.Gitlab;
|
||||
oauthClientId?: string;
|
||||
};
|
||||
|
||||
export type TAppConnectionOption =
|
||||
| TAwsConnectionOption
|
||||
| TGitHubConnectionOption
|
||||
@@ -148,7 +153,8 @@ export type TAppConnectionOption =
|
||||
| TOnePassConnectionOption
|
||||
| THerokuConnectionOption
|
||||
| TRenderConnectionOption
|
||||
| TFlyioConnectionOption;
|
||||
| TFlyioConnectionOption
|
||||
| TGitlabConnectionOption;
|
||||
|
||||
export type TAppConnectionOptionMap = {
|
||||
[AppConnection.AWS]: TAwsConnectionOption;
|
||||
@@ -178,4 +184,5 @@ export type TAppConnectionOptionMap = {
|
||||
[AppConnection.Heroku]: THerokuConnectionOption;
|
||||
[AppConnection.Render]: TRenderConnectionOption;
|
||||
[AppConnection.Flyio]: TFlyioConnectionOption;
|
||||
[AppConnection.Gitlab]: TGitlabConnectionOption;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
import { AppConnection } from "@app/hooks/api/appConnections/enums";
|
||||
import { TRootAppConnection } from "@app/hooks/api/appConnections/types/root-connection";
|
||||
|
||||
export enum GitlabConnectionMethod {
|
||||
AccessToken = "access-token",
|
||||
OAuth = "oauth"
|
||||
}
|
||||
|
||||
export type TGitlabConnection = TRootAppConnection & { app: AppConnection.Gitlab } & (
|
||||
| {
|
||||
method: GitlabConnectionMethod.AccessToken;
|
||||
credentials: {
|
||||
instanceUrl?: string;
|
||||
accessToken: string;
|
||||
};
|
||||
}
|
||||
| {
|
||||
method: GitlabConnectionMethod.OAuth;
|
||||
credentials: {
|
||||
code: string;
|
||||
instanceUrl?: string;
|
||||
};
|
||||
}
|
||||
);
|
||||
@@ -13,6 +13,7 @@ import { TFlyioConnection } from "./flyio-connection";
|
||||
import { TGcpConnection } from "./gcp-connection";
|
||||
import { TGitHubConnection } from "./github-connection";
|
||||
import { TGitHubRadarConnection } from "./github-radar-connection";
|
||||
import { TGitlabConnection } from "./gitlab-connection";
|
||||
import { THCVaultConnection } from "./hc-vault-connection";
|
||||
import { THerokuConnection } from "./heroku-connection";
|
||||
import { THumanitecConnection } from "./humanitec-connection";
|
||||
@@ -41,6 +42,7 @@ export * from "./flyio-connection";
|
||||
export * from "./gcp-connection";
|
||||
export * from "./github-connection";
|
||||
export * from "./github-radar-connection";
|
||||
export * from "./gitlab-connection";
|
||||
export * from "./hc-vault-connection";
|
||||
export * from "./heroku-connection";
|
||||
export * from "./humanitec-connection";
|
||||
@@ -83,7 +85,8 @@ export type TAppConnection =
|
||||
| TOnePassConnection
|
||||
| THerokuConnection
|
||||
| TRenderConnection
|
||||
| TFlyioConnection;
|
||||
| TFlyioConnection
|
||||
| TGitlabConnection;
|
||||
|
||||
export type TAvailableAppConnection = Pick<TAppConnection, "name" | "id">;
|
||||
|
||||
@@ -138,4 +141,5 @@ export type TAppConnectionMap = {
|
||||
[AppConnection.Heroku]: THerokuConnection;
|
||||
[AppConnection.Render]: TRenderConnection;
|
||||
[AppConnection.Flyio]: TFlyioConnection;
|
||||
[AppConnection.Gitlab]: TGitlabConnection;
|
||||
};
|
||||
|
||||
@@ -18,7 +18,8 @@ export enum SecretSync {
|
||||
OnePass = "1password",
|
||||
Heroku = "heroku",
|
||||
Render = "render",
|
||||
Flyio = "flyio"
|
||||
Flyio = "flyio",
|
||||
Gitlab = "gitlab"
|
||||
}
|
||||
|
||||
export enum SecretSyncStatus {
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
import { AppConnection } from "@app/hooks/api/appConnections/enums";
|
||||
import { SecretSync } from "@app/hooks/api/secretSyncs";
|
||||
import { TRootSecretSync } from "@app/hooks/api/secretSyncs/types/root-sync";
|
||||
|
||||
export enum GitlabSyncScope {
|
||||
Individual = "individual",
|
||||
Group = "group"
|
||||
}
|
||||
|
||||
export type TGitlabSync = TRootSecretSync & {
|
||||
destination: SecretSync.Gitlab;
|
||||
destinationConfig:
|
||||
| {
|
||||
scope: GitlabSyncScope.Individual;
|
||||
projectId: string;
|
||||
projectName: string;
|
||||
targetEnvironment?: string;
|
||||
shouldProtectSecrets?: boolean;
|
||||
shouldMaskSecrets?: boolean;
|
||||
shouldHideSecrets?: boolean;
|
||||
}
|
||||
| {
|
||||
scope: GitlabSyncScope.Group;
|
||||
groupId: string;
|
||||
projectId: string;
|
||||
projectName: string;
|
||||
targetEnvironment?: string;
|
||||
shouldProtectSecrets?: boolean;
|
||||
shouldMaskSecrets?: boolean;
|
||||
shouldHideSecrets?: boolean;
|
||||
};
|
||||
connection: {
|
||||
app: AppConnection.Gitlab;
|
||||
name: string;
|
||||
id: string;
|
||||
};
|
||||
};
|
||||
@@ -13,6 +13,7 @@ import { TDatabricksSync } from "./databricks-sync";
|
||||
import { TFlyioSync } from "./flyio-sync";
|
||||
import { TGcpSync } from "./gcp-sync";
|
||||
import { TGitHubSync } from "./github-sync";
|
||||
import { TGitlabSync } from "./gitlab-sync";
|
||||
import { THCVaultSync } from "./hc-vault-sync";
|
||||
import { THerokuSync } from "./heroku-sync";
|
||||
import { THumanitecSync } from "./humanitec-sync";
|
||||
@@ -49,7 +50,8 @@ export type TSecretSync =
|
||||
| TOnePassSync
|
||||
| THerokuSync
|
||||
| TRenderSync
|
||||
| TFlyioSync;
|
||||
| TFlyioSync
|
||||
| TGitlabSync;
|
||||
|
||||
export type TListSecretSyncs = { secretSyncs: TSecretSync[] };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user