mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
feat(secret-sync): add PR suggestions for Zabbix secret sync
This commit is contained in:
@@ -46,6 +46,9 @@ const handleZabbixResponse = <T>(response: ZabbixApiResponse<T>): T => {
|
||||
const listZabbixSecrets = async (apiToken: string, instanceUrl: string, hostId?: string): Promise<TZabbixSecret[]> => {
|
||||
const apiUrl = `${instanceUrl.replace(TRAILING_SLASH_REGEX, "")}/api_jsonrpc.php`;
|
||||
|
||||
// - jsonrpc: Specifies the JSON-RPC protocol version.
|
||||
// - method: The API method to call, in this case "usermacro.get" for retrieving user macros.
|
||||
// - id: A unique identifier for the request. Required by JSON-RPC but not used by the API for logic. Typically set to any integer.
|
||||
const payload = {
|
||||
jsonrpc: "2.0" as const,
|
||||
method: "usermacro.get",
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
TZabbixHost,
|
||||
useZabbixConnectionListHosts,
|
||||
ZABBIX_SYNC_SCOPES,
|
||||
ZabbixMacroType,
|
||||
ZabbixSyncScope
|
||||
} from "@app/hooks/api/appConnections/zabbix";
|
||||
import { SecretSync } from "@app/hooks/api/secretSyncs";
|
||||
@@ -120,7 +121,7 @@ export const ZabbixSyncFields = () => {
|
||||
<Controller
|
||||
control={control}
|
||||
name="destinationConfig.macroType"
|
||||
defaultValue={0}
|
||||
defaultValue={ZabbixMacroType.Secret}
|
||||
render={({ field: { onChange, value }, fieldState: { error } }) => (
|
||||
<FormControl isError={Boolean(error)} errorText={error?.message} label="Macro Type">
|
||||
<Select
|
||||
@@ -131,10 +132,10 @@ export const ZabbixSyncFields = () => {
|
||||
placeholder="Select a macro type..."
|
||||
dropdownContainerClassName="max-w-none"
|
||||
>
|
||||
<SelectItem value="0" key="text">
|
||||
<SelectItem value={String(ZabbixMacroType.Text)} key="text">
|
||||
Text
|
||||
</SelectItem>
|
||||
<SelectItem value="1" key="secret">
|
||||
<SelectItem value={String(ZabbixMacroType.Secret)} key="secret">
|
||||
Secret
|
||||
</SelectItem>
|
||||
</Select>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { z } from "zod";
|
||||
|
||||
import { BaseSecretSyncSchema } from "@app/components/secret-syncs/forms/schemas/base-secret-sync-schema";
|
||||
import { ZabbixSyncScope } from "@app/hooks/api/appConnections/zabbix";
|
||||
import { ZabbixMacroType, ZabbixSyncScope } from "@app/hooks/api/appConnections/zabbix";
|
||||
import { SecretSync } from "@app/hooks/api/secretSyncs";
|
||||
|
||||
export const ZabbixSyncDestinationSchema = BaseSecretSyncSchema().merge(
|
||||
@@ -12,11 +12,15 @@ export const ZabbixSyncDestinationSchema = BaseSecretSyncSchema().merge(
|
||||
scope: z.literal(ZabbixSyncScope.Host),
|
||||
hostId: z.string().trim().min(1, "Host ID required"),
|
||||
hostName: z.string().trim().min(1, "Host name required"),
|
||||
macroType: z.number().min(0, "Macro type required").max(1, "Macro type required")
|
||||
macroType: z.nativeEnum(ZabbixMacroType, {
|
||||
errorMap: () => ({ message: "Macro type must be either 'text' or 'secret'" })
|
||||
})
|
||||
}),
|
||||
z.object({
|
||||
scope: z.literal(ZabbixSyncScope.Global),
|
||||
macroType: z.number().min(0, "Macro type required").max(1, "Macro type required")
|
||||
macroType: z.nativeEnum(ZabbixMacroType, {
|
||||
errorMap: () => ({ message: "Macro type must be either 'text' or 'secret'" })
|
||||
})
|
||||
})
|
||||
])
|
||||
})
|
||||
|
||||
@@ -8,6 +8,11 @@ export enum ZabbixSyncScope {
|
||||
Global = "global"
|
||||
}
|
||||
|
||||
export enum ZabbixMacroType {
|
||||
Text = 0,
|
||||
Secret = 1
|
||||
}
|
||||
|
||||
export const ZABBIX_SYNC_SCOPES = {
|
||||
[ZabbixSyncScope.Host]: {
|
||||
name: "Host",
|
||||
|
||||
@@ -2,15 +2,7 @@ import { Controller, FormProvider, useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import {
|
||||
Button,
|
||||
FormControl,
|
||||
Input,
|
||||
ModalClose,
|
||||
SecretInput,
|
||||
Select,
|
||||
SelectItem
|
||||
} from "@app/components/v2";
|
||||
import { Button, FormControl, Input, ModalClose, Select, SelectItem } from "@app/components/v2";
|
||||
import { APP_CONNECTION_MAP, getAppConnectionMethodDetails } from "@app/helpers/appConnections";
|
||||
import { TZabbixConnection, ZabbixConnectionMethod } from "@app/hooks/api/appConnections";
|
||||
import { AppConnection } from "@app/hooks/api/appConnections/enums";
|
||||
@@ -93,6 +85,20 @@ export const ZabbixConnectionForm = ({ appConnection, onSubmit }: Props) => {
|
||||
</FormControl>
|
||||
)}
|
||||
/>
|
||||
<Controller
|
||||
name="credentials.apiToken"
|
||||
control={control}
|
||||
shouldUnregister
|
||||
render={({ field, fieldState: { error } }) => (
|
||||
<FormControl
|
||||
errorText={error?.message}
|
||||
isError={Boolean(error?.message)}
|
||||
label="API Token"
|
||||
>
|
||||
<Input {...field} type="password" placeholder="Enter your API Token" />
|
||||
</FormControl>
|
||||
)}
|
||||
/>
|
||||
<Controller
|
||||
name="credentials.instanceUrl"
|
||||
control={control}
|
||||
@@ -108,24 +114,6 @@ export const ZabbixConnectionForm = ({ appConnection, onSubmit }: Props) => {
|
||||
</FormControl>
|
||||
)}
|
||||
/>
|
||||
<Controller
|
||||
name="credentials.apiToken"
|
||||
control={control}
|
||||
shouldUnregister
|
||||
render={({ field: { value, onChange }, fieldState: { error } }) => (
|
||||
<FormControl
|
||||
errorText={error?.message}
|
||||
isError={Boolean(error?.message)}
|
||||
label="Access Token"
|
||||
>
|
||||
<SecretInput
|
||||
containerClassName="text-gray-400 group-focus-within:!border-primary-400/50 border border-mineshaft-500 bg-mineshaft-900 px-2.5 py-1.5"
|
||||
value={value}
|
||||
onChange={(e) => onChange(e.target.value)}
|
||||
/>
|
||||
</FormControl>
|
||||
)}
|
||||
/>
|
||||
<div className="mt-8 flex items-center">
|
||||
<Button
|
||||
className="mr-4"
|
||||
|
||||
Reference in New Issue
Block a user