Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
feat: add secret sync and app connection for rundeck
adilsonc540c3de1773
diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.tsindex cd6cd952db..45a7a3415a 100644--- a/backend/src/lib/api-docs/constants.ts+++ b/backend/src/lib/api-docs/constants.ts@@ -2881,6 +2881,10 @@ export const AppConnections = {instanceUrl: "The Octopus Deploy instance URL to connect to.",apiKey: "The API key used to authenticate with Octopus Deploy."},+ RUNDECK: {+ instanceUrl: "The Rundeck instance URL to connect to.",+ apiToken: "The API token used to authenticate with Rundeck."+ },DATADOG: {url: "The Datadog site URL to connect to (e.g., 'https://api.datadoghq.com').",apiKey: "The Datadog API key used to authenticate.",diff --git a/backend/src/server/routes/v1/app-connection-routers/app-connection-router.ts b/backend/src/server/routes/v1/app-connection-routers/app-connection-router.tsindex 8102bc52ff..ab593aa6b8 100644--- a/backend/src/server/routes/v1/app-connection-routers/app-connection-router.ts+++ b/backend/src/server/routes/v1/app-connection-routers/app-connection-router.ts@@ -172,6 +172,10 @@ import {RenderConnectionListItemSchema,SanitizedRenderConnectionSchema} from "@app/services/app-connection/render/render-connection-schema";+import {+ RundeckConnectionListItemSchema,+ SanitizedRundeckConnectionSchema+} from "@app/services/app-connection/rundeck";import {SalesforceConnectionListItemSchema,SanitizedSalesforceConnectionSchema@@ -286,7 +290,8 @@ const SanitizedAppConnectionSchema = z.union([...SanitizedSnowflakeConnectionSchema.options,...SanitizedDatadogConnectionSchema.options,...SanitizedF5BigIpConnectionSchema.options,- ...SanitizedConvexConnectionSchema.options+ ...SanitizedConvexConnectionSchema.options,+ ...SanitizedRundeckConnectionSchema.options]);const AppConnectionOptionsSchema = z.discriminatedUnion("app", [@@ -359,7 +364,8 @@ const AppConnectionOptionsSchema = z.discriminatedUnion("app", [SnowflakeConnectionListItemSchema,DatadogConnectionListItemSchema,F5BigIpConnectionListItemSchema,- ConvexConnectionListItemSchema+ ConvexConnectionListItemSchema,+ RundeckConnectionListItemSchema]);export const registerAppConnectionRouter = async (server: FastifyZodProvider) => {diff --git a/backend/src/server/routes/v1/app-connection-routers/index.ts b/backend/src/server/routes/v1/app-connection-routers/index.tsindex 861a892ccb..0547779730 100644--- a/backend/src/server/routes/v1/app-connection-routers/index.ts+++ b/backend/src/server/routes/v1/app-connection-routers/index.ts@@ -56,6 +56,7 @@ import { registerPostgresConnectionRouter } from "./postgres-connection-router";import { registerRailwayConnectionRouter } from "./railway-connection-router";import { registerRedisConnectionRouter } from "./redis-connection-router";import { registerRenderConnectionRouter } from "./render-connection-router";+import { registerRundeckConnectionRouter } from "./rundeck-connection-router";import { registerSalesforceConnectionRouter } from "./salesforce-connection-router";import { registerSmbConnectionRouter } from "./smb-connection-router";import { registerSnowflakeConnectionRouter } from "./snowflake-connection-router";@@ -144,5 +145,6 @@ export const APP_CONNECTION_REGISTER_ROUTER_MAP: Record<AppConnection, (server:[AppConnection.Snowflake]: registerSnowflakeConnectionRouter,[AppConnection.Datadog]: registerDatadogConnectionRouter,[AppConnection.F5BigIp]: registerF5BigIpConnectionRouter,- [AppConnection.Convex]: registerConvexConnectionRouter+ [AppConnection.Convex]: registerConvexConnectionRouter,+ [AppConnection.Rundeck]: registerRundeckConnectionRouter};diff --git a/backend/src/server/routes/v1/app-connection-routers/rundeck-connection-router.ts b/backend/src/server/routes/v1/app-connection-routers/rundeck-connection-router.tsnew file mode 100644index 0000000000..17ac4b948d--- /dev/null+++ b/backend/src/server/routes/v1/app-connection-routers/rundeck-connection-router.ts@@ -0,0 +1,55 @@+import { z } from "zod";++import { readLimit } from "@app/server/config/rateLimiter";+import { verifyAuth } from "@app/server/plugins/auth/verify-auth";+import { AppConnection } from "@app/services/app-connection/app-connection-enums";+import {+ CreateRundeckConnectionSchema,+ SanitizedRundeckConnectionSchema,+ UpdateRundeckConnectionSchema+} from "@app/services/app-connection/rundeck";+import { AuthMode } from "@app/services/auth/auth-type";++import { registerAppConnectionEndpoints } from "./app-connection-endpoints";++export const registerRundeckConnectionRouter = async (server: FastifyZodProvider) => {+ registerAppConnectionEndpoints({+ app: AppConnection.Rundeck,+ server,+ sanitizedResponseSchema: SanitizedRundeckConnectionSchema,+ createSchema: CreateRundeckConnectionSchema,+ updateSchema: UpdateRundeckConnectionSchema+ });++ // The below endpoints are not exposed and for Infisical App use+ server.route({+ method: "GET",+ url: `/:connectionId/projects`,+ config: {+ rateLimit: readLimit+ },+ schema: {+ operationId: "listRundeckProjects",+ params: z.object({+ connectionId: z.string().uuid()+ }),+ response: {+ 200: z.object({+ projects: z+ .object({+ name: z.string()+ })+ .array()+ })+ }+ },+ onRequest: verifyAuth([AuthMode.JWT]),+ handler: async (req) => {+ const { connectionId } = req.params;++ const projects = await server.services.appConnection.rundeck.listProjects(connectionId, req.permission);++ return { projects };+ }+ });+};diff --git a/backend/src/server/routes/v1/secret-sync-routers/index.ts b/backend/src/server/routes/v1/secret-sync-routers/index.tsindex 2b39b89dab..0cdcf48757 100644--- a/backend/src/server/routes/v1/secret-sync-routers/index.ts+++ b/backend/src/server/routes/v1/secret-sync-routers/index.ts@@ -34,6 +34,7 @@ import { registerOnaSyncRouter } from "./ona-sync-router";import { registerOvhSyncRouter } from "./ovh-sync-router";import { registerRailwaySyncRouter } from "./railway-sync-router";import { registerRenderSyncRouter } from "./render-sync-router";+import { registerRundeckSyncRouter } from "./rundeck-sync-router";import { registerSnowflakeSyncRouter } from "./snowflake-sync-router";import { registerSupabaseSyncRouter } from "./supabase-sync-router";import { registerTeamCitySyncRouter } from "./teamcity-sync-router";@@ -72,6 +73,7 @@ export const SECRET_SYNC_REGISTER_ROUTER_MAP: Record<SecretSync, (server: Fastif[SecretSync.CloudflarePages]: registerCloudflarePagesSyncRouter,[SecretSync.CloudflareWorkers]: registerCloudflareWorkersSyncRouter,[SecretSync.Supabase]: registerSupabaseSyncRouter,+ [SecretSync.Rundeck]: registerRundeckSyncRouter,[SecretSync.Zabbix]: registerZabbixSyncRouter,[SecretSync.Railway]: registerRailwaySyncRouter,[SecretSync.Checkly]: registerChecklySyncRouter,diff --git a/backend/src/server/routes/v1/secret-sync-routers/rundeck-sync-router.ts b/backend/src/server/routes/v1/secret-sync-routers/rundeck-sync-router.tsnew file mode 100644index 0000000000..ae1ff50599--- /dev/null+++ b/backend/src/server/routes/v1/secret-sync-routers/rundeck-sync-router.ts@@ -0,0 +1,13 @@+import { CreateRundeckSyncSchema, RundeckSyncSchema, UpdateRundeckSyncSchema } from "@app/services/secret-sync/rundeck";+import { SecretSync } from "@app/services/secret-sync/secret-sync-enums";++import { registerSyncSecretsEndpoints } from "./secret-sync-endpoints";++export const registerRundeckSyncRouter = async (server: FastifyZodProvider) =>+ registerSyncSecretsEndpoints({+ destination: SecretSync.Rundeck,+ server,+ responseSchema: RundeckSyncSchema,+ createSchema: CreateRundeckSyncSchema,+ updateSchema: UpdateRundeckSyncSchema+ });diff --git a/backend/src/server/routes/v1/secret-sync-routers/secret-sync-router.ts b/backend/src/server/routes/v1/secret-sync-routers/secret-sync-router.tsindex d512ea9b2f..65cfa2dc09 100644--- a/backend/src/server/routes/v1/secret-sync-routers/secret-sync-router.ts+++ b/backend/src/server/routes/v1/secret-sync-routers/secret-sync-router.ts@@ -63,6 +63,7 @@ import { OnaSyncListItemSchema, OnaSyncSchema } from "@app/services/secret-sync/import { OvhSyncListItemSchema, OvhSyncSchema } from "@app/services/secret-sync/ovh";import { RailwaySyncListItemSchema, RailwaySyncSchema } from "@app/services/secret-sync/railway/railway-sync-schemas";import { RenderSyncListItemSchema, RenderSyncSchema } from "@app/services/secret-sync/render/render-sync-schemas";+import { RundeckSyncListItemSchema, RundeckSyncSchema } from "@app/services/secret-sync/rundeck";import { SnowflakeSyncListItemSchema, SnowflakeSyncSchema } from "@app/services/secret-sync/snowflake";import { SupabaseSyncListItemSchema, SupabaseSyncSchema } from "@app/services/secret-sync/supabase";import { TeamCitySyncListItemSchema, TeamCitySyncSchema } from "@app/services/secret-sync/teamcity";@@ -99,6 +100,7 @@ const SecretSyncSchema = z.discriminatedUnion("destination", [CloudflarePagesSyncSchema,CloudflareWorkersSyncSchema,SupabaseSyncSchema,+ RundeckSyncSchema,ZabbixSyncSchema,RailwaySyncSchema,ChecklySyncSchema,@@ -149,6 +151,7 @@ const SecretSyncOptionsSchema = z.discriminatedUnion("destination", [RailwaySyncListItemSchema,ChecklySyncListItemSchema,SupabaseSyncListItemSchema,+ RundeckSyncListItemSchema,NetlifySyncListItemSchema,NorthflankSyncListItemSchema,BitbucketSyncListItemSchema,diff --git a/backend/src/services/app-connection/app-connection-enums.ts b/backend/src/services/app-connection/app-connection-enums.tsindex 2396a9309e..012065826a 100644--- a/backend/src/services/app-connection/app-connection-enums.ts+++ b/backend/src/services/app-connection/app-connection-enums.ts@@ -68,7 +68,8 @@ export enum AppConnection {Datadog = "datadog",F5BigIp = "f5-big-ip",GoDaddy = "godaddy",- Convex = "convex"+ Convex = "convex",+ Rundeck = "rundeck"}export enum AWSRegion {diff --git a/backend/src/services/app-connection/app-connection-fns.ts b/backend/src/services/app-connection/app-connection-fns.tsindex 6fdb0ede8c..2a3130c69b 100644--- a/backend/src/services/app-connection/app-connection-fns.ts+++ b/backend/src/services/app-connection/app-connection-fns.ts@@ -210,6 +210,7 @@ import { getRailwayConnectionListItem, validateRailwayConnectionCredentials } frimport { getRedisConnectionListItem, RedisConnectionMethod, validateRedisConnectionCredentials } from "./redis";import { RenderConnectionMethod } from "./render/render-connection-enums";import { getRenderConnectionListItem, validateRenderConnectionCredentials } from "./render/render-connection-fns";+import { getRundeckConnectionListItem, RundeckConnectionMethod, validateRundeckConnectionCredentials } from "./rundeck";import {getSalesforceConnectionListItem,SalesforceConnectionMethod,@@ -363,7 +364,8 @@ export const listAppConnectionOptions = (projectType?: ProjectType) => {getSnowflakeConnectionListItem(),getDatadogConnectionListItem(),getF5BigIpConnectionListItem(),- getConvexConnectionListItem()+ getConvexConnectionListItem(),+ getRundeckConnectionListItem()].filter((option) => {switch (projectType) {@@ -604,7 +606,8 @@ export const validateAppConnectionCredentials = async ([AppConnection.Snowflake]: validateSnowflakeConnectionCredentials as TAppConnectionCredentialsValidator,[AppConnection.Datadog]: validateDatadogConnectionCredentials as TAppConnectionCredentialsValidator,[AppConnection.F5BigIp]: validateF5BigIpConnectionCredentials as TAppConnectionCredentialsValidator,- [AppConnection.Convex]: validateConvexConnectionCredentials as TAppConnectionCredentialsValidator+ [AppConnection.Convex]: validateConvexConnectionCredentials as TAppConnectionCredentialsValidator,+ [AppConnection.Rundeck]: validateRundeckConnectionCredentials as TAppConnectionCredentialsValidator};return VALIDATE_APP_CONNECTION_CREDENTIALS_MAP[appConnection.app](appConnection, gatewayService, gatewayV2Service);@@ -655,6 +658,7 @@ export const getAppConnectionMethodName = (method: TAppConnection["method"]) =>case DbtConnectionMethod.ApiToken:case CircleCIConnectionMethod.ApiToken:case TravisCIConnectionMethod.ApiToken:+ case RundeckConnectionMethod.ApiToken:return "API Token";case DNSMadeEasyConnectionMethod.APIKeySecret:return "API Key & Secret";@@ -847,7 +851,8 @@ export const TRANSITION_CONNECTION_CREDENTIALS_TO_PLATFORM: Record<[AppConnection.Datadog]: platformManagedCredentialsNotSupported,[AppConnection.F5BigIp]: platformManagedCredentialsNotSupported,[AppConnection.GoDaddy]: platformManagedCredentialsNotSupported,- [AppConnection.Convex]: platformManagedCredentialsNotSupported+ [AppConnection.Convex]: platformManagedCredentialsNotSupported,+ [AppConnection.Rundeck]: platformManagedCredentialsNotSupported};export const enterpriseAppCheck = async (diff --git a/backend/src/services/app-connection/app-connection-maps.ts b/backend/src/services/app-connection/app-connection-maps.tsindex b265cce9c5..63d5d68366 100644--- a/backend/src/services/app-connection/app-connection-maps.ts+++ b/backend/src/services/app-connection/app-connection-maps.ts@@ -70,7 +70,8 @@ export const APP_CONNECTION_NAME_MAP: Record<AppConnection, string> = {[AppConnection.Datadog]: "Datadog",[AppConnection.F5BigIp]: "F5 BIG-IP",[AppConnection.GoDaddy]: "GoDaddy",- [AppConnection.Convex]: "Convex"+ [AppConnection.Convex]: "Convex",+ [AppConnection.Rundeck]: "Rundeck"};export const APP_CONNECTION_PLAN_MAP: Record<AppConnection, AppConnectionPlanType> = {@@ -143,5 +144,6 @@ export const APP_CONNECTION_PLAN_MAP: Record<AppConnection, AppConnectionPlanTyp[AppConnection.Datadog]: AppConnectionPlanType.Regular,[AppConnection.F5BigIp]: AppConnectionPlanType.Regular,[AppConnection.GoDaddy]: AppConnectionPlanType.Regular,- [AppConnection.Convex]: AppConnectionPlanType.Regular+ [AppConnection.Convex]: AppConnectionPlanType.Regular,+ [AppConnection.Rundeck]: AppConnectionPlanType.Regular};diff --git a/backend/src/services/app-connection/app-connection-service.ts b/backend/src/services/app-connection/app-connection-service.tsindex 310db7fce6..418958196d 100644--- a/backend/src/services/app-connection/app-connection-service.ts+++ b/backend/src/services/app-connection/app-connection-service.ts@@ -148,6 +148,8 @@ import { railwayConnectionService } from "./railway/railway-connection-service";import { ValidateRedisConnectionCredentialsSchema } from "./redis";import { ValidateRenderConnectionCredentialsSchema } from "./render/render-connection-schema";import { renderConnectionService } from "./render/render-connection-service";+import { ValidateRundeckConnectionCredentialsSchema } from "./rundeck";+import { rundeckConnectionService } from "./rundeck/rundeck-connection-service";import { ValidateSalesforceConnectionCredentialsSchema } from "./salesforce";import { salesforceConnectionService } from "./salesforce/salesforce-connection-service";import { ValidateSmbConnectionCredentialsSchema } from "./smb";@@ -266,7 +268,8 @@ const VALIDATE_APP_CONNECTION_CREDENTIALS_MAP: Record<AppConnection, TValidateAp[AppConnection.Snowflake]: ValidateSnowflakeConnectionCredentialsSchema,[AppConnection.Datadog]: ValidateDatadogConnectionCredentialsSchema,[AppConnection.F5BigIp]: ValidateF5BigIpConnectionCredentialsSchema,- [AppConnection.Convex]: ValidateConvexConnectionCredentialsSchema+ [AppConnection.Convex]: ValidateConvexConnectionCredentialsSchema,+ [AppConnection.Rundeck]: ValidateRundeckConnectionCredentialsSchema};export const appConnectionServiceFactory = ({@@ -1345,6 +1348,7 @@ export const appConnectionServiceFactory = ({bitbucket: bitbucketConnectionService(connectAppConnectionById),checkly: checklyConnectionService(connectAppConnectionById),supabase: supabaseConnectionService(connectAppConnectionById),+ rundeck: rundeckConnectionService(connectAppConnectionById),digitalOcean: digitalOceanAppPlatformConnectionService(connectAppConnectionById),netlify: netlifyConnectionService(connectAppConnectionById),northflank: northflankConnectionService(connectAppConnectionById),diff --git a/backend/src/services/app-connection/app-connection-types.ts b/backend/src/services/app-connection/app-connection-types.tsindex 3fccad5c92..7d6967ccf4 100644--- a/backend/src/services/app-connection/app-connection-types.ts+++ b/backend/src/services/app-connection/app-connection-types.ts@@ -329,6 +329,12 @@ import {TRenderConnectionInput,TValidateRenderConnectionCredentialsSchema} from "./render/render-connection-types";+import {+ TRundeckConnection,+ TRundeckConnectionConfig,+ TRundeckConnectionInput,+ TValidateRundeckConnectionCredentialsSchema+} from "./rundeck";import {TSalesforceConnection,TSalesforceConnectionConfig,@@ -487,6 +493,7 @@ export type TAppConnection = { id: string; configuration?: TAppConnectionConfigu| TDatadogConnection| TF5BigIpConnection| TConvexConnection+ | TRundeckConnection);export type TAppConnectionRaw = NonNullable<Awaited<ReturnType<TAppConnectionDALFactory["findById"]>>>;@@ -568,6 +575,7 @@ export type TAppConnectionInput = { id: string } & (| TDatadogConnectionInput| TF5BigIpConnectionInput| TConvexConnectionInput+ | TRundeckConnectionInput);export type TSqlConnectionInput =@@ -680,7 +688,8 @@ export type TAppConnectionConfig =| TSnowflakeConnectionConfig| TDatadogConnectionConfig| TF5BigIpConnectionConfig- | TConvexConnectionConfig;+ | TConvexConnectionConfig+ | TRundeckConnectionConfig;export type TValidateAppConnectionCredentialsSchema =| TValidateAwsConnectionCredentialsSchema@@ -752,7 +761,8 @@ export type TValidateAppConnectionCredentialsSchema =| TValidateSnowflakeConnectionCredentialsSchema| TValidateDatadogConnectionCredentialsSchema| TValidateF5BigIpConnectionCredentialsSchema- | TValidateConvexConnectionCredentialsSchema;+ | TValidateConvexConnectionCredentialsSchema+ | TValidateRundeckConnectionCredentialsSchema;export type TListAwsConnectionKmsKeys = {connectionId: string;diff --git a/backend/src/services/app-connection/rundeck/index.ts b/backend/src/services/app-connection/rundeck/index.tsnew file mode 100644index 0000000000..fe7c60702c--- /dev/null+++ b/backend/src/services/app-connection/rundeck/index.ts@@ -0,0 +1,4 @@+export * from "./rundeck-connection-enums";+export * from "./rundeck-connection-fns";+export * from "./rundeck-connection-schemas";+export * from "./rundeck-connection-types";diff --git a/backend/src/services/app-connection/rundeck/rundeck-connection-enums.ts b/backend/src/services/app-connection/rundeck/rundeck-connection-enums.tsnew file mode 100644index 0000000000..0c740aff74--- /dev/null+++ b/backend/src/services/app-connection/rundeck/rundeck-connection-enums.ts@@ -0,0 +1,3 @@+export enum RundeckConnectionMethod {+ ApiToken = "api-token"+}diff --git a/backend/src/services/app-connection/rundeck/rundeck-connection-fns.ts b/backend/src/services/app-connection/rundeck/rundeck-connection-fns.tsnew file mode 100644index 0000000000..0afef9b07f--- /dev/null+++ b/backend/src/services/app-connection/rundeck/rundeck-connection-fns.ts@@ -0,0 +1,83 @@+import { AxiosError } from "axios";++import { request } from "@app/lib/config/request";+import { BadRequestError } from "@app/lib/errors";+import { removeTrailingSlash } from "@app/lib/fn";+import { blockLocalAndPrivateIpAddresses } from "@app/lib/validator";++import { AppConnection } from "../app-connection-enums";+import { RundeckConnectionMethod } from "./rundeck-connection-enums";+import { TRundeckConnection, TRundeckConnectionConfig, TRundeckProject } from "./rundeck-connection-types";++export const getRundeckInstanceUrl = async (config: TRundeckConnectionConfig) => {+ const instanceUrl = removeTrailingSlash(config.credentials.instanceUrl);++ await blockLocalAndPrivateIpAddresses(instanceUrl);++ return instanceUrl;+};++export const getRundeckConnectionListItem = () => {+ return {+ name: "Rundeck" as const,+ app: AppConnection.Rundeck as const,+ methods: Object.values(RundeckConnectionMethod) as [RundeckConnectionMethod.ApiToken]+ };+};++export const validateRundeckConnectionCredentials = async (config: TRundeckConnectionConfig) => {+ const instanceUrl = await getRundeckInstanceUrl(config);+ const { apiToken } = config.credentials;++ try {+ await request.get(`${instanceUrl}/api/14/projects`, {+ headers: {+ "X-Rundeck-Auth-Token": apiToken,+ Accept: "application/json"+ }+ });+ } catch (error: unknown) {+ if (error instanceof AxiosError) {+ throw new BadRequestError({+ message: `Failed to validate Rundeck credentials: ${error.message || "Unknown error"}`+ });+ }++ throw new BadRequestError({+ message: `Failed to validate Rundeck credentials - verify the instance URL and API token are correct`+ });+ }++ return config.credentials;+};++export const listRundeckProjects = async (appConnection: TRundeckConnection): Promise<TRundeckProject[]> => {+ const instanceUrl = await getRundeckInstanceUrl(appConnection);+ const { apiToken } = appConnection.credentials;++ try {+ const { data } = await request.get<TRundeckProject[]>(`${instanceUrl}/api/14/projects`, {+ headers: {+ "X-Rundeck-Auth-Token": apiToken,+ Accept: "application/json"+ }+ });++ return data.map((project) => ({ name: project.name }));+ } catch (error: unknown) {+ if (error instanceof AxiosError) {+ throw new BadRequestError({+ message: `Failed to list Rundeck projects: ${error.message || "Unknown error"}`+ });+ }++ if (error instanceof BadRequestError) {+ throw error;+ }++ throw new BadRequestError({+ message: "Unable to list Rundeck projects",+ error+ });+ }+};diff --git a/backend/src/services/app-connection/rundeck/rundeck-connection-schemas.ts b/backend/src/services/app-connection/rundeck/rundeck-connection-schemas.tsnew file mode 100644index 0000000000..7ad098f95a--- /dev/null+++ b/backend/src/services/app-connection/rundeck/rundeck-connection-schemas.ts@@ -0,0 +1,70 @@+import z from "zod";++import { AppConnections } from "@app/lib/api-docs";+import { AppConnection } from "@app/services/app-connection/app-connection-enums";+import {+ BaseAppConnectionSchema,+ GenericCreateAppConnectionFieldsSchema,+ GenericUpdateAppConnectionFieldsSchema+} from "@app/services/app-connection/app-connection-schemas";++import { APP_CONNECTION_NAME_MAP } from "../app-connection-maps";+import { RundeckConnectionMethod } from "./rundeck-connection-enums";++export const RundeckConnectionApiTokenCredentialsSchema = z.object({+ instanceUrl: z+ .string()+ .trim()+ .url("Invalid Instance URL")+ .min(1, "Instance URL required")+ .max(255)+ .describe(AppConnections.CREDENTIALS.RUNDECK.instanceUrl),+ apiToken: z.string().trim().min(1, "API token required").describe(AppConnections.CREDENTIALS.RUNDECK.apiToken)+});++const BaseRundeckConnectionSchema = BaseAppConnectionSchema.extend({+ app: z.literal(AppConnection.Rundeck)+});++export const RundeckConnectionSchema = z.discriminatedUnion("method", [+ BaseRundeckConnectionSchema.extend({+ method: z.literal(RundeckConnectionMethod.ApiToken),+ credentials: RundeckConnectionApiTokenCredentialsSchema+ })+]);++export const SanitizedRundeckConnectionSchema = z.discriminatedUnion("method", [+ BaseRundeckConnectionSchema.extend({+ method: z.literal(RundeckConnectionMethod.ApiToken),+ credentials: RundeckConnectionApiTokenCredentialsSchema.pick({ instanceUrl: true })+ }).describe(JSON.stringify({ title: `${APP_CONNECTION_NAME_MAP[AppConnection.Rundeck]} (API Token)` }))+]);++export const ValidateRundeckConnectionCredentialsSchema = z.discriminatedUnion("method", [+ z.object({+ method: z.literal(RundeckConnectionMethod.ApiToken).describe(AppConnections.CREATE(AppConnection.Rundeck).method),+ credentials: RundeckConnectionApiTokenCredentialsSchema.describe(+ AppConnections.CREATE(AppConnection.Rundeck).credentials+ )+ })+]);++export const CreateRundeckConnectionSchema = ValidateRundeckConnectionCredentialsSchema.and(+ GenericCreateAppConnectionFieldsSchema(AppConnection.Rundeck)+);++export const UpdateRundeckConnectionSchema = z+ .object({+ credentials: RundeckConnectionApiTokenCredentialsSchema.optional().describe(+ AppConnections.UPDATE(AppConnection.Rundeck).credentials+ )+ })+ .and(GenericUpdateAppConnectionFieldsSchema(AppConnection.Rundeck));++export const RundeckConnectionListItemSchema = z+ .object({+ name: z.literal("Rundeck"),+ app: z.literal(AppConnection.Rundeck),+ methods: z.nativeEnum(RundeckConnectionMethod).array()+ })+ .describe(JSON.stringify({ title: APP_CONNECTION_NAME_MAP[AppConnection.Rundeck] }));diff --git a/backend/src/services/app-connection/rundeck/rundeck-connection-service.ts b/backend/src/services/app-connection/rundeck/rundeck-connection-service.tsnew file mode 100644index 0000000000..fdd0866f4d--- /dev/null+++ b/backend/src/services/app-connection/rundeck/rundeck-connection-service.ts@@ -0,0 +1,30 @@+import { logger } from "@app/lib/logger";+import { OrgServiceActor } from "@app/lib/types";++import { AppConnection } from "../app-connection-enums";+import { listRundeckProjects } from "./rundeck-connection-fns";+import { TRundeckConnection } from "./rundeck-connection-types";++type TGetAppConnectionFunc = (+ app: AppConnection,+ connectionId: string,+ actor: OrgServiceActor+) => Promise<TRundeckConnection>;++export const rundeckConnectionService = (getAppConnection: TGetAppConnectionFunc) => {+ const listProjects = async (connectionId: string, actor: OrgServiceActor) => {+ const appConnection = await getAppConnection(AppConnection.Rundeck, connectionId, actor);+ try {+ const projects = await listRundeckProjects(appConnection);++ return projects ?? [];+ } catch (error) {+ logger.error(error, "Failed to establish connection with Rundeck");+ return [];+ }+ };++ return {+ listProjects+ };+};diff --git a/backend/src/services/app-connection/rundeck/rundeck-connection-types.ts b/backend/src/services/app-connection/rundeck/rundeck-connection-types.tsnew file mode 100644index 0000000000..72744d82b4--- /dev/null+++ b/backend/src/services/app-connection/rundeck/rundeck-connection-types.ts@@ -0,0 +1,24 @@+import z from "zod";++import { DiscriminativePick } from "@app/lib/types";++import { AppConnection } from "../app-connection-enums";+import {+ CreateRundeckConnectionSchema,+ RundeckConnectionSchema,+ ValidateRundeckConnectionCredentialsSchema+} from "./rundeck-connection-schemas";++export type TRundeckConnection = z.infer<typeof RundeckConnectionSchema>;++export type TRundeckConnectionInput = z.infer<typeof CreateRundeckConnectionSchema> & {+ app: AppConnection.Rundeck;+};++export type TValidateRundeckConnectionCredentialsSchema = typeof ValidateRundeckConnectionCredentialsSchema;++export type TRundeckConnectionConfig = DiscriminativePick<TRundeckConnectionInput, "method" | "app" | "credentials">;++export type TRundeckProject = {+ name: string;+};diff --git a/backend/src/services/integration-auth/integration-list.ts b/backend/src/services/integration-auth/integration-list.tsindex f2956c12c6..876afde7f9 100644--- a/backend/src/services/integration-auth/integration-list.ts+++ b/backend/src/services/integration-auth/integration-list.ts@@ -414,7 +414,7 @@ export const getIntegrationOptions = async () => {docsLink: ""},{- name: "Rundeck",+ name: "RundecRundeckk",slug: "rundeck",image: "Rundeck.svg",isAvailable: true,diff --git a/backend/src/services/secret-sync/rundeck/index.ts b/backend/src/services/secret-sync/rundeck/index.tsnew file mode 100644index 0000000000..842a6ee815--- /dev/null+++ b/backend/src/services/secret-sync/rundeck/index.ts@@ -0,0 +1,4 @@+export * from "./rundeck-sync-constants";+export * from "./rundeck-sync-fns";+export * from "./rundeck-sync-schemas";+export * from "./rundeck-sync-types";diff --git a/backend/src/services/secret-sync/rundeck/rundeck-sync-constants.ts b/backend/src/services/secret-sync/rundeck/rundeck-sync-constants.tsnew file mode 100644index 0000000000..7fbefdfa9e--- /dev/null+++ b/backend/src/services/secret-sync/rundeck/rundeck-sync-constants.ts@@ -0,0 +1,11 @@+import { AppConnection } from "@app/services/app-connection/app-connection-enums";+import { SecretSync } from "@app/services/secret-sync/secret-sync-enums";+import { TSecretSyncListItem } from "@app/services/secret-sync/secret-sync-types";++export const RUNDECK_SYNC_LIST_OPTION: TSecretSyncListItem = {+ name: "Rundeck",+ destination: SecretSync.Rundeck,+ connection: AppConnection.Rundeck,+ canRemoveSecretsOnDeletion: true,+ canImportSecrets: false+};diff --git a/backend/src/services/secret-sync/rundeck/rundeck-sync-fns.ts b/backend/src/services/secret-sync/rundeck/rundeck-sync-fns.tsnew file mode 100644index 0000000000..e9dd8d01f8--- /dev/null+++ b/backend/src/services/secret-sync/rundeck/rundeck-sync-fns.ts@@ -0,0 +1,132 @@+/* eslint-disable no-await-in-loop */+/* eslint-disable no-continue */+import { AxiosError } from "axios";++import { request } from "@app/lib/config/request";+import { removeTrailingSlash } from "@app/lib/fn";+import { blockLocalAndPrivateIpAddresses } from "@app/lib/validator";+import { matchesSchema } from "@app/services/secret-sync/secret-sync-fns";++import { SecretSyncError } from "../secret-sync-errors";+import { SECRET_SYNC_NAME_MAP } from "../secret-sync-maps";+import { TSecretMap } from "../secret-sync-types";+import { TRundeckSyncWithCredentials } from "./rundeck-sync-types";++// Rundeck Key Storage API version (matches the native Rundeck integration)+const RUNDECK_STORAGE_API_VERSION = 44;++const RUNDECK_SECRET_CONTENT_TYPE = "application/x-rundeck-data-password";++type TRundeckStorageResource = {+ name: string;+};++type TRundeckStorageListResponse = {+ resources: TRundeckStorageResource[];+};++/**+ * Secrets are stored under the selected project's Rundeck Key Storage:+ * keys/project/<project>/<path>/<secretKey>+ */+const getRundeckStoragePath = (project: string, path: string) => {+ const normalizedPath = path.replace(/^\/+|\/+$/g, "");+ return `keys/project/${project}/${normalizedPath}`;+};++const getRundeckClientDetails = async (secretSync: TRundeckSyncWithCredentials) => {+ const { connection, destinationConfig } = secretSync;++ const instanceUrl = removeTrailingSlash(connection.credentials.instanceUrl);+ await blockLocalAndPrivateIpAddresses(instanceUrl);++ const storagePath = getRundeckStoragePath(destinationConfig.project, destinationConfig.path);++ return {+ baseUrl: `${instanceUrl}/api/${RUNDECK_STORAGE_API_VERSION}/storage/${storagePath}`,+ headers: {+ "X-Rundeck-Auth-Token": connection.credentials.apiToken+ }+ };+};++const listRundeckSecretKeys = async (baseUrl: string, headers: Record<string, string>): Promise<string[]> => {+ try {+ const { data } = await request.get<TRundeckStorageListResponse>(baseUrl, { headers });+ return data.resources.map((resource) => resource.name);+ } catch (error) {+ // The storage path does not exist until the first secret is written - treat as empty+ if (error instanceof AxiosError && error.response?.status === 404) {+ return [];+ }+ throw new SecretSyncError({ error });+ }+};++export const RundeckSyncFns = {+ async getSecrets(secretSync: TRundeckSyncWithCredentials): Promise<TSecretMap> {+ throw new Error(`${SECRET_SYNC_NAME_MAP[secretSync.destination]} does not support importing secrets.`);+ },++ async syncSecrets(secretSync: TRundeckSyncWithCredentials, secretMap: TSecretMap) {+ const {+ environment,+ syncOptions: { disableSecretDeletion, keySchema }+ } = secretSync;++ const { baseUrl, headers } = await getRundeckClientDetails(secretSync);++ const existingSecretKeys = await listRundeckSecretKeys(baseUrl, headers);+ const existingSecretKeySet = new Set(existingSecretKeys);++ for (const key of Object.keys(secretMap)) {+ const value = secretMap[key].value ?? "";+ const url = `${baseUrl}/${key}`;++ try {+ if (existingSecretKeySet.has(key)) {+ await request.put(url, value, {+ headers: { ...headers, "Content-Type": RUNDECK_SECRET_CONTENT_TYPE }+ });+ } else {+ await request.post(url, value, {+ headers: { ...headers, "Content-Type": RUNDECK_SECRET_CONTENT_TYPE }+ });+ }+ } catch (error) {+ throw new SecretSyncError({ error, secretKey: key });+ }+ }++ if (disableSecretDeletion) return;++ for (const key of existingSecretKeys) {+ // Only remove keys managed by this sync (respecting the configured key schema)+ if (!matchesSchema(key, environment?.slug || "", keySchema)) continue;++ if (!(key in secretMap)) {+ try {+ await request.delete(`${baseUrl}/${key}`, { headers });+ } catch (error) {+ throw new SecretSyncError({ error, secretKey: key });+ }+ }+ }+ },++ async removeSecrets(secretSync: TRundeckSyncWithCredentials, secretMap: TSecretMap) {+ const { baseUrl, headers } = await getRundeckClientDetails(secretSync);++ const existingSecretKeys = await listRundeckSecretKeys(baseUrl, headers);++ for (const key of existingSecretKeys) {+ if (!(key in secretMap)) continue;++ try {+ await request.delete(`${baseUrl}/${key}`, { headers });+ } catch (error) {+ throw new SecretSyncError({ error, secretKey: key });+ }+ }+ }+};diff --git a/backend/src/services/secret-sync/rundeck/rundeck-sync-schemas.ts b/backend/src/services/secret-sync/rundeck/rundeck-sync-schemas.tsnew file mode 100644index 0000000000..159306e7d1--- /dev/null+++ b/backend/src/services/secret-sync/rundeck/rundeck-sync-schemas.ts@@ -0,0 +1,50 @@+import { z } from "zod";++import { AppConnection } from "@app/services/app-connection/app-connection-enums";+import { SecretSync } from "@app/services/secret-sync/secret-sync-enums";+import {+ BaseSecretSyncSchema,+ GenericCreateSecretSyncFieldsSchema,+ GenericUpdateSecretSyncFieldsSchema+} from "@app/services/secret-sync/secret-sync-schemas";+import { TSyncOptionsConfig } from "@app/services/secret-sync/secret-sync-types";++import { SECRET_SYNC_NAME_MAP } from "../secret-sync-maps";++const RundeckSyncDestinationConfigSchema = z.object({+ project: z.string().min(1, "Project is required").max(255),+ path: z.string().min(1, "Path is required").max(255)+});++const RundeckSyncOptionsConfig: TSyncOptionsConfig = { canImportSecrets: false };++export const RundeckSyncSchema = BaseSecretSyncSchema(SecretSync.Rundeck, RundeckSyncOptionsConfig)+ .extend({+ destination: z.literal(SecretSync.Rundeck),+ destinationConfig: RundeckSyncDestinationConfigSchema+ })+ .describe(JSON.stringify({ title: SECRET_SYNC_NAME_MAP[SecretSync.Rundeck] }));++export const CreateRundeckSyncSchema = GenericCreateSecretSyncFieldsSchema(+ SecretSync.Rundeck,+ RundeckSyncOptionsConfig+).extend({+ destinationConfig: RundeckSyncDestinationConfigSchema+});++export const UpdateRundeckSyncSchema = GenericUpdateSecretSyncFieldsSchema(+ SecretSync.Rundeck,+ RundeckSyncOptionsConfig+).extend({+ destinationConfig: RundeckSyncDestinationConfigSchema.optional()+});++export const RundeckSyncListItemSchema = z+ .object({+ name: z.literal("Rundeck"),+ connection: z.literal(AppConnection.Rundeck),+ destination: z.literal(SecretSync.Rundeck),+ canImportSecrets: z.literal(false),+ canRemoveSecretsOnDeletion: z.literal(true)+ })+ .describe(JSON.stringify({ title: SECRET_SYNC_NAME_MAP[SecretSync.Rundeck] }));diff --git a/backend/src/services/secret-sync/rundeck/rundeck-sync-types.ts b/backend/src/services/secret-sync/rundeck/rundeck-sync-types.tsnew file mode 100644index 0000000000..4f9819c654--- /dev/null+++ b/backend/src/services/secret-sync/rundeck/rundeck-sync-types.ts@@ -0,0 +1,15 @@+import z from "zod";++import { TRundeckConnection } from "@app/services/app-connection/rundeck";++import { CreateRundeckSyncSchema, RundeckSyncListItemSchema, RundeckSyncSchema } from "./rundeck-sync-schemas";++export type TRundeckSyncListItem = z.infer<typeof RundeckSyncListItemSchema>;++export type TRundeckSync = z.infer<typeof RundeckSyncSchema>;++export type TRundeckSyncInput = z.infer<typeof CreateRundeckSyncSchema>;++export type TRundeckSyncWithCredentials = TRundeckSync & {+ connection: TRundeckConnection;+};diff --git a/backend/src/services/secret-sync/secret-sync-enums.ts b/backend/src/services/secret-sync/secret-sync-enums.tsindex b7c3793f77..a86971022a 100644--- a/backend/src/services/secret-sync/secret-sync-enums.ts+++ b/backend/src/services/secret-sync/secret-sync-enums.ts@@ -41,7 +41,8 @@ export enum SecretSync {Devin = "devin",Ona = "ona",TravisCI = "travis-ci",- Snowflake = "snowflake"+ Snowflake = "snowflake",+ Rundeck = "rundeck"}export enum SecretSyncInitialSyncBehavior {diff --git a/backend/src/services/secret-sync/secret-sync-fns.ts b/backend/src/services/secret-sync/secret-sync-fns.tsindex c0fbc56495..cf71a7a24d 100644--- a/backend/src/services/secret-sync/secret-sync-fns.ts+++ b/backend/src/services/secret-sync/secret-sync-fns.ts@@ -77,6 +77,7 @@ import { OVH_SYNC_LIST_OPTION, OvhSyncFns } from "./ovh";import { RAILWAY_SYNC_LIST_OPTION } from "./railway/railway-sync-constants";import { RailwaySyncFns } from "./railway/railway-sync-fns";import { RENDER_SYNC_LIST_OPTION, RenderSyncFns } from "./render";+import { RUNDECK_SYNC_LIST_OPTION, RundeckSyncFns } from "./rundeck";import { SECRET_SYNC_PLAN_MAP } from "./secret-sync-maps";import { SNOWFLAKE_SYNC_LIST_OPTION, SnowflakeSyncFns } from "./snowflake";import { SUPABASE_SYNC_LIST_OPTION, SupabaseSyncFns } from "./supabase";@@ -114,6 +115,7 @@ const SECRET_SYNC_LIST_OPTIONS: Record<SecretSync, TSecretSyncListItem> = {[SecretSync.CloudflarePages]: CLOUDFLARE_PAGES_SYNC_LIST_OPTION,[SecretSync.CloudflareWorkers]: CLOUDFLARE_WORKERS_SYNC_LIST_OPTION,[SecretSync.Supabase]: SUPABASE_SYNC_LIST_OPTION,+ [SecretSync.Rundeck]: RUNDECK_SYNC_LIST_OPTION,[SecretSync.Zabbix]: ZABBIX_SYNC_LIST_OPTION,[SecretSync.Railway]: RAILWAY_SYNC_LIST_OPTION,[SecretSync.Checkly]: CHECKLY_SYNC_LIST_OPTION,@@ -397,6 +399,8 @@ export const SecretSyncFns = {return ChecklySyncFns.syncSecrets(secretSync, schemaSecretMap);case SecretSync.Supabase:return SupabaseSyncFns.syncSecrets(secretSync, schemaSecretMap);+ case SecretSync.Rundeck:+ return RundeckSyncFns.syncSecrets(secretSync, schemaSecretMap);case SecretSync.DigitalOceanAppPlatform:return DigitalOceanAppPlatformSyncFns.syncSecrets(secretSync, schemaSecretMap);case SecretSync.Netlify:@@ -545,6 +549,9 @@ export const SecretSyncFns = {case SecretSync.Supabase:secretMap = await SupabaseSyncFns.getSecrets(secretSync);break;+ case SecretSync.Rundeck:+ secretMap = await RundeckSyncFns.getSecrets(secretSync);+ break;case SecretSync.DigitalOceanAppPlatform:secretMap = await DigitalOceanAppPlatformSyncFns.getSecrets(secretSync);break;@@ -702,6 +709,8 @@ export const SecretSyncFns = {return ChecklySyncFns.removeSecrets(secretSync, schemaSecretMap);case SecretSync.Supabase:return SupabaseSyncFns.removeSecrets(secretSync, schemaSecretMap);+ case SecretSync.Rundeck:+ return RundeckSyncFns.removeSecrets(secretSync, schemaSecretMap);case SecretSync.DigitalOceanAppPlatform:return DigitalOceanAppPlatformSyncFns.removeSecrets(secretSync, schemaSecretMap);case SecretSync.Netlify:diff --git a/backend/src/services/secret-sync/secret-sync-maps.ts b/backend/src/services/secret-sync/secret-sync-maps.tsindex 2012c99ae7..b9f61332a9 100644--- a/backend/src/services/secret-sync/secret-sync-maps.ts+++ b/backend/src/services/secret-sync/secret-sync-maps.ts@@ -28,6 +28,7 @@ export const SECRET_SYNC_NAME_MAP: Record<SecretSync, string> = {[SecretSync.CloudflarePages]: "Cloudflare Pages",[SecretSync.CloudflareWorkers]: "Cloudflare Workers",[SecretSync.Supabase]: "Supabase",+ [SecretSync.Rundeck]: "Rundeck",[SecretSync.Zabbix]: "Zabbix",[SecretSync.Railway]: "Railway",[SecretSync.Checkly]: "Checkly",@@ -74,6 +75,7 @@ export const SECRET_SYNC_CONNECTION_MAP: Record<SecretSync, AppConnection> = {[SecretSync.CloudflarePages]: AppConnection.Cloudflare,[SecretSync.CloudflareWorkers]: AppConnection.Cloudflare,[SecretSync.Supabase]: AppConnection.Supabase,+ [SecretSync.Rundeck]: AppConnection.Rundeck,[SecretSync.Zabbix]: AppConnection.Zabbix,[SecretSync.Railway]: AppConnection.Railway,[SecretSync.Checkly]: AppConnection.Checkly,@@ -120,6 +122,7 @@ export const SECRET_SYNC_PLAN_MAP: Record<SecretSync, SecretSyncPlanType> = {[SecretSync.CloudflarePages]: SecretSyncPlanType.Regular,[SecretSync.CloudflareWorkers]: SecretSyncPlanType.Regular,[SecretSync.Supabase]: SecretSyncPlanType.Regular,+ [SecretSync.Rundeck]: SecretSyncPlanType.Regular,[SecretSync.Zabbix]: SecretSyncPlanType.Regular,[SecretSync.Railway]: SecretSyncPlanType.Regular,[SecretSync.Checkly]: SecretSyncPlanType.Regular,@@ -175,6 +178,7 @@ export const SECRET_SYNC_SKIP_FIELDS_MAP: Record<SecretSync, string[]> = {[SecretSync.CloudflarePages]: [],[SecretSync.CloudflareWorkers]: [],[SecretSync.Supabase]: ["projectName"],+ [SecretSync.Rundeck]: [],[SecretSync.Zabbix]: ["hostName", "macroType"],[SecretSync.Railway]: ["projectName", "environmentName", "serviceName"],[SecretSync.Checkly]: ["groupName", "accountName"],@@ -247,6 +251,7 @@ export const DESTINATION_DUPLICATE_CHECK_MAP: Record<SecretSync, DestinationDupl[SecretSync.CloudflarePages]: defaultDuplicateCheck,[SecretSync.CloudflareWorkers]: defaultDuplicateCheck,[SecretSync.Supabase]: defaultDuplicateCheck,+ [SecretSync.Rundeck]: defaultDuplicateCheck,[SecretSync.Zabbix]: defaultDuplicateCheck,[SecretSync.Railway]: defaultDuplicateCheck,[SecretSync.Checkly]: defaultDuplicateCheck,diff --git a/backend/src/services/secret-sync/secret-sync-types.ts b/backend/src/services/secret-sync/secret-sync-types.tsindex ba577e867d..c5272d0b72 100644--- a/backend/src/services/secret-sync/secret-sync-types.ts+++ b/backend/src/services/secret-sync/secret-sync-types.ts@@ -173,6 +173,12 @@ import {TRenderSyncListItem,TRenderSyncWithCredentials} from "./render/render-sync-types";+import {+ TRundeckSync,+ TRundeckSyncInput,+ TRundeckSyncListItem,+ TRundeckSyncWithCredentials+} from "./rundeck/rundeck-sync-types";import {TSnowflakeSync,TSnowflakeSyncInput,@@ -238,6 +244,7 @@ export type TSecretSync =| TRailwaySync| TChecklySync| TSupabaseSync+ | TRundeckSync| TNetlifySync| TNorthflankSync| TBitbucketSync@@ -281,6 +288,7 @@ export type TSecretSyncWithCredentials =| TRailwaySyncWithCredentials| TChecklySyncWithCredentials| TSupabaseSyncWithCredentials+ | TRundeckSyncWithCredentials| TDigitalOceanAppPlatformSyncWithCredentials| TNetlifySyncWithCredentials| TNorthflankSyncWithCredentials@@ -326,6 +334,7 @@ export type TSecretSyncInput =| TRailwaySyncInput| TChecklySyncInput| TSupabaseSyncInput+ | TRundeckSyncInput| TDigitalOceanAppPlatformSyncInput| TNetlifySyncInput| TNorthflankSyncInput@@ -372,6 +381,7 @@ export type TSecretSyncListItem =| TRailwaySyncListItem| TChecklySyncListItem| TSupabaseSyncListItem+ | TRundeckSyncListItem| TDigitalOceanAppPlatformSyncListItem| TNetlifySyncListItem| TNorthflankSyncListItemdiff --git a/frontend/src/components/secret-syncs/forms/SecretSyncDestinationFields/RundeckSyncFields.tsx b/frontend/src/components/secret-syncs/forms/SecretSyncDestinationFields/RundeckSyncFields.tsxnew file mode 100644index 0000000000..f6f13c2f68--- /dev/null+++ b/frontend/src/components/secret-syncs/forms/SecretSyncDestinationFields/RundeckSyncFields.tsx@@ -0,0 +1,92 @@+import { Controller, useFormContext, useWatch } from "react-hook-form";+import { SingleValue } from "react-select";++import { SecretSyncConnectionField } from "@app/components/secret-syncs/forms/SecretSyncConnectionField";+import {+ Field,+ FieldContent,+ FieldDescription,+ FieldError,+ FieldGroup,+ FieldLabel,+ FilterableSelect,+ Input+} from "@app/components/v3";+import {+ TRundeckProject,+ useRundeckConnectionListProjects+} from "@app/hooks/api/appConnections/rundeck";+import { SecretSync } from "@app/hooks/api/secretSyncs";++import { TSecretSyncForm } from "../schemas";++export const RundeckSyncFields = () => {+ const { control, setValue } = useFormContext<+ TSecretSyncForm & { destination: SecretSync.Rundeck }+ >();++ const connectionId = useWatch({ name: "connection.id", control });++ const { data: projects = [], isPending: isProjectsLoading } = useRundeckConnectionListProjects(+ connectionId,+ {+ enabled: Boolean(connectionId)+ }+ );++ return (+ <FieldGroup>+ <SecretSyncConnectionField+ onChange={() => {+ setValue("destinationConfig.project", "");+ }}+ />+ <Controller+ name="destinationConfig.project"+ control={control}+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <Field>+ <FieldLabel>Project</FieldLabel>+ <FieldContent>+ <FilterableSelect+ isLoading={isProjectsLoading && Boolean(connectionId)}+ isDisabled={!connectionId}+ value={projects.find((project) => project.name === value) ?? null}+ onChange={(option) => {+ const selected = option as SingleValue<TRundeckProject>;+ onChange(selected?.name ?? "");+ }}+ options={projects}+ placeholder="Select a project..."+ getOptionLabel={(option) => option.name}+ getOptionValue={(option) => option.name}+ />+ <FieldError errors={[error]} />+ </FieldContent>+ </Field>+ )}+ />+ <Controller+ name="destinationConfig.path"+ control={control}+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <Field>+ <FieldLabel>Path</FieldLabel>+ <FieldContent>+ <Input+ value={value}+ onChange={onChange}+ placeholder="production"+ isError={Boolean(error)}+ />+ <FieldDescription>+ {`Secrets are stored in this project's Rundeck Key Storage under keys/project/<project>/<path>.`}+ </FieldDescription>+ <FieldError errors={[error]} />+ </FieldContent>+ </Field>+ )}+ />+ </FieldGroup>+ );+};diff --git a/frontend/src/components/secret-syncs/forms/SecretSyncDestinationFields/SecretSyncDestinationFields.tsx b/frontend/src/components/secret-syncs/forms/SecretSyncDestinationFields/SecretSyncDestinationFields.tsxindex 24811b6e0e..6b5bf8be04 100644--- a/frontend/src/components/secret-syncs/forms/SecretSyncDestinationFields/SecretSyncDestinationFields.tsx+++ b/frontend/src/components/secret-syncs/forms/SecretSyncDestinationFields/SecretSyncDestinationFields.tsx@@ -38,6 +38,7 @@ import { OvhSyncFields } from "./OvhSyncFields";import { RailwaySyncFields } from "./RailwaySyncFields";import { RenderSyncFields } from "./RenderSyncFields";import { SnowflakeSyncFields } from "./SnowflakeSyncFields";+import { RundeckSyncFields } from "./RundeckSyncFields";import { SupabaseSyncFields } from "./SupabaseSyncFields";import { TeamCitySyncFields } from "./TeamCitySyncFields";import { TerraformCloudSyncFields } from "./TerraformCloudSyncFields";@@ -107,6 +108,8 @@ export const SecretSyncDestinationFields = () => {return <ChecklySyncFields />;case SecretSync.Supabase:return <SupabaseSyncFields />;+ case SecretSync.Rundeck:+ return <RundeckSyncFields />;case SecretSync.DigitalOceanAppPlatform:return <DigitalOceanAppPlatformSyncFields />;case SecretSync.Netlify:diff --git a/frontend/src/components/secret-syncs/forms/SecretSyncOptionsFields/SecretSyncOptionsFields.tsx b/frontend/src/components/secret-syncs/forms/SecretSyncOptionsFields/SecretSyncOptionsFields.tsxindex 3c340cb1e4..d2f1ae4a0c 100644--- a/frontend/src/components/secret-syncs/forms/SecretSyncOptionsFields/SecretSyncOptionsFields.tsx+++ b/frontend/src/components/secret-syncs/forms/SecretSyncOptionsFields/SecretSyncOptionsFields.tsx@@ -132,6 +132,7 @@ export const SecretSyncOptionsFields = ({ hideInitialSync, children }: Props) =>case SecretSync.Ona:case SecretSync.TravisCI:case SecretSync.Snowflake:+ case SecretSync.Rundeck:AdditionalSyncOptionsFieldsComponent = null;break;default:diff --git a/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/RundeckSyncReviewFields.tsx b/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/RundeckSyncReviewFields.tsxnew file mode 100644index 0000000000..378cef73d3--- /dev/null+++ b/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/RundeckSyncReviewFields.tsx@@ -0,0 +1,24 @@+import { useFormContext } from "react-hook-form";++import { TSecretSyncForm } from "@app/components/secret-syncs/forms/schemas";+import { Detail, DetailLabel, DetailValue } from "@app/components/v3";+import { SecretSync } from "@app/hooks/api/secretSyncs";++export const RundeckSyncReviewFields = () => {+ const { watch } = useFormContext<TSecretSyncForm & { destination: SecretSync.Rundeck }>();+ const project = watch("destinationConfig.project");+ const path = watch("destinationConfig.path");++ return (+ <>+ <Detail>+ <DetailLabel>Project</DetailLabel>+ <DetailValue>{project}</DetailValue>+ </Detail>+ <Detail>+ <DetailLabel>Path</DetailLabel>+ <DetailValue>{path}</DetailValue>+ </Detail>+ </>+ );+};diff --git a/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/SecretSyncReviewFields.tsx b/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/SecretSyncReviewFields.tsxindex 228f0b5c1a..426403e682 100644--- a/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/SecretSyncReviewFields.tsx+++ b/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/SecretSyncReviewFields.tsx@@ -59,6 +59,7 @@ import { OvhSyncReviewFields } from "./OvhSyncReviewFields";import { RailwaySyncReviewFields } from "./RailwaySyncReviewFields";import { RenderSyncOptionsReviewFields, RenderSyncReviewFields } from "./RenderSyncReviewFields";import { SnowflakeSyncReviewFields } from "./SnowflakeSyncReviewFields";+import { RundeckSyncReviewFields } from "./RundeckSyncReviewFields";import { SupabaseSyncReviewFields } from "./SupabaseSyncReviewFields";import { TeamCitySyncReviewFields } from "./TeamCitySyncReviewFields";import { TerraformCloudSyncReviewFields } from "./TerraformCloudSyncReviewFields";@@ -185,6 +186,9 @@ export const SecretSyncReviewFields = () => {case SecretSync.Supabase:DestinationFieldsComponent = <SupabaseSyncReviewFields />;break;+ case SecretSync.Rundeck:+ DestinationFieldsComponent = <RundeckSyncReviewFields />;+ break;case SecretSync.DigitalOceanAppPlatform:DestinationFieldsComponent = <DigitalOceanAppPlatformSyncReviewFields />;break;diff --git a/frontend/src/components/secret-syncs/forms/schemas/rundeck-sync-destination-schema.ts b/frontend/src/components/secret-syncs/forms/schemas/rundeck-sync-destination-schema.tsnew file mode 100644index 0000000000..f11af7256d--- /dev/null+++ b/frontend/src/components/secret-syncs/forms/schemas/rundeck-sync-destination-schema.ts@@ -0,0 +1,14 @@+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 RundeckSyncDestinationSchema = BaseSecretSyncSchema().merge(+ z.object({+ destination: z.literal(SecretSync.Rundeck),+ destinationConfig: z.object({+ project: z.string().trim().min(1, "Project is required"),+ path: z.string().trim().min(1, "Path is required")+ })+ })+);diff --git a/frontend/src/components/secret-syncs/forms/schemas/secret-sync-schema.ts b/frontend/src/components/secret-syncs/forms/schemas/secret-sync-schema.tsindex c2e1a6a228..d82bb8c78b 100644--- a/frontend/src/components/secret-syncs/forms/schemas/secret-sync-schema.ts+++ b/frontend/src/components/secret-syncs/forms/schemas/secret-sync-schema.ts@@ -35,6 +35,7 @@ import { OvhSyncDestinationSchema } from "./ovh-sync-destination-schema";import { RailwaySyncDestinationSchema } from "./railway-sync-destination-schema";import { RenderSyncDestinationSchema } from "./render-sync-destination-schema";import { SnowflakeSyncDestinationSchema } from "./snowflake-sync-destination-schema";+import { RundeckSyncDestinationSchema } from "./rundeck-sync-destination-schema";import { SupabaseSyncDestinationSchema } from "./supabase-sync-destination-schema";import { TeamCitySyncDestinationSchema } from "./teamcity-sync-destination-schema";import { TerraformCloudSyncDestinationSchema } from "./terraform-cloud-destination-schema";@@ -69,6 +70,7 @@ const SecretSyncUnionSchema = z.discriminatedUnion("destination", [CloudflarePagesSyncDestinationSchema,CloudflareWorkersSyncDestinationSchema,SupabaseSyncDestinationSchema,+ RundeckSyncDestinationSchema,ZabbixSyncDestinationSchema,RailwaySyncDestinationSchema,ChecklySyncDestinationSchema,diff --git a/frontend/src/helpers/appConnections.ts b/frontend/src/helpers/appConnections.tsindex 509fa0470b..044af48e76 100644--- a/frontend/src/helpers/appConnections.ts+++ b/frontend/src/helpers/appConnections.ts@@ -76,6 +76,7 @@ import { OpenRouterConnectionMethod } from "@app/hooks/api/appConnections/types/import { OVHConnectionMethod } from "@app/hooks/api/appConnections/types/ovh-connection";import { RailwayConnectionMethod } from "@app/hooks/api/appConnections/types/railway-connection";import { RenderConnectionMethod } from "@app/hooks/api/appConnections/types/render-connection";+import { RundeckConnectionMethod } from "@app/hooks/api/appConnections/types/rundeck-connection";import { SalesforceConnectionMethod } from "@app/hooks/api/appConnections/types/salesforce-connection";import { SmbConnectionMethod } from "@app/hooks/api/appConnections/types/smb-connection";import { SnowflakeConnectionMethod } from "@app/hooks/api/appConnections/types/snowflake-connection";@@ -531,6 +532,12 @@ export const APP_CONNECTION_MAP: Record<image: "TriggerDev.png",category: "INFRASTRUCTURE",description: "Trigger.dev access."+ },+ [AppConnection.Rundeck]: {+ name: "Rundeck",+ image: "Rundeck.svg",+ category: "INFRASTRUCTURE",+ description: "Job and project access for Rundeck."}};@@ -586,6 +593,7 @@ export const getAppConnectionMethodDetails = (method: TAppConnection["method"])case CircleCIConnectionMethod.ApiToken:case TravisCIConnectionMethod.ApiToken:case DopplerConnectionMethod.ApiToken:+ case RundeckConnectionMethod.ApiToken:return { name: "API Token", icon: faKey };case VenafiConnectionMethod.ApiKey:return { name: "API Key", icon: faKey };diff --git a/frontend/src/helpers/secretSyncs.ts b/frontend/src/helpers/secretSyncs.tsindex 4e99658d9a..989365df62 100644--- a/frontend/src/helpers/secretSyncs.ts+++ b/frontend/src/helpers/secretSyncs.ts@@ -180,6 +180,12 @@ export const SECRET_SYNC_MAP: Record<category: "DATA",description: "Project secrets for Supabase."},+ [SecretSync.Rundeck]: {+ name: "Rundeck",+ image: "Rundeck.svg",+ category: "CI/CD",+ description: "Job and project secrets for Rundeck Key Storage."+ },[SecretSync.DigitalOceanAppPlatform]: {name: "Digital Ocean App Platform",image: "Digital Ocean.png",@@ -311,6 +317,7 @@ export const SECRET_SYNC_CONNECTION_MAP: Record<SecretSync, AppConnection> = {[SecretSync.CloudflarePages]: AppConnection.Cloudflare,[SecretSync.CloudflareWorkers]: AppConnection.Cloudflare,[SecretSync.Supabase]: AppConnection.Supabase,+ [SecretSync.Rundeck]: AppConnection.Rundeck,[SecretSync.Zabbix]: AppConnection.Zabbix,[SecretSync.Railway]: AppConnection.Railway,[SecretSync.Checkly]: AppConnection.Checkly,diff --git a/frontend/src/hooks/api/appConnections/enums.ts b/frontend/src/hooks/api/appConnections/enums.tsindex 28a77fade9..010bebe7d6 100644--- a/frontend/src/hooks/api/appConnections/enums.ts+++ b/frontend/src/hooks/api/appConnections/enums.ts@@ -68,5 +68,6 @@ export enum AppConnection {F5BigIp = "f5-big-ip",GoDaddy = "godaddy",Convex = "convex",- TriggerDev = "trigger-dev"+ TriggerDev = "trigger-dev",+ Rundeck = "rundeck"}diff --git a/frontend/src/hooks/api/appConnections/rundeck/index.ts b/frontend/src/hooks/api/appConnections/rundeck/index.tsnew file mode 100644index 0000000000..2c1906d369--- /dev/null+++ b/frontend/src/hooks/api/appConnections/rundeck/index.ts@@ -0,0 +1,2 @@+export * from "./queries";+export * from "./types";diff --git a/frontend/src/hooks/api/appConnections/rundeck/queries.tsx b/frontend/src/hooks/api/appConnections/rundeck/queries.tsxnew file mode 100644index 0000000000..7890604663--- /dev/null+++ b/frontend/src/hooks/api/appConnections/rundeck/queries.tsx@@ -0,0 +1,37 @@+import { useQuery, UseQueryOptions } from "@tanstack/react-query";++import { apiRequest } from "@app/config/request";+import { appConnectionKeys } from "@app/hooks/api/appConnections";++import { TRundeckProject } from "./types";++const rundeckConnectionKeys = {+ all: [...appConnectionKeys.all, "rundeck"] as const,+ listProjects: (connectionId: string) =>+ [...rundeckConnectionKeys.all, "projects", connectionId] as const+};++export const useRundeckConnectionListProjects = (+ connectionId: string,+ options?: Omit<+ UseQueryOptions<+ TRundeckProject[],+ unknown,+ TRundeckProject[],+ ReturnType<typeof rundeckConnectionKeys.listProjects>+ >,+ "queryKey" | "queryFn"+ >+) => {+ return useQuery({+ queryKey: rundeckConnectionKeys.listProjects(connectionId),+ queryFn: async () => {+ const { data } = await apiRequest.get<{ projects: TRundeckProject[] }>(+ `/api/v1/app-connections/rundeck/${connectionId}/projects`+ );++ return data.projects;+ },+ ...options+ });+};diff --git a/frontend/src/hooks/api/appConnections/rundeck/types.ts b/frontend/src/hooks/api/appConnections/rundeck/types.tsnew file mode 100644index 0000000000..7d8d33f10b--- /dev/null+++ b/frontend/src/hooks/api/appConnections/rundeck/types.ts@@ -0,0 +1,3 @@+export type TRundeckProject = {+ name: string;+};diff --git a/frontend/src/hooks/api/appConnections/types/app-options.ts b/frontend/src/hooks/api/appConnections/types/app-options.tsindex 8538c09801..d1975ec046 100644--- a/frontend/src/hooks/api/appConnections/types/app-options.ts+++ b/frontend/src/hooks/api/appConnections/types/app-options.ts@@ -290,6 +290,10 @@ export type TConvexConnectionOption = TAppConnectionOptionBase & {app: AppConnection.Convex;};+export type TRundeckConnectionOption = TAppConnectionOptionBase & {+ app: AppConnection.Rundeck;+};+export type TTriggerDevConnectionOption = TAppConnectionOptionBase & {app: AppConnection.TriggerDev;};@@ -364,7 +368,8 @@ export type TAppConnectionOption =| TDatadogConnectionOption| TF5BigIpConnectionOption| TConvexConnectionOption- | TTriggerDevConnectionOption;+ | TTriggerDevConnectionOption+ | TRundeckConnectionOption;export type TAppConnectionOptionMap = {[AppConnection.AWS]: TAwsConnectionOption;@@ -437,4 +442,5 @@ export type TAppConnectionOptionMap = {[AppConnection.F5BigIp]: TF5BigIpConnectionOption;[AppConnection.Convex]: TConvexConnectionOption;[AppConnection.TriggerDev]: TTriggerDevConnectionOption;+ [AppConnection.Rundeck]: TRundeckConnectionOption;};diff --git a/frontend/src/hooks/api/appConnections/types/index.ts b/frontend/src/hooks/api/appConnections/types/index.tsindex 745297a050..719df69686 100644--- a/frontend/src/hooks/api/appConnections/types/index.ts+++ b/frontend/src/hooks/api/appConnections/types/index.ts@@ -56,6 +56,7 @@ import { TPostgresConnection } from "./postgres-connection";import { TRailwayConnection } from "./railway-connection";import { TRedisConnection } from "./redis-connection";import { TRenderConnection } from "./render-connection";+import { TRundeckConnection } from "./rundeck-connection";import { TSalesforceConnection } from "./salesforce-connection";import { TSmbConnection } from "./smb-connection";import { TSnowflakeConnection } from "./snowflake-connection";@@ -124,6 +125,7 @@ export * from "./postgres-connection";export * from "./railway-connection";export * from "./redis-connection";export * from "./render-connection";+export * from "./rundeck-connection";export * from "./salesforce-connection";export * from "./smb-connection";export * from "./snowflake-connection";@@ -209,7 +211,8 @@ export type TAppConnection =| TDatadogConnection| TF5BigIpConnection| TConvexConnection- | TTriggerDevConnection;+ | TTriggerDevConnection+ | TRundeckConnection;export type TAvailableAppConnection = Pick<TAppConnection, "name" | "id" | "projectId">;diff --git a/frontend/src/hooks/api/appConnections/types/rundeck-connection.ts b/frontend/src/hooks/api/appConnections/types/rundeck-connection.tsnew file mode 100644index 0000000000..2d4223a3cd--- /dev/null+++ b/frontend/src/hooks/api/appConnections/types/rundeck-connection.ts@@ -0,0 +1,14 @@+import { AppConnection } from "@app/hooks/api/appConnections/enums";+import { TRootAppConnection } from "@app/hooks/api/appConnections/types/root-connection";++export enum RundeckConnectionMethod {+ ApiToken = "api-token"+}++export type TRundeckConnection = TRootAppConnection & { app: AppConnection.Rundeck } & {+ method: RundeckConnectionMethod.ApiToken;+ credentials: {+ instanceUrl: string;+ apiToken: string;+ };+};diff --git a/frontend/src/hooks/api/secretSyncs/enums.ts b/frontend/src/hooks/api/secretSyncs/enums.tsindex 75fdbaa4ba..56d8eaa702 100644--- a/frontend/src/hooks/api/secretSyncs/enums.ts+++ b/frontend/src/hooks/api/secretSyncs/enums.ts@@ -41,7 +41,8 @@ export enum SecretSync {Ona = "ona",TravisCI = "travis-ci",Snowflake = "snowflake",- TriggerDev = "trigger-dev"+ TriggerDev = "trigger-dev",+ Rundeck = "rundeck"}export enum SecretSyncStatus {diff --git a/frontend/src/hooks/api/secretSyncs/types/index.ts b/frontend/src/hooks/api/secretSyncs/types/index.tsindex 8c436fb0d7..85d7f2a576 100644--- a/frontend/src/hooks/api/secretSyncs/types/index.ts+++ b/frontend/src/hooks/api/secretSyncs/types/index.ts@@ -36,6 +36,7 @@ import { TOvhSync } from "./ovh-sync";import { TRailwaySync } from "./railway-sync";import { TRenderSync } from "./render-sync";import { TSnowflakeSync } from "./snowflake-sync";+import { TRundeckSync } from "./rundeck-sync";import { TSupabaseSync } from "./supabase";import { TTeamCitySync } from "./teamcity-sync";import { TTerraformCloudSync } from "./terraform-cloud-sync";@@ -83,6 +84,7 @@ export type TSecretSync =| TRailwaySync| TChecklySync| TSupabaseSync+ | TRundeckSync| TDigitalOceanAppPlatformSync| TNetlifySync| TNorthflankSyncdiff --git a/frontend/src/hooks/api/secretSyncs/types/rundeck-sync.ts b/frontend/src/hooks/api/secretSyncs/types/rundeck-sync.tsnew file mode 100644index 0000000000..e4a160e794--- /dev/null+++ b/frontend/src/hooks/api/secretSyncs/types/rundeck-sync.ts@@ -0,0 +1,16 @@+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 type TRundeckSync = TRootSecretSync & {+ destination: SecretSync.Rundeck;+ destinationConfig: {+ project: string;+ path: string;+ };+ connection: {+ app: AppConnection.Rundeck;+ name: string;+ id: string;+ };+};diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AppConnectionForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AppConnectionForm.tsxindex 75b0850194..eac00bebfc 100644--- a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AppConnectionForm.tsx+++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AppConnectionForm.tsx@@ -71,6 +71,7 @@ import { PostgresConnectionForm } from "./PostgresConnectionForm";import { RailwayConnectionForm } from "./RailwayConnectionForm";import { RedisConnectionForm } from "./RedisConnectionForm";import { RenderConnectionForm } from "./RenderConnectionForm";+import { RundeckConnectionForm } from "./RundeckConnectionForm";import { SalesforceConnectionForm } from "./SalesforceConnectionForm";import { SmbConnectionForm } from "./SmbConnectionForm";import { SnowflakeConnectionForm } from "./SnowflakeConnectionForm";@@ -324,6 +325,8 @@ const CreateForm = ({ app, onComplete, projectId }: CreateFormProps) => {return <F5BigIpConnectionForm onSubmit={onSubmit} />;case AppConnection.Convex:return <ConvexConnectionForm onSubmit={onSubmit} />;+ case AppConnection.Rundeck:+ return <RundeckConnectionForm onSubmit={onSubmit} />;default:throw new Error(`Unhandled App ${app}`);}@@ -569,6 +572,8 @@ const UpdateForm = ({ appConnection, onComplete }: UpdateFormProps) => {return <F5BigIpConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;case AppConnection.Convex:return <ConvexConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;+ case AppConnection.Rundeck:+ return <RundeckConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;case AppConnection.Venafi:return <VenafiConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;case AppConnection.VenafiTpp:diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/RundeckConnectionForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/RundeckConnectionForm.tsxnew file mode 100644index 0000000000..c5842e2db8--- /dev/null+++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/RundeckConnectionForm.tsx@@ -0,0 +1,159 @@+import { Controller, FormProvider, useForm } from "react-hook-form";+import { zodResolver } from "@hookform/resolvers/zod";+import { Info } from "lucide-react";+import { z } from "zod";++import {+ Field,+ FieldError,+ FieldLabel,+ Input,+ SecretInput,+ Select,+ SelectContent,+ SelectItem,+ SelectTrigger,+ SelectValue,+ Tooltip,+ TooltipContent,+ TooltipTrigger+} from "@app/components/v3";+import { APP_CONNECTION_MAP, getAppConnectionMethodDetails } from "@app/helpers/appConnections";+import { RundeckConnectionMethod, TRundeckConnection } from "@app/hooks/api/appConnections";+import { AppConnection } from "@app/hooks/api/appConnections/enums";++import { AppConnectionFormFooter } from "./AppConnectionFormFooter";+import {+ genericAppConnectionFieldsSchema,+ GenericAppConnectionsFields+} from "./GenericAppConnectionFields";++type Props = {+ appConnection?: TRundeckConnection;+ onSubmit: (formData: FormData) => void;+};++const rootSchema = genericAppConnectionFieldsSchema.extend({+ app: z.literal(AppConnection.Rundeck)+});++const formSchema = z.discriminatedUnion("method", [+ rootSchema.extend({+ method: z.literal(RundeckConnectionMethod.ApiToken),+ credentials: z.object({+ instanceUrl: z+ .string()+ .trim()+ .url("Invalid Instance URL")+ .min(1, "Instance URL required")+ .max(255),+ apiToken: z.string().trim().min(1, "API Token required")+ })+ })+]);++type FormData = z.infer<typeof formSchema>;++export const RundeckConnectionForm = ({ appConnection, onSubmit }: Props) => {+ const isUpdate = Boolean(appConnection);++ const form = useForm<FormData>({+ resolver: zodResolver(formSchema),+ defaultValues: appConnection ?? {+ app: AppConnection.Rundeck,+ method: RundeckConnectionMethod.ApiToken+ }+ });++ const { handleSubmit, control } = form;++ return (+ <FormProvider {...form}>+ <form onSubmit={handleSubmit(onSubmit)}>+ {!isUpdate && <GenericAppConnectionsFields />}+ <Controller+ name="method"+ control={control}+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <Field className="mb-4">+ <FieldLabel htmlFor="method">+ Method+ <Tooltip>+ <TooltipTrigger asChild>+ <Info />+ </TooltipTrigger>+ <TooltipContent className="max-w-sm">+ The method you would like to use to connect with{" "}+ {APP_CONNECTION_MAP[AppConnection.Rundeck].name}. This field cannot be changed+ after creation.+ </TooltipContent>+ </Tooltip>+ </FieldLabel>+ <Select disabled={isUpdate} value={value} onValueChange={(val) => onChange(val)}>+ <SelectTrigger className="w-full" isError={Boolean(error)} id="method">+ <SelectValue placeholder="Select a method..." />+ </SelectTrigger>+ <SelectContent position="popper">+ {Object.values(RundeckConnectionMethod).map((method) => {+ return (+ <SelectItem value={method} key={method}>+ {getAppConnectionMethodDetails(method).name}{" "}+ </SelectItem>+ );+ })}+ </SelectContent>+ </Select>+ <FieldError errors={[error]} />+ </Field>+ )}+ />+ <Controller+ name="credentials.instanceUrl"+ control={control}+ shouldUnregister+ render={({ field, fieldState: { error } }) => (+ <Field className="mb-4">+ <FieldLabel htmlFor="instance-url">+ Rundeck Instance URL+ <Tooltip>+ <TooltipTrigger asChild>+ <Info />+ </TooltipTrigger>+ <TooltipContent className="max-w-sm">+ The URL of the Rundeck instance to authenticate with.+ </TooltipContent>+ </Tooltip>+ </FieldLabel>+ <Input+ id="instance-url"+ {...field}+ placeholder="https://rundeck.example.com"+ isError={Boolean(error?.message)}+ />+ <FieldError errors={[error]} />+ </Field>+ )}+ />+ <Controller+ name="credentials.apiToken"+ control={control}+ shouldUnregister+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <Field className="mb-4">+ <FieldLabel htmlFor="api-token">Rundeck API Token</FieldLabel>+ <SecretInput+ id="api-token"+ value={value}+ onChange={(e) => onChange(e.target.value)}+ />+ <FieldError errors={[error]} />+ </Field>+ )}+ />+ <AppConnectionFormFooter+ submitLabel={isUpdate ? "Update Credentials" : "Connect to Rundeck"}+ />+ </form>+ </FormProvider>+ );+};