mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-14 21:51:56 +00:00
feat(app-connections): OCI
This commit is contained in:
@@ -16,5 +16,6 @@ export enum AppConnection {
|
||||
Auth0 = "auth0",
|
||||
HCVault = "hashicorp-vault",
|
||||
LDAP = "ldap",
|
||||
TeamCity = "teamcity"
|
||||
TeamCity = "teamcity",
|
||||
OCI = "oci"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from "./queries";
|
||||
export * from "./types";
|
||||
@@ -0,0 +1,73 @@
|
||||
import { useQuery, UseQueryOptions } from "@tanstack/react-query";
|
||||
|
||||
import { apiRequest } from "@app/config/request";
|
||||
|
||||
import { appConnectionKeys } from "../queries";
|
||||
import { TListOCIVaultKeys, TListOCIVaults, TOCIVault, TOCIVaultKey } from "./types";
|
||||
|
||||
const ociConnectionKeys = {
|
||||
all: [...appConnectionKeys.all, "oci"] as const,
|
||||
listVaults: (connectionId: string) => [...ociConnectionKeys.all, "vaults", connectionId] as const,
|
||||
listVaultKeys: (connectionId: string) => [...ociConnectionKeys.all, "keys", connectionId] as const
|
||||
};
|
||||
|
||||
export const useOCIConnectionListVaults = (
|
||||
{ connectionId, compartmentOcid }: TListOCIVaults,
|
||||
options?: Omit<
|
||||
UseQueryOptions<
|
||||
TOCIVault[],
|
||||
unknown,
|
||||
TOCIVault[],
|
||||
ReturnType<typeof ociConnectionKeys.listVaults>
|
||||
>,
|
||||
"queryKey" | "queryFn"
|
||||
>
|
||||
) => {
|
||||
return useQuery({
|
||||
queryKey: ociConnectionKeys.listVaults(connectionId),
|
||||
queryFn: async () => {
|
||||
const { data } = await apiRequest.get<TOCIVault[]>(
|
||||
`/api/v1/app-connections/oci/${connectionId}/vaults`,
|
||||
{
|
||||
params: {
|
||||
compartmentOcid
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
return data;
|
||||
},
|
||||
...options
|
||||
});
|
||||
};
|
||||
|
||||
export const useOCIConnectionListVaultKeys = (
|
||||
{ connectionId, compartmentOcid, vaultOcid }: TListOCIVaultKeys,
|
||||
options?: Omit<
|
||||
UseQueryOptions<
|
||||
TOCIVaultKey[],
|
||||
unknown,
|
||||
TOCIVaultKey[],
|
||||
ReturnType<typeof ociConnectionKeys.listVaultKeys>
|
||||
>,
|
||||
"queryKey" | "queryFn"
|
||||
>
|
||||
) => {
|
||||
return useQuery({
|
||||
queryKey: ociConnectionKeys.listVaultKeys(connectionId),
|
||||
queryFn: async () => {
|
||||
const { data } = await apiRequest.get<TOCIVaultKey[]>(
|
||||
`/api/v1/app-connections/oci/${connectionId}/vault-keys`,
|
||||
{
|
||||
params: {
|
||||
compartmentOcid,
|
||||
vaultOcid
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
return data;
|
||||
},
|
||||
...options
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
// Response types
|
||||
export type TOCIVault = {
|
||||
id: string;
|
||||
displayName: string;
|
||||
compartmentId: string;
|
||||
timeCreated: string;
|
||||
lifecycleState: string;
|
||||
};
|
||||
|
||||
export type TOCIVaultKey = {
|
||||
id: string;
|
||||
displayName: string;
|
||||
};
|
||||
|
||||
// Param types
|
||||
export type TListOCIVaults = {
|
||||
connectionId: string;
|
||||
compartmentOcid: string;
|
||||
};
|
||||
|
||||
export type TListOCIVaultKeys = {
|
||||
connectionId: string;
|
||||
compartmentOcid: string;
|
||||
vaultOcid: string;
|
||||
};
|
||||
@@ -84,6 +84,10 @@ export type TTeamCityConnectionOption = TAppConnectionOptionBase & {
|
||||
app: AppConnection.TeamCity;
|
||||
};
|
||||
|
||||
export type TOCIConnectionOption = TAppConnectionOptionBase & {
|
||||
app: AppConnection.OCI;
|
||||
};
|
||||
|
||||
export type TAppConnectionOption =
|
||||
| TAwsConnectionOption
|
||||
| TGitHubConnectionOption
|
||||
@@ -101,7 +105,8 @@ export type TAppConnectionOption =
|
||||
| TWindmillConnectionOption
|
||||
| TAuth0ConnectionOption
|
||||
| THCVaultConnectionOption
|
||||
| TTeamCityConnectionOption;
|
||||
| TTeamCityConnectionOption
|
||||
| TOCIConnectionOption;
|
||||
|
||||
export type TAppConnectionOptionMap = {
|
||||
[AppConnection.AWS]: TAwsConnectionOption;
|
||||
@@ -122,4 +127,5 @@ export type TAppConnectionOptionMap = {
|
||||
[AppConnection.HCVault]: THCVaultConnectionOption;
|
||||
[AppConnection.LDAP]: TLdapConnectionOption;
|
||||
[AppConnection.TeamCity]: TTeamCityConnectionOption;
|
||||
[AppConnection.OCI]: TOCIConnectionOption;
|
||||
};
|
||||
|
||||
@@ -13,6 +13,7 @@ import { THCVaultConnection } from "./hc-vault-connection";
|
||||
import { THumanitecConnection } from "./humanitec-connection";
|
||||
import { TLdapConnection } from "./ldap-connection";
|
||||
import { TMsSqlConnection } from "./mssql-connection";
|
||||
import { TOCIConnection } from "./oci-connection";
|
||||
import { TPostgresConnection } from "./postgres-connection";
|
||||
import { TTeamCityConnection } from "./teamcity-connection";
|
||||
import { TTerraformCloudConnection } from "./terraform-cloud-connection";
|
||||
@@ -32,6 +33,7 @@ export * from "./hc-vault-connection";
|
||||
export * from "./humanitec-connection";
|
||||
export * from "./ldap-connection";
|
||||
export * from "./mssql-connection";
|
||||
export * from "./oci-connection";
|
||||
export * from "./postgres-connection";
|
||||
export * from "./teamcity-connection";
|
||||
export * from "./terraform-cloud-connection";
|
||||
@@ -56,7 +58,8 @@ export type TAppConnection =
|
||||
| TAuth0Connection
|
||||
| THCVaultConnection
|
||||
| TLdapConnection
|
||||
| TTeamCityConnection;
|
||||
| TTeamCityConnection
|
||||
| TOCIConnection;
|
||||
|
||||
export type TAvailableAppConnection = Pick<TAppConnection, "name" | "id">;
|
||||
|
||||
@@ -102,4 +105,5 @@ export type TAppConnectionMap = {
|
||||
[AppConnection.HCVault]: THCVaultConnection;
|
||||
[AppConnection.LDAP]: TLdapConnection;
|
||||
[AppConnection.TeamCity]: TTeamCityConnection;
|
||||
[AppConnection.OCI]: TOCIConnection;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import { AppConnection } from "@app/hooks/api/appConnections/enums";
|
||||
import { TRootAppConnection } from "@app/hooks/api/appConnections/types/root-connection";
|
||||
|
||||
export enum OCIConnectionMethod {
|
||||
AccessKey = "access-key"
|
||||
}
|
||||
|
||||
export type TOCIConnection = TRootAppConnection & { app: AppConnection.OCI } & {
|
||||
method: OCIConnectionMethod.AccessKey;
|
||||
credentials: {
|
||||
userOcid: string;
|
||||
tenancyOcid: string;
|
||||
region: string;
|
||||
fingerprint: string;
|
||||
privateKey: string;
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user