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
finish implementation and update docs
Matheus Nogueira64c5c3b0a05b
diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.tsindex 6b93dbfdde..2d447df466 100644--- a/backend/src/lib/api-docs/constants.ts+++ b/backend/src/lib/api-docs/constants.ts@@ -3148,6 +3148,10 @@ export const SecretSyncs = {CLOUDFLARE_WORKERS: {syncNonSecretBindings:"Whether Infisical should also sync plaintext and JSON variable bindings in addition to secret bindings."+ },+ SPACELIFT: {+ writeOnly:+ "Whether secrets should be marked as secret in Spacelift. Secret values are only available to Runs and Tasks and are not accessible in the web GUI or through the API."}},DESTINATION_CONFIG: {diff --git a/backend/src/services/secret-sync/spacelift/spacelift-sync-constants.ts b/backend/src/services/secret-sync/spacelift/spacelift-sync-constants.tsindex 3d84524c83..99479afc67 100644--- a/backend/src/services/secret-sync/spacelift/spacelift-sync-constants.ts+++ b/backend/src/services/secret-sync/spacelift/spacelift-sync-constants.ts@@ -6,6 +6,6 @@ export const SPACELIFT_SYNC_LIST_OPTION: TSecretSyncListItem = {name: "Spacelift",destination: SecretSync.Spacelift,connection: AppConnection.Spacelift,- canImportSecrets: false,+ canImportSecrets: true,canRemoveSecretsOnDeletion: true};diff --git a/backend/src/services/secret-sync/spacelift/spacelift-sync-fns.ts b/backend/src/services/secret-sync/spacelift/spacelift-sync-fns.tsindex 05c2e7c241..304b62915e 100644--- a/backend/src/services/secret-sync/spacelift/spacelift-sync-fns.ts+++ b/backend/src/services/secret-sync/spacelift/spacelift-sync-fns.ts@@ -1,18 +1,178 @@+/* eslint-disable no-await-in-loop */+import { removeTrailingSlash } from "@app/lib/fn";+import { safeRequest } from "@app/lib/validator";+import { SecretSyncError } from "@app/services/secret-sync/secret-sync-errors";+import { matchesSchema } from "@app/services/secret-sync/secret-sync-fns";import { TSecretMap } from "@app/services/secret-sync/secret-sync-types";-import { SECRET_SYNC_NAME_MAP } from "../secret-sync-maps";import { TSpaceliftSyncWithCredentials } from "./spacelift-sync-types";+type TSpaceliftConfigElement = {+ id: string;+ value: string;+ writeOnly: boolean;+};++const authenticateSpacelift = async (instanceUrl: string, apiKeyId: string, apiKeySecret: string): Promise<string> => {+ const { data } = await safeRequest.post<{+ data?: { apiKeyUser?: { jwt: string } };+ errors?: { message: string }[];+ }>(`${instanceUrl}/graphql`, {+ query: `mutation GetSpaceliftToken($id: ID!, $secret: String!) { apiKeyUser(id: $id, secret: $secret) { jwt } }`,+ variables: { id: apiKeyId, secret: apiKeySecret }+ });++ if (data.errors?.length || !data.data?.apiKeyUser?.jwt) {+ throw new Error(`Failed to authenticate with Spacelift: ${data.errors?.[0]?.message ?? "no JWT returned"}`);+ }++ return data.data.apiKeyUser.jwt;+};++const graphqlRequest = async <T>(+ instanceUrl: string,+ jwt: string,+ query: string,+ variables?: Record<string, unknown>+) => {+ const { data } = await safeRequest.post<{ data?: T; errors?: { message: string }[] }>(+ `${instanceUrl}/graphql`,+ { query, variables },+ { headers: { Authorization: `Bearer ${jwt}` } }+ );++ if (data.errors?.length) {+ throw new Error(data.errors[0].message);+ }++ return data.data;+};++const getContextConfigElements = async (+ instanceUrl: string,+ jwt: string,+ contextId: string+): Promise<TSpaceliftConfigElement[]> => {+ const data = await graphqlRequest<{ context?: { config: TSpaceliftConfigElement[] } }>(+ instanceUrl,+ jwt,+ `query GetContextConfig($id: ID!) { context(id: $id) { config { id value writeOnly } } }`,+ { id: contextId }+ );++ return data?.context?.config ?? [];+};++const addContextConfigElement = async (+ instanceUrl: string,+ jwt: string,+ contextId: string,+ key: string,+ value: string,+ writeOnly: boolean+) => {+ await graphqlRequest(+ instanceUrl,+ jwt,+ `mutation AddContextConfig($context: ID!, $config: ConfigInput!) {+ contextConfigAdd(context: $context, config: $config) { id }+ }`,+ {+ context: contextId,+ config: { id: key, value, type: "ENVIRONMENT_VARIABLE", writeOnly }+ }+ );+};++const deleteContextConfigElement = async (instanceUrl: string, jwt: string, contextId: string, key: string) => {+ await graphqlRequest(+ instanceUrl,+ jwt,+ `mutation DeleteContextConfig($context: ID!, $id: ID!) {+ contextConfigDelete(context: $context, id: $id) { id }+ }`,+ { context: contextId, id: key }+ );+};+export const SpaceliftSyncFns = {- syncSecrets: async (_secretSync: TSpaceliftSyncWithCredentials, _secretMap: TSecretMap): Promise<void> => {- // TODO: Implement syncing secrets to Spacelift context+ syncSecrets: async (secretSync: TSpaceliftSyncWithCredentials, secretMap: TSecretMap): Promise<void> => {+ const instanceUrl = removeTrailingSlash(secretSync.connection.credentials.apiUrl);+ const { apiKeyId, apiKeySecret } = secretSync.connection.credentials;+ const { contextId } = secretSync.destinationConfig;+ const writeOnly = secretSync.syncOptions?.writeOnly ?? false;++ const jwt = await authenticateSpacelift(instanceUrl, apiKeyId, apiKeySecret);+ const existingElements = await getContextConfigElements(instanceUrl, jwt, contextId);+ const existingMap = new Map(existingElements.map((e) => [e.id, e]));++ for (const key of Object.keys(secretMap)) {+ try {+ const existing = existingMap.get(key);++ if (existing) {+ await deleteContextConfigElement(instanceUrl, jwt, contextId, key);+ }++ await addContextConfigElement(instanceUrl, jwt, contextId, key, secretMap[key].value, writeOnly);+ } catch (error) {+ throw new SecretSyncError({ error, secretKey: key });+ }+ }++ if (secretSync.syncOptions.disableSecretDeletion) return;++ for (const element of existingElements) {+ if (!matchesSchema(element.id, secretSync.environment?.slug || "", secretSync.syncOptions.keySchema)) {+ // eslint-disable-next-line no-continue+ continue;+ }++ if (!(element.id in secretMap)) {+ try {+ await deleteContextConfigElement(instanceUrl, jwt, contextId, element.id);+ } catch (error) {+ throw new SecretSyncError({ error, secretKey: element.id });+ }+ }+ }},getSecrets: async (secretSync: TSpaceliftSyncWithCredentials): Promise<TSecretMap> => {- throw new Error(`${SECRET_SYNC_NAME_MAP[secretSync.destination]} does not support importing secrets.`);+ const instanceUrl = removeTrailingSlash(secretSync.connection.credentials.apiUrl);+ const { apiKeyId, apiKeySecret } = secretSync.connection.credentials;+ const { contextId } = secretSync.destinationConfig;++ const jwt = await authenticateSpacelift(instanceUrl, apiKeyId, apiKeySecret);+ const existingElements = await getContextConfigElements(instanceUrl, jwt, contextId);++ const secretMap: TSecretMap = {};++ for (const element of existingElements) {+ if (!element.writeOnly) {+ secretMap[element.id] = { value: element.value };+ }+ }++ return secretMap;},- removeSecrets: async (_secretSync: TSpaceliftSyncWithCredentials, _secretMap: TSecretMap): Promise<void> => {- // TODO: Implement removing secrets from Spacelift context+ removeSecrets: async (secretSync: TSpaceliftSyncWithCredentials, secretMap: TSecretMap): Promise<void> => {+ const instanceUrl = removeTrailingSlash(secretSync.connection.credentials.apiUrl);+ const { apiKeyId, apiKeySecret } = secretSync.connection.credentials;+ const { contextId } = secretSync.destinationConfig;++ const jwt = await authenticateSpacelift(instanceUrl, apiKeyId, apiKeySecret);+ const existingElements = await getContextConfigElements(instanceUrl, jwt, contextId);++ for (const element of existingElements) {+ if (Object.prototype.hasOwnProperty.call(secretMap, element.id)) {+ try {+ await deleteContextConfigElement(instanceUrl, jwt, contextId, element.id);+ } catch (error) {+ throw new SecretSyncError({ error, secretKey: element.id });+ }+ }+ }}};diff --git a/backend/src/services/secret-sync/spacelift/spacelift-sync-schemas.ts b/backend/src/services/secret-sync/spacelift/spacelift-sync-schemas.tsindex b094dfc9fa..bacb933bac 100644--- a/backend/src/services/secret-sync/spacelift/spacelift-sync-schemas.ts+++ b/backend/src/services/secret-sync/spacelift/spacelift-sync-schemas.ts@@ -24,9 +24,21 @@ const SpaceliftSyncDestinationConfigSchema = z.object({.describe(SecretSyncs.DESTINATION_CONFIG.SPACELIFT.contextName)});-const SpaceliftSyncOptionsConfig: TSyncOptionsConfig = { canImportSecrets: false };+const SpaceliftSyncOptionsConfig: TSyncOptionsConfig = { canImportSecrets: true };-export const SpaceliftSyncSchema = BaseSecretSyncSchema(SecretSync.Spacelift, SpaceliftSyncOptionsConfig)+const SpaceliftSyncOptionsSchema = z.object({+ writeOnly: z+ .boolean()+ .optional()+ .default(false)+ .describe(SecretSyncs.ADDITIONAL_SYNC_OPTIONS.SPACELIFT.writeOnly)+});++export const SpaceliftSyncSchema = BaseSecretSyncSchema(+ SecretSync.Spacelift,+ SpaceliftSyncOptionsConfig,+ SpaceliftSyncOptionsSchema+).extend({destination: z.literal(SecretSync.Spacelift),destinationConfig: SpaceliftSyncDestinationConfigSchema@@ -35,14 +47,16 @@ export const SpaceliftSyncSchema = BaseSecretSyncSchema(SecretSync.Spacelift, Spexport const CreateSpaceliftSyncSchema = GenericCreateSecretSyncFieldsSchema(SecretSync.Spacelift,- SpaceliftSyncOptionsConfig+ SpaceliftSyncOptionsConfig,+ SpaceliftSyncOptionsSchema).extend({destinationConfig: SpaceliftSyncDestinationConfigSchema});export const UpdateSpaceliftSyncSchema = GenericUpdateSecretSyncFieldsSchema(SecretSync.Spacelift,- SpaceliftSyncOptionsConfig+ SpaceliftSyncOptionsConfig,+ SpaceliftSyncOptionsSchema).extend({destinationConfig: SpaceliftSyncDestinationConfigSchema.optional()});@@ -52,7 +66,7 @@ export const SpaceliftSyncListItemSchema = zname: z.literal("Spacelift"),connection: z.literal(AppConnection.Spacelift),destination: z.literal(SecretSync.Spacelift),- canImportSecrets: z.literal(false),+ canImportSecrets: z.literal(true),canRemoveSecretsOnDeletion: z.literal(true)}).describe(JSON.stringify({ title: SECRET_SYNC_NAME_MAP[SecretSync.Spacelift] }));diff --git a/docs/images/app-connections/spacelift/spacelift-select-roles.png b/docs/images/app-connections/spacelift/spacelift-select-roles.pngindex 86a7c02f18..8c368ccaff 100644Binary files a/docs/images/app-connections/spacelift/spacelift-select-roles.png and b/docs/images/app-connections/spacelift/spacelift-select-roles.png differdiff --git a/docs/images/secret-syncs/spacelift/spacelift-sync-add.png b/docs/images/secret-syncs/spacelift/spacelift-sync-add.pngnew file mode 100644index 0000000000..43ba4a192bBinary files /dev/null and b/docs/images/secret-syncs/spacelift/spacelift-sync-add.png differdiff --git a/docs/images/secret-syncs/spacelift/spacelift-sync-created.png b/docs/images/secret-syncs/spacelift/spacelift-sync-created.pngnew file mode 100644index 0000000000..f4b5b1dc91Binary files /dev/null and b/docs/images/secret-syncs/spacelift/spacelift-sync-created.png differdiff --git a/docs/images/secret-syncs/spacelift/spacelift-sync-destination.png b/docs/images/secret-syncs/spacelift/spacelift-sync-destination.pngnew file mode 100644index 0000000000..8d8676cd9bBinary files /dev/null and b/docs/images/secret-syncs/spacelift/spacelift-sync-destination.png differdiff --git a/docs/images/secret-syncs/spacelift/spacelift-sync-details.png b/docs/images/secret-syncs/spacelift/spacelift-sync-details.pngnew file mode 100644index 0000000000..4d006f8542Binary files /dev/null and b/docs/images/secret-syncs/spacelift/spacelift-sync-details.png differdiff --git a/docs/images/secret-syncs/spacelift/spacelift-sync-options.png b/docs/images/secret-syncs/spacelift/spacelift-sync-options.pngnew file mode 100644index 0000000000..c7da3401a0Binary files /dev/null and b/docs/images/secret-syncs/spacelift/spacelift-sync-options.png differdiff --git a/docs/images/secret-syncs/spacelift/spacelift-sync-review.png b/docs/images/secret-syncs/spacelift/spacelift-sync-review.pngnew file mode 100644index 0000000000..b30d999a0dBinary files /dev/null and b/docs/images/secret-syncs/spacelift/spacelift-sync-review.png differdiff --git a/docs/images/secret-syncs/spacelift/spacelift-sync-select.png b/docs/images/secret-syncs/spacelift/spacelift-sync-select.pngnew file mode 100644index 0000000000..abc988532bBinary files /dev/null and b/docs/images/secret-syncs/spacelift/spacelift-sync-select.png differdiff --git a/docs/images/secret-syncs/spacelift/spacelift-sync-source.png b/docs/images/secret-syncs/spacelift/spacelift-sync-source.pngnew file mode 100644index 0000000000..d74405b994Binary files /dev/null and b/docs/images/secret-syncs/spacelift/spacelift-sync-source.png differdiff --git a/docs/integrations/secret-syncs/spacelift.mdx b/docs/integrations/secret-syncs/spacelift.mdxnew file mode 100644index 0000000000..608bb456e5--- /dev/null+++ b/docs/integrations/secret-syncs/spacelift.mdx@@ -0,0 +1,111 @@+---+title: "Spacelift Sync"+description: "Learn how to configure a Spacelift Sync for Infisical."+---++**Prerequisites:**++- Set up and add secrets to [Infisical Cloud](https://app.infisical.com).+- Create a [Spacelift Connection](/integrations/app-connections/spacelift).++<Tabs>+ <Tab title="Infisical UI">+ <Steps>+ <Step title="Add Sync">+ Navigate to **Project** > **Integrations**, select the **Secret Syncs** tab, and click **Add Sync**.++ + </Step>+ <Step title="Select Spacelift">+ Select **Spacelift** from the list of available secret syncs.++ + </Step>+ <Step title="Configure source">+ Configure the **Source** from where secrets should be retrieved, then click **Next**.++ - **Environment**: The project environment from which to retrieve secrets.+ - **Secret Path**: The folder path from which to retrieve secrets.++ <Tip>+ If you need to sync secrets from multiple folder locations, use [secret imports](/documentation/platform/secret-reference#secret-imports).+ </Tip>++ + </Step>+ <Step title="Configure destination">+ Configure the **Destination** where secrets should be deployed, then click **Next**.++ - **Spacelift Connection**: Select the app connection to use for authentication.+ - **Context**: Select the Spacelift context that will receive the synced secrets.++ + </Step>+ <Step title="Configure sync options">+ Configure the **Sync Options**, then click **Next**.++ - **Initial Sync Behavior**: Determines how Infisical resolves the first sync.+ - **Overwrite Destination Secrets**: Removes any secrets at the destination not present in Infisical.+ - **Import Secrets (Prioritize Infisical)**: Imports secrets from Spacelift before syncing, prioritizing values from Infisical over Spacelift when keys conflict.+ - **Import Secrets (Prioritize Spacelift)**: Imports secrets from Spacelift before syncing, prioritizing values from Spacelift over Infisical when keys conflict.+ - **Key Schema**: A template that transforms secret names when syncing. Use `{{secretKey}}` for the original secret name and `{{environment}}` for the environment.+ - **Auto-Sync Enabled**: Automatically sync secrets from the source location when changes occur. Disable this to sync manually only.+ - **Disable Secret Deletion**: Prevents Infisical from removing secrets at the destination. Enable this when you intend to manage destination secrets outside Infisical.+ - **Mark as Secret**: When enabled, synced variables are marked as secrets in Spacelift. Secret values are only available to Runs and Tasks and are not accessible in the web GUI or through the API.++ <Warning>+ Variables marked as secret in Spacelift cannot be read back by Infisical. When using an import sync behavior, only plaintext variable values will be imported. If **Disable Secret Deletion** is not enabled, any existing secret variables in the Spacelift context that are not present in Infisical will be deleted during sync.+ </Warning>++ + </Step>+ <Step title="Configure details">+ Configure the details of your Spacelift Sync, then click **Next**.++ - **Name**: A slug-friendly name for the sync.+ - **Description**: An optional description for the sync.++ + </Step>+ <Step title="Review configuration">+ Review the Spacelift Sync configuration, then click **Create Sync**.++ + </Step>+ <Step title="Sync created">+ If enabled, the Spacelift Sync begins syncing your secrets to the selected context.++ + </Step>+ </Steps>+ </Tab>+ <Tab title="API">+ To create a **Spacelift Sync**, make an API request to the [Create Spacelift Sync](/api-reference/endpoints/secret-syncs/spacelift/create) API endpoint.++ ### Sample request++ ```bash Request+ curl --request POST \+ --url https://app.infisical.com/api/v1/secret-syncs/spacelift \+ --header 'Content-Type: application/json' \+ --data '{+ "name": "my-spacelift-sync",+ "projectId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",+ "description": "an example sync",+ "connectionId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",+ "environment": "dev",+ "secretPath": "/my-secrets",+ "isEnabled": true,+ "syncOptions": {+ "initialSyncBehavior": "overwrite-destination",+ "disableSecretDeletion": true,+ "writeOnly": false+ },+ "destinationConfig": {+ "contextId": "context-id",+ "contextName": "my-context"+ }+ }'+ ```+ </Tab>+</Tabs>diff --git a/docs/snippets/SecretSyncsBrowser.jsx b/docs/snippets/SecretSyncsBrowser.jsxindex f600e107c7..616f412000 100644--- a/docs/snippets/SecretSyncsBrowser.jsx+++ b/docs/snippets/SecretSyncsBrowser.jsx@@ -30,6 +30,7 @@ export const SecretSyncsBrowser = () => {{"name": "TeamCity", "slug": "teamcity", "path": "/integrations/secret-syncs/teamcity", "description": "Learn how to sync secrets from Infisical to TeamCity.", "category": "CI/CD"},{"name": "Bitbucket", "slug": "bitbucket", "path": "/integrations/secret-syncs/bitbucket", "description": "Learn how to sync secrets from Infisical to Bitbucket.", "category": "CI/CD"},{"name": "Terraform Cloud", "slug": "terraform-cloud", "path": "/integrations/secret-syncs/terraform-cloud", "description": "Learn how to sync secrets from Infisical to Terraform Cloud.", "category": "DevOps Tools"},+ {"name": "Spacelift", "slug": "spacelift", "path": "/integrations/secret-syncs/spacelift", "description": "Learn how to sync secrets from Infisical to Spacelift.", "category": "DevOps Tools"},{"name": "Cloudflare Pages", "slug": "cloudflare-pages", "path": "/integrations/secret-syncs/cloudflare-pages", "description": "Learn how to sync secrets from Infisical to Cloudflare Pages.", "category": "Hosting"},{"name": "Cloudflare Workers", "slug": "cloudflare-workers", "path": "/integrations/secret-syncs/cloudflare-workers", "description": "Learn how to sync secrets from Infisical to Cloudflare Workers.", "category": "Cloud Providers"},{"name": "Databricks", "slug": "databricks", "path": "/integrations/secret-syncs/databricks", "description": "Learn how to sync secrets from Infisical to Databricks.", "category": "Data Analytics"},@@ -160,4 +161,4 @@ export const SecretSyncsBrowser = () => {)}</div>);-};\ No newline at end of file+};diff --git a/frontend/src/components/secret-syncs/forms/SecretSyncInitialSyncBehaviorFields.tsx b/frontend/src/components/secret-syncs/forms/SecretSyncInitialSyncBehaviorFields.tsxindex 7a27693554..7a8ee88cf6 100644--- a/frontend/src/components/secret-syncs/forms/SecretSyncInitialSyncBehaviorFields.tsx+++ b/frontend/src/components/secret-syncs/forms/SecretSyncInitialSyncBehaviorFields.tsx@@ -390,6 +390,17 @@ export const SecretSyncInitialSyncBehaviorFields = () => {</AlertDescription></Alert>)}+ {destination === SecretSync.Spacelift &&+ currentInitialBehavior !== SecretSyncInitialSyncBehavior.OverwriteDestination && (+ <Alert className="mb-3" variant="warning">+ <TriangleAlert />+ <AlertTitle>Secret values are not imported</AlertTitle>+ <AlertDescription>+ Variables marked as secret in Spacelift cannot be read back, so only plaintext+ variable values will be imported.+ </AlertDescription>+ </Alert>+ )}{destination === SecretSync.Vercel &&!vercelSensitive &¤tInitialBehavior !== SecretSyncInitialSyncBehavior.OverwriteDestination && (diff --git a/frontend/src/components/secret-syncs/forms/SecretSyncOptionsFields/SecretSyncOptionsFields.tsx b/frontend/src/components/secret-syncs/forms/SecretSyncOptionsFields/SecretSyncOptionsFields.tsxindex 7f0d4f0076..5145b8296f 100644--- a/frontend/src/components/secret-syncs/forms/SecretSyncOptionsFields/SecretSyncOptionsFields.tsx+++ b/frontend/src/components/secret-syncs/forms/SecretSyncOptionsFields/SecretSyncOptionsFields.tsx@@ -45,6 +45,7 @@ import { FlyioSyncOptionsFields } from "./FlyioSyncOptionsFields";import { QoverySyncOptionsFields } from "./QoverySyncOptionsFields";import { RenderSyncOptionsFields } from "./RenderSyncOptionsFields";import { SecretSyncKeySchemaField } from "./SecretSyncKeySchemaField";+import { SpaceliftSyncOptionsFields } from "./SpaceliftSyncOptionsFields";import { TriggerDevSyncOptionsFields } from "./TriggerDevSyncOptionsFields";type Props = {@@ -152,9 +153,11 @@ export const SecretSyncOptionsFields = ({ hideInitialSync, children }: Props) =>case SecretSync.Rundeck:case SecretSync.HasuraCloud:case SecretSync.Cloud66:- case SecretSync.Spacelift:AdditionalSyncOptionsFieldsComponent = null;break;+ case SecretSync.Spacelift:+ AdditionalSyncOptionsFieldsComponent = <SpaceliftSyncOptionsFields />;+ break;default:throw new Error(`Unhandled Additional Sync Options Fields: ${destination}`);}diff --git a/frontend/src/components/secret-syncs/forms/SecretSyncOptionsFields/SpaceliftSyncOptionsFields.tsx b/frontend/src/components/secret-syncs/forms/SecretSyncOptionsFields/SpaceliftSyncOptionsFields.tsxnew file mode 100644index 0000000000..6b69152e02--- /dev/null+++ b/frontend/src/components/secret-syncs/forms/SecretSyncOptionsFields/SpaceliftSyncOptionsFields.tsx@@ -0,0 +1,66 @@+import { Controller, useFormContext } from "react-hook-form";+import { TriangleAlert } from "lucide-react";++import {+ Alert,+ AlertDescription,+ AlertTitle,+ Field,+ FieldContent,+ FieldDescription,+ FieldError,+ Label,+ Switch+} from "@app/components/v3";+import { SecretSync } from "@app/hooks/api/secretSyncs";++import { TSecretSyncForm } from "../schemas";++export const SpaceliftSyncOptionsFields = () => {+ const { control, watch } = useFormContext<+ TSecretSyncForm & { destination: SecretSync.Spacelift }+ >();++ const writeOnly = watch("syncOptions.writeOnly");+ const disableSecretDeletion = watch("syncOptions.disableSecretDeletion");++ return (+ <>+ <Controller+ name="syncOptions.writeOnly"+ control={control}+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <Field className="mb-4">+ <Field orientation="horizontal">+ <FieldContent>+ <Label htmlFor="spacelift-write-only">Mark as secret</Label>+ <FieldDescription>+ Secret values are only made available to Runs and Tasks and are not accessible in+ the web GUI or through the API.+ </FieldDescription>+ </FieldContent>+ <Switch+ id="spacelift-write-only"+ variant="project"+ checked={value}+ onCheckedChange={onChange}+ />+ </Field>+ <FieldError errors={[error]} />+ </Field>+ )}+ />+ {writeOnly && !disableSecretDeletion && (+ <Alert variant="warning">+ <TriangleAlert />+ <AlertTitle>Secret values cannot be read back</AlertTitle>+ <AlertDescription>+ Existing secret values in the Spacelift context cannot be read by Infisical. Any secret+ values not present in Infisical will be deleted during sync. Enable secret deletion+ protection to prevent this.+ </AlertDescription>+ </Alert>+ )}+ </>+ );+};diff --git a/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/SecretSyncReviewFields.tsx b/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/SecretSyncReviewFields.tsxindex 6e31cf02b2..b4308b2dff 100644--- a/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/SecretSyncReviewFields.tsx+++ b/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/SecretSyncReviewFields.tsx@@ -36,7 +36,10 @@ import { ChecklySyncReviewFields } from "./ChecklySyncReviewFields";import { ChefSyncReviewFields } from "./ChefSyncReviewFields";import { CircleCISyncReviewFields } from "./CircleCISyncReviewFields";import { Cloud66SyncReviewFields } from "./Cloud66SyncReviewFields";-import { SpaceliftSyncReviewFields } from "./SpaceliftSyncReviewFields";+import {+ SpaceliftSyncOptionsReviewFields,+ SpaceliftSyncReviewFields+} from "./SpaceliftSyncReviewFields";import { CloudflarePagesSyncReviewFields } from "./CloudflarePagesReviewFields";import {CloudflareWorkersSyncOptionsReviewFields,@@ -258,6 +261,7 @@ export const SecretSyncReviewFields = () => {break;case SecretSync.Spacelift:DestinationFieldsComponent = <SpaceliftSyncReviewFields />;+ AdditionalSyncOptionsFieldsComponent = <SpaceliftSyncOptionsReviewFields />;break;default:throw new Error(`Unhandled Destination Review Fields: ${destination}`);diff --git a/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/SpaceliftSyncReviewFields.tsx b/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/SpaceliftSyncReviewFields.tsxindex fb22d5b029..95d931fb66 100644--- a/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/SpaceliftSyncReviewFields.tsx+++ b/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/SpaceliftSyncReviewFields.tsx@@ -1,9 +1,26 @@import { useFormContext } from "react-hook-form";import { TSecretSyncForm } from "@app/components/secret-syncs/forms/schemas";-import { Detail, DetailLabel, DetailValue } from "@app/components/v3";+import { Badge, Detail, DetailLabel, DetailValue } from "@app/components/v3";import { SecretSync } from "@app/hooks/api/secretSyncs";+export const SpaceliftSyncOptionsReviewFields = () => {+ const { watch } = useFormContext<TSecretSyncForm & { destination: SecretSync.Spacelift }>();++ const [{ writeOnly }] = watch(["syncOptions"]);++ return (+ <Detail>+ <DetailLabel>Mark as Secret</DetailLabel>+ <DetailValue>+ <Badge variant={writeOnly ? "success" : "neutral"}>+ {writeOnly ? "Enabled" : "Disabled"}+ </Badge>+ </DetailValue>+ </Detail>+ );+};+export const SpaceliftSyncReviewFields = () => {const { watch } = useFormContext<TSecretSyncForm & { destination: SecretSync.Spacelift }>();const contextName = watch("destinationConfig.contextName");diff --git a/frontend/src/components/secret-syncs/forms/schemas/spacelift-sync-destination-schema.ts b/frontend/src/components/secret-syncs/forms/schemas/spacelift-sync-destination-schema.tsindex 1120a77267..136ef57bae 100644--- a/frontend/src/components/secret-syncs/forms/schemas/spacelift-sync-destination-schema.ts+++ b/frontend/src/components/secret-syncs/forms/schemas/spacelift-sync-destination-schema.ts@@ -3,7 +3,11 @@ 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 SpaceliftSyncDestinationSchema = BaseSecretSyncSchema().merge(+export const SpaceliftSyncDestinationSchema = BaseSecretSyncSchema(+ z.object({+ writeOnly: z.boolean().optional().default(false)+ })+).merge(z.object({destination: z.literal(SecretSync.Spacelift),destinationConfig: z.object({diff --git a/frontend/src/hooks/api/secretSyncs/types/spacelift-sync.ts b/frontend/src/hooks/api/secretSyncs/types/spacelift-sync.tsindex 5037ff96a6..42a8eceab5 100644--- a/frontend/src/hooks/api/secretSyncs/types/spacelift-sync.ts+++ b/frontend/src/hooks/api/secretSyncs/types/spacelift-sync.ts@@ -1,6 +1,6 @@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";+import { RootSyncOptions, TRootSecretSync } from "@app/hooks/api/secretSyncs/types/root-sync";export type TSpaceliftSync = TRootSecretSync & {destination: SecretSync.Spacelift;@@ -8,6 +8,9 @@ export type TSpaceliftSync = TRootSecretSync & {contextId: string;contextName: string;};+ syncOptions: RootSyncOptions & {+ writeOnly?: boolean;+ };connection: {app: AppConnection.Spacelift;name: string;diff --git a/frontend/src/pages/secret-manager/SecretSyncDetailsByIDPage/components/SecretSyncOptionsSection/SecretSyncOptionsSection.tsx b/frontend/src/pages/secret-manager/SecretSyncDetailsByIDPage/components/SecretSyncOptionsSection/SecretSyncOptionsSection.tsxindex 521da67e4e..02d67c7299 100644--- a/frontend/src/pages/secret-manager/SecretSyncDetailsByIDPage/components/SecretSyncOptionsSection/SecretSyncOptionsSection.tsx+++ b/frontend/src/pages/secret-manager/SecretSyncDetailsByIDPage/components/SecretSyncOptionsSection/SecretSyncOptionsSection.tsx@@ -20,6 +20,7 @@ import { AwsSecretsManagerSyncOptionsSection } from "./AwsSecretsManagerSyncOptiimport { FlyioSyncOptionsSection } from "./FlyioSyncOptionsSection";import { QoverySyncOptionsSection } from "./QoverySyncOptionsSection";import { RenderSyncOptionsSection } from "./RenderSyncOptionsSection";+import { SpaceliftSyncOptionsSection } from "./SpaceliftSyncOptionsSection";import { TriggerDevSyncOptionsSection } from "./TriggerDevSyncOptionsSection";type Props = {@@ -98,9 +99,11 @@ export const SecretSyncOptionsSection = ({ secretSync }: Props) => {case SecretSync.Rundeck:case SecretSync.HasuraCloud:case SecretSync.Cloud66:- case SecretSync.Spacelift:AdditionalSyncOptionsComponent = null;break;+ case SecretSync.Spacelift:+ AdditionalSyncOptionsComponent = <SpaceliftSyncOptionsSection secretSync={secretSync} />;+ break;default:throw new Error(`Unhandled Destination Review Fields: ${destination}`);}diff --git a/frontend/src/pages/secret-manager/SecretSyncDetailsByIDPage/components/SecretSyncOptionsSection/SpaceliftSyncOptionsSection.tsx b/frontend/src/pages/secret-manager/SecretSyncDetailsByIDPage/components/SecretSyncOptionsSection/SpaceliftSyncOptionsSection.tsxnew file mode 100644index 0000000000..2c27209473--- /dev/null+++ b/frontend/src/pages/secret-manager/SecretSyncDetailsByIDPage/components/SecretSyncOptionsSection/SpaceliftSyncOptionsSection.tsx@@ -0,0 +1,23 @@+import { Badge, Detail, DetailLabel, DetailValue } from "@app/components/v3";+import { TSpaceliftSync } from "@app/hooks/api/secretSyncs/types/spacelift-sync";++type Props = {+ secretSync: TSpaceliftSync;+};++export const SpaceliftSyncOptionsSection = ({ secretSync }: Props) => {+ const {+ syncOptions: { writeOnly }+ } = secretSync;++ return (+ <Detail>+ <DetailLabel>Mark as Secret</DetailLabel>+ <DetailValue>+ <Badge variant={writeOnly ? "success" : "neutral"}>+ {writeOnly ? "Enabled" : "Disabled"}+ </Badge>+ </DetailValue>+ </Detail>+ );+};