mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-14 16:40:30 +00:00
feat: added camunda secret sync
This commit is contained in:
+80
@@ -0,0 +1,80 @@
|
||||
import { useEffect } from "react";
|
||||
import { Controller, useFormContext, useWatch } from "react-hook-form";
|
||||
import { SingleValue } from "react-select";
|
||||
import { faCircleInfo } from "@fortawesome/free-solid-svg-icons";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
|
||||
import { SecretSyncConnectionField } from "@app/components/secret-syncs/forms/SecretSyncConnectionField";
|
||||
import { FilterableSelect, FormControl, Tooltip } from "@app/components/v2";
|
||||
import { useCamundaConnectionListClusters } from "@app/hooks/api/appConnections/camunda";
|
||||
import { TCamundaCluster } from "@app/hooks/api/appConnections/camunda/types";
|
||||
import { SecretSync } from "@app/hooks/api/secretSyncs";
|
||||
import { CamundaSyncScope } from "@app/hooks/api/secretSyncs/types/camunda-sync";
|
||||
|
||||
import { TSecretSyncForm } from "../schemas";
|
||||
|
||||
export const CamundaSyncFields = () => {
|
||||
const { control, setValue } = useFormContext<
|
||||
TSecretSyncForm & { destination: SecretSync.Camunda }
|
||||
>();
|
||||
|
||||
const connectionId = useWatch({ name: "connection.id", control });
|
||||
|
||||
const { data: clusters, isPending } = useCamundaConnectionListClusters(connectionId, {
|
||||
enabled: Boolean(connectionId)
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
setValue("destinationConfig.scope", CamundaSyncScope.Cluster);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
<SecretSyncConnectionField
|
||||
onChange={() => {
|
||||
setValue("destinationConfig.clusterUUID", "");
|
||||
}}
|
||||
/>
|
||||
<Controller
|
||||
name="destinationConfig.clusterUUID"
|
||||
control={control}
|
||||
render={({ field: { value, onChange }, fieldState: { error } }) => (
|
||||
<FormControl
|
||||
isError={Boolean(error)}
|
||||
errorText={error?.message}
|
||||
label="Cluster"
|
||||
helperText={
|
||||
<Tooltip
|
||||
className="max-w-md"
|
||||
content="Ensure that your credential has been granted access to the cluster"
|
||||
>
|
||||
<div>
|
||||
<span>Don't see the cluster you're looking for?</span>{" "}
|
||||
<FontAwesomeIcon icon={faCircleInfo} className="text-mineshaft-400" />
|
||||
</div>
|
||||
</Tooltip>
|
||||
}
|
||||
>
|
||||
<FilterableSelect
|
||||
menuPlacement="top"
|
||||
isLoading={isPending && Boolean(connectionId)}
|
||||
isDisabled={!connectionId}
|
||||
value={clusters?.find((cluster) => cluster.uuid === value) ?? null}
|
||||
onChange={(option) => {
|
||||
onChange((option as SingleValue<TCamundaCluster>)?.uuid ?? null);
|
||||
setValue(
|
||||
"destinationConfig.clusterName",
|
||||
(option as SingleValue<TCamundaCluster>)?.name ?? ""
|
||||
);
|
||||
}}
|
||||
options={clusters}
|
||||
placeholder="Select a cluster..."
|
||||
getOptionLabel={(option) => option.name}
|
||||
getOptionValue={(option) => option.uuid}
|
||||
/>
|
||||
</FormControl>
|
||||
)}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
};
|
||||
+3
@@ -7,6 +7,7 @@ import { AwsParameterStoreSyncFields } from "./AwsParameterStoreSyncFields";
|
||||
import { AwsSecretsManagerSyncFields } from "./AwsSecretsManagerSyncFields";
|
||||
import { AzureAppConfigurationSyncFields } from "./AzureAppConfigurationSyncFields";
|
||||
import { AzureKeyVaultSyncFields } from "./AzureKeyVaultSyncFields";
|
||||
import { CamundaSyncFields } from "./CamundaSyncFields";
|
||||
import { DatabricksSyncFields } from "./DatabricksSyncFields";
|
||||
import { GcpSyncFields } from "./GcpSyncFields";
|
||||
import { GitHubSyncFields } from "./GitHubSyncFields";
|
||||
@@ -34,6 +35,8 @@ export const SecretSyncDestinationFields = () => {
|
||||
return <DatabricksSyncFields />;
|
||||
case SecretSync.Humanitec:
|
||||
return <HumanitecSyncFields />;
|
||||
case SecretSync.Camunda:
|
||||
return <CamundaSyncFields />;
|
||||
default:
|
||||
throw new Error(`Unhandled Destination Config Field: ${destination}`);
|
||||
}
|
||||
|
||||
+1
@@ -39,6 +39,7 @@ export const SecretSyncOptionsFields = ({ hideInitialSync }: Props) => {
|
||||
case SecretSync.AzureAppConfiguration:
|
||||
case SecretSync.Databricks:
|
||||
case SecretSync.Humanitec:
|
||||
case SecretSync.Camunda:
|
||||
AdditionalSyncOptionsFieldsComponent = null;
|
||||
break;
|
||||
default:
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
import { useFormContext } from "react-hook-form";
|
||||
|
||||
import { GenericFieldLabel } from "@app/components/secret-syncs";
|
||||
import { TSecretSyncForm } from "@app/components/secret-syncs/forms/schemas";
|
||||
import { SecretSync } from "@app/hooks/api/secretSyncs";
|
||||
|
||||
export const CamundaSyncReviewFields = () => {
|
||||
const { watch } = useFormContext<TSecretSyncForm & { destination: SecretSync.Camunda }>();
|
||||
const scope = watch("destinationConfig.scope");
|
||||
const clusterName = watch("destinationConfig.clusterName");
|
||||
const clusterUUID = watch("destinationConfig.clusterUUID");
|
||||
return (
|
||||
<>
|
||||
<GenericFieldLabel label="Secret Scope">{scope}</GenericFieldLabel>
|
||||
<GenericFieldLabel label="Cluster">
|
||||
{clusterName} (uuid:{clusterUUID})
|
||||
</GenericFieldLabel>
|
||||
</>
|
||||
);
|
||||
};
|
||||
+4
@@ -17,6 +17,7 @@ import {
|
||||
} from "./AwsSecretsManagerSyncReviewFields";
|
||||
import { AzureAppConfigurationSyncReviewFields } from "./AzureAppConfigurationSyncReviewFields";
|
||||
import { AzureKeyVaultSyncReviewFields } from "./AzureKeyVaultSyncReviewFields";
|
||||
import { CamundaSyncReviewFields } from "./CamundaSyncReviewFields";
|
||||
import { DatabricksSyncReviewFields } from "./DatabricksSyncReviewFields";
|
||||
import { GcpSyncReviewFields } from "./GcpSyncReviewFields";
|
||||
import { GitHubSyncReviewFields } from "./GitHubSyncReviewFields";
|
||||
@@ -72,6 +73,9 @@ export const SecretSyncReviewFields = () => {
|
||||
case SecretSync.Humanitec:
|
||||
DestinationFieldsComponent = <HumanitecSyncReviewFields />;
|
||||
break;
|
||||
case SecretSync.Camunda:
|
||||
DestinationFieldsComponent = <CamundaSyncReviewFields />;
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Unhandled Destination Review Fields: ${destination}`);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import { z } from "zod";
|
||||
|
||||
import { BaseSecretSyncSchema } from "@app/components/secret-syncs/forms/schemas/base-secret-sync-schema";
|
||||
import { SecretSync } from "@app/hooks/api/secretSyncs";
|
||||
|
||||
export const CamundaSyncDestinationSchema = BaseSecretSyncSchema().merge(
|
||||
z.object({
|
||||
destination: z.literal(SecretSync.Camunda),
|
||||
destinationConfig: z.object({
|
||||
scope: z.string().trim().min(1, "Camunda scope required"),
|
||||
clusterUUID: z.string().trim().min(1, "Camunda cluster UUID required"),
|
||||
clusterName: z.string().optional()
|
||||
})
|
||||
})
|
||||
);
|
||||
@@ -7,6 +7,7 @@ import { GitHubSyncDestinationSchema } from "@app/components/secret-syncs/forms/
|
||||
import { AwsParameterStoreSyncDestinationSchema } from "./aws-parameter-store-sync-destination-schema";
|
||||
import { AzureAppConfigurationSyncDestinationSchema } from "./azure-app-configuration-sync-destination-schema";
|
||||
import { AzureKeyVaultSyncDestinationSchema } from "./azure-key-vault-sync-destination-schema";
|
||||
import { CamundaSyncDestinationSchema } from "./camunda-sync-destination-schema";
|
||||
import { GcpSyncDestinationSchema } from "./gcp-sync-destination-schema";
|
||||
import { HumanitecSyncDestinationSchema } from "./humanitec-sync-destination-schema";
|
||||
|
||||
@@ -18,7 +19,8 @@ const SecretSyncUnionSchema = z.discriminatedUnion("destination", [
|
||||
AzureKeyVaultSyncDestinationSchema,
|
||||
AzureAppConfigurationSyncDestinationSchema,
|
||||
DatabricksSyncDestinationSchema,
|
||||
HumanitecSyncDestinationSchema
|
||||
HumanitecSyncDestinationSchema,
|
||||
CamundaSyncDestinationSchema
|
||||
]);
|
||||
|
||||
export const SecretSyncFormSchema = SecretSyncUnionSchema;
|
||||
|
||||
@@ -23,6 +23,10 @@ export const SECRET_SYNC_MAP: Record<SecretSync, { name: string; image: string }
|
||||
[SecretSync.Humanitec]: {
|
||||
name: "Humanitec",
|
||||
image: "Humanitec.png"
|
||||
},
|
||||
[SecretSync.Camunda]: {
|
||||
name: "Camunda",
|
||||
image: "Camunda.png"
|
||||
}
|
||||
};
|
||||
|
||||
@@ -34,7 +38,8 @@ export const SECRET_SYNC_CONNECTION_MAP: Record<SecretSync, AppConnection> = {
|
||||
[SecretSync.AzureKeyVault]: AppConnection.AzureKeyVault,
|
||||
[SecretSync.AzureAppConfiguration]: AppConnection.AzureAppConfiguration,
|
||||
[SecretSync.Databricks]: AppConnection.Databricks,
|
||||
[SecretSync.Humanitec]: AppConnection.Humanitec
|
||||
[SecretSync.Humanitec]: AppConnection.Humanitec,
|
||||
[SecretSync.Camunda]: AppConnection.Camunda
|
||||
};
|
||||
|
||||
export const SECRET_SYNC_INITIAL_SYNC_BEHAVIOR_MAP: Record<
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
export * from "./queries";
|
||||
@@ -0,0 +1,37 @@
|
||||
import { useQuery, UseQueryOptions } from "@tanstack/react-query";
|
||||
|
||||
import { apiRequest } from "@app/config/request";
|
||||
|
||||
import { appConnectionKeys } from "../queries";
|
||||
import { TCamundaCluster } from "./types";
|
||||
|
||||
const camundaConnectionKeys = {
|
||||
all: [...appConnectionKeys.all, "camunda"] as const,
|
||||
listClusters: (connectionId: string) =>
|
||||
[...camundaConnectionKeys.all, "clusters", connectionId] as const
|
||||
};
|
||||
|
||||
export const useCamundaConnectionListClusters = (
|
||||
connectionId: string,
|
||||
options?: Omit<
|
||||
UseQueryOptions<
|
||||
TCamundaCluster[],
|
||||
unknown,
|
||||
TCamundaCluster[],
|
||||
ReturnType<typeof camundaConnectionKeys.listClusters>
|
||||
>,
|
||||
"queryKey" | "queryFn"
|
||||
>
|
||||
) => {
|
||||
return useQuery({
|
||||
queryKey: camundaConnectionKeys.listClusters(connectionId),
|
||||
queryFn: async () => {
|
||||
const { data } = await apiRequest.get<{ clusters: TCamundaCluster[] }>(
|
||||
`/api/v1/app-connections/camunda/${connectionId}/clusters`
|
||||
);
|
||||
|
||||
return data.clusters;
|
||||
},
|
||||
...options
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,4 @@
|
||||
export type TCamundaCluster = {
|
||||
name: string;
|
||||
uuid: string;
|
||||
};
|
||||
@@ -6,7 +6,8 @@ export enum SecretSync {
|
||||
AzureKeyVault = "azure-key-vault",
|
||||
AzureAppConfiguration = "azure-app-configuration",
|
||||
Databricks = "databricks",
|
||||
Humanitec = "humanitec"
|
||||
Humanitec = "humanitec",
|
||||
Camunda = "camunda"
|
||||
}
|
||||
|
||||
export enum SecretSyncStatus {
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
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 CamundaSyncScope {
|
||||
Cluster = "cluster"
|
||||
}
|
||||
|
||||
export type TCamundaSync = TRootSecretSync & {
|
||||
destination: SecretSync.Camunda;
|
||||
destinationConfig: {
|
||||
scope: string;
|
||||
clusterUUID: string;
|
||||
};
|
||||
connection: {
|
||||
app: AppConnection.Camunda;
|
||||
name: string;
|
||||
id: string;
|
||||
};
|
||||
};
|
||||
@@ -7,6 +7,7 @@ import { DiscriminativePick } from "@app/types";
|
||||
import { TAwsSecretsManagerSync } from "./aws-secrets-manager-sync";
|
||||
import { TAzureAppConfigurationSync } from "./azure-app-configuration-sync";
|
||||
import { TAzureKeyVaultSync } from "./azure-key-vault-sync";
|
||||
import { TCamundaSync } from "./camunda-sync";
|
||||
import { TGcpSync } from "./gcp-sync";
|
||||
import { THumanitecSync } from "./humanitec-sync";
|
||||
|
||||
@@ -24,7 +25,8 @@ export type TSecretSync =
|
||||
| TAzureKeyVaultSync
|
||||
| TAzureAppConfigurationSync
|
||||
| TDatabricksSync
|
||||
| THumanitecSync;
|
||||
| THumanitecSync
|
||||
| TCamundaSync;
|
||||
|
||||
export type TListSecretSyncs = { secretSyncs: TSecretSync[] };
|
||||
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import { TCamundaSync } from "@app/hooks/api/secretSyncs/types/camunda-sync";
|
||||
|
||||
import { getSecretSyncDestinationColValues } from "../helpers";
|
||||
import { SecretSyncTableCell } from "../SecretSyncTableCell";
|
||||
|
||||
type Props = {
|
||||
secretSync: TCamundaSync;
|
||||
};
|
||||
|
||||
export const CamundaDestinationSyncCol = ({ secretSync }: Props) => {
|
||||
const { primaryText, secondaryText } = getSecretSyncDestinationColValues(secretSync);
|
||||
|
||||
return <SecretSyncTableCell primaryText={primaryText} secondaryText={secondaryText} />;
|
||||
};
|
||||
+3
@@ -4,6 +4,7 @@ import { AwsParameterStoreSyncDestinationCol } from "./AwsParameterStoreSyncDest
|
||||
import { AwsSecretsManagerSyncDestinationCol } from "./AwsSecretsManagerSyncDestinationCol";
|
||||
import { AzureAppConfigurationDestinationSyncCol } from "./AzureAppConfigurationDestinationSyncCol";
|
||||
import { AzureKeyVaultDestinationSyncCol } from "./AzureKeyVaultDestinationSyncCol";
|
||||
import { CamundaDestinationSyncCol } from "./CamundaSyncDestinationCol";
|
||||
import { DatabricksSyncDestinationCol } from "./DatabricksSyncDestinationCol";
|
||||
import { GcpSyncDestinationCol } from "./GcpSyncDestinationCol";
|
||||
import { GitHubSyncDestinationCol } from "./GitHubSyncDestinationCol";
|
||||
@@ -31,6 +32,8 @@ export const SecretSyncDestinationCol = ({ secretSync }: Props) => {
|
||||
return <DatabricksSyncDestinationCol secretSync={secretSync} />;
|
||||
case SecretSync.Humanitec:
|
||||
return <HumanitecSyncDestinationCol secretSync={secretSync} />;
|
||||
case SecretSync.Camunda:
|
||||
return <CamundaDestinationSyncCol secretSync={secretSync} />;
|
||||
default:
|
||||
throw new Error(
|
||||
`Unhandled Secret Sync Destination Col: ${(secretSync as TSecretSync).destination}`
|
||||
|
||||
+4
@@ -73,6 +73,10 @@ export const getSecretSyncDestinationColValues = (secretSync: TSecretSync) => {
|
||||
}
|
||||
secondaryText = `Organization - ${destinationConfig.org}`;
|
||||
break;
|
||||
case SecretSync.Camunda:
|
||||
primaryText = destinationConfig.clusterUUID;
|
||||
secondaryText = "Cluster";
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Unhandled Destination Col Values ${destination}`);
|
||||
}
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import { GenericFieldLabel } from "@app/components/secret-syncs";
|
||||
import { TCamundaSync } from "@app/hooks/api/secretSyncs/types/camunda-sync";
|
||||
|
||||
type Props = {
|
||||
secretSync: TCamundaSync;
|
||||
};
|
||||
|
||||
export const CamundaSyncDestinationSection = ({ secretSync }: Props) => {
|
||||
const {
|
||||
destinationConfig: { clusterUUID }
|
||||
} = secretSync;
|
||||
|
||||
return <GenericFieldLabel label="Cluster UUID">{clusterUUID}</GenericFieldLabel>;
|
||||
};
|
||||
+4
@@ -16,6 +16,7 @@ import { GitHubSyncDestinationSection } from "@app/pages/secret-manager/SecretSy
|
||||
|
||||
import { AzureAppConfigurationSyncDestinationSection } from "./AzureAppConfigurationSyncDestinationSection";
|
||||
import { AzureKeyVaultSyncDestinationSection } from "./AzureKeyVaultSyncDestinationSection";
|
||||
import { CamundaSyncDestinationSection } from "./CamundaSyncDestinationSection";
|
||||
import { GcpSyncDestinationSection } from "./GcpSyncDestinationSection";
|
||||
import { HumanitecSyncDestinationSection } from "./HumanitecSyncDestinationSection";
|
||||
|
||||
@@ -57,6 +58,9 @@ export const SecretSyncDestinationSection = ({ secretSync, onEditDestination }:
|
||||
case SecretSync.Humanitec:
|
||||
DestinationComponents = <HumanitecSyncDestinationSection secretSync={secretSync} />;
|
||||
break;
|
||||
case SecretSync.Camunda:
|
||||
DestinationComponents = <CamundaSyncDestinationSection secretSync={secretSync} />;
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Unhandled Destination Section components: ${destination}`);
|
||||
}
|
||||
|
||||
+1
@@ -48,6 +48,7 @@ export const SecretSyncOptionsSection = ({ secretSync, onEditOptions }: Props) =
|
||||
case SecretSync.AzureAppConfiguration:
|
||||
case SecretSync.Databricks:
|
||||
case SecretSync.Humanitec:
|
||||
case SecretSync.Camunda:
|
||||
AdditionalSyncOptionsComponent = null;
|
||||
break;
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user