mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 18:28:12 +00:00
feat: cloudflare pages secret sync
This commit is contained in:
@@ -45,3 +45,4 @@ cli/detect/config/gitleaks.toml:gcp-api-key:582
|
|||||||
.github/workflows/helm-release-infisical-core.yml:generic-api-key:48
|
.github/workflows/helm-release-infisical-core.yml:generic-api-key:48
|
||||||
.github/workflows/helm-release-infisical-core.yml:generic-api-key:47
|
.github/workflows/helm-release-infisical-core.yml:generic-api-key:47
|
||||||
backend/src/services/smtp/smtp-service.ts:generic-api-key:79
|
backend/src/services/smtp/smtp-service.ts:generic-api-key:79
|
||||||
|
frontend/src/components/secret-syncs/forms/SecretSyncDestinationFields/CloudflarePagesSyncFields.tsx:cloudflare-api-key:7
|
||||||
|
|||||||
@@ -2397,6 +2397,10 @@ export const SecretSyncs = {
|
|||||||
},
|
},
|
||||||
FLYIO: {
|
FLYIO: {
|
||||||
appId: "The ID of the Fly.io app to sync secrets to."
|
appId: "The ID of the Fly.io app to sync secrets to."
|
||||||
|
},
|
||||||
|
CLOUDFLARE_PAGES: {
|
||||||
|
projectName: "The name of the Cloudflare Pages project to sync secrets to.",
|
||||||
|
environment: "The environment of the Cloudflare Pages project to sync secrets to."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
+38
-3
@@ -1,11 +1,16 @@
|
|||||||
import { AppConnection } from "@app/services/app-connection/app-connection-enums";
|
import z from "zod";
|
||||||
|
|
||||||
import { registerAppConnectionEndpoints } from "./app-connection-endpoints";
|
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 {
|
import {
|
||||||
SanitizedCloudflareConnectionSchema,
|
|
||||||
CreateCloudflareConnectionSchema,
|
CreateCloudflareConnectionSchema,
|
||||||
|
SanitizedCloudflareConnectionSchema,
|
||||||
UpdateCloudflareConnectionSchema
|
UpdateCloudflareConnectionSchema
|
||||||
} from "@app/services/app-connection/cloudflare/cloudflare-connection-schema";
|
} from "@app/services/app-connection/cloudflare/cloudflare-connection-schema";
|
||||||
|
import { AuthMode } from "@app/services/auth/auth-type";
|
||||||
|
|
||||||
|
import { registerAppConnectionEndpoints } from "./app-connection-endpoints";
|
||||||
|
|
||||||
export const registerCloudflareConnectionRouter = async (server: FastifyZodProvider) => {
|
export const registerCloudflareConnectionRouter = async (server: FastifyZodProvider) => {
|
||||||
registerAppConnectionEndpoints({
|
registerAppConnectionEndpoints({
|
||||||
@@ -15,4 +20,34 @@ export const registerCloudflareConnectionRouter = async (server: FastifyZodProvi
|
|||||||
createSchema: CreateCloudflareConnectionSchema,
|
createSchema: CreateCloudflareConnectionSchema,
|
||||||
updateSchema: UpdateCloudflareConnectionSchema
|
updateSchema: UpdateCloudflareConnectionSchema
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// The below endpoints are not exposed and for Infisical App use
|
||||||
|
server.route({
|
||||||
|
method: "GET",
|
||||||
|
url: `/:connectionId/cloudflare-pages-projects`,
|
||||||
|
config: {
|
||||||
|
rateLimit: readLimit
|
||||||
|
},
|
||||||
|
schema: {
|
||||||
|
params: z.object({
|
||||||
|
connectionId: z.string().uuid()
|
||||||
|
}),
|
||||||
|
response: {
|
||||||
|
200: z
|
||||||
|
.object({
|
||||||
|
id: z.string(),
|
||||||
|
name: z.string()
|
||||||
|
})
|
||||||
|
.array()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onRequest: verifyAuth([AuthMode.JWT]),
|
||||||
|
handler: async (req) => {
|
||||||
|
const { connectionId } = req.params;
|
||||||
|
|
||||||
|
const projects = await server.services.appConnection.cloudflare.listPagesProjects(connectionId, req.permission);
|
||||||
|
|
||||||
|
return projects;
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import { SecretSync } from "@app/services/secret-sync/secret-sync-enums";
|
||||||
|
import { registerSyncSecretsEndpoints } from "./secret-sync-endpoints";
|
||||||
|
import {
|
||||||
|
CloudflarePagesSyncSchema,
|
||||||
|
CreateCloudflarePagesSyncSchema,
|
||||||
|
UpdateCloudflarePagesSyncSchema
|
||||||
|
} from "@app/services/secret-sync/cloudflare-pages/cloudflare-pages-schema";
|
||||||
|
|
||||||
|
export const registerCloudflarePagesSyncRouter = async (server: FastifyZodProvider) =>
|
||||||
|
registerSyncSecretsEndpoints({
|
||||||
|
destination: SecretSync.CloudflarePages,
|
||||||
|
server,
|
||||||
|
responseSchema: CloudflarePagesSyncSchema,
|
||||||
|
createSchema: CreateCloudflarePagesSyncSchema,
|
||||||
|
updateSchema: UpdateCloudflarePagesSyncSchema
|
||||||
|
});
|
||||||
@@ -19,6 +19,7 @@ import { registerTeamCitySyncRouter } from "./teamcity-sync-router";
|
|||||||
import { registerTerraformCloudSyncRouter } from "./terraform-cloud-sync-router";
|
import { registerTerraformCloudSyncRouter } from "./terraform-cloud-sync-router";
|
||||||
import { registerVercelSyncRouter } from "./vercel-sync-router";
|
import { registerVercelSyncRouter } from "./vercel-sync-router";
|
||||||
import { registerWindmillSyncRouter } from "./windmill-sync-router";
|
import { registerWindmillSyncRouter } from "./windmill-sync-router";
|
||||||
|
import { registerCloudflarePagesSyncRouter } from "./cloudflare-pages-sync-router";
|
||||||
|
|
||||||
export * from "./secret-sync-router";
|
export * from "./secret-sync-router";
|
||||||
|
|
||||||
@@ -41,5 +42,6 @@ export const SECRET_SYNC_REGISTER_ROUTER_MAP: Record<SecretSync, (server: Fastif
|
|||||||
[SecretSync.OCIVault]: registerOCIVaultSyncRouter,
|
[SecretSync.OCIVault]: registerOCIVaultSyncRouter,
|
||||||
[SecretSync.OnePass]: registerOnePassSyncRouter,
|
[SecretSync.OnePass]: registerOnePassSyncRouter,
|
||||||
[SecretSync.Render]: registerRenderSyncRouter,
|
[SecretSync.Render]: registerRenderSyncRouter,
|
||||||
[SecretSync.Flyio]: registerFlyioSyncRouter
|
[SecretSync.Flyio]: registerFlyioSyncRouter,
|
||||||
|
[SecretSync.CloudflarePages]: registerCloudflarePagesSyncRouter
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -33,6 +33,10 @@ import { TeamCitySyncListItemSchema, TeamCitySyncSchema } from "@app/services/se
|
|||||||
import { TerraformCloudSyncListItemSchema, TerraformCloudSyncSchema } from "@app/services/secret-sync/terraform-cloud";
|
import { TerraformCloudSyncListItemSchema, TerraformCloudSyncSchema } from "@app/services/secret-sync/terraform-cloud";
|
||||||
import { VercelSyncListItemSchema, VercelSyncSchema } from "@app/services/secret-sync/vercel";
|
import { VercelSyncListItemSchema, VercelSyncSchema } from "@app/services/secret-sync/vercel";
|
||||||
import { WindmillSyncListItemSchema, WindmillSyncSchema } from "@app/services/secret-sync/windmill";
|
import { WindmillSyncListItemSchema, WindmillSyncSchema } from "@app/services/secret-sync/windmill";
|
||||||
|
import {
|
||||||
|
CloudflarePagesSyncListItemSchema,
|
||||||
|
CloudflarePagesSyncSchema
|
||||||
|
} from "@app/services/secret-sync/cloudflare-pages/cloudflare-pages-schema";
|
||||||
|
|
||||||
const SecretSyncSchema = z.discriminatedUnion("destination", [
|
const SecretSyncSchema = z.discriminatedUnion("destination", [
|
||||||
AwsParameterStoreSyncSchema,
|
AwsParameterStoreSyncSchema,
|
||||||
@@ -53,7 +57,8 @@ const SecretSyncSchema = z.discriminatedUnion("destination", [
|
|||||||
OCIVaultSyncSchema,
|
OCIVaultSyncSchema,
|
||||||
OnePassSyncSchema,
|
OnePassSyncSchema,
|
||||||
RenderSyncSchema,
|
RenderSyncSchema,
|
||||||
FlyioSyncSchema
|
FlyioSyncSchema,
|
||||||
|
CloudflarePagesSyncSchema
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const SecretSyncOptionsSchema = z.discriminatedUnion("destination", [
|
const SecretSyncOptionsSchema = z.discriminatedUnion("destination", [
|
||||||
@@ -75,7 +80,8 @@ const SecretSyncOptionsSchema = z.discriminatedUnion("destination", [
|
|||||||
OCIVaultSyncListItemSchema,
|
OCIVaultSyncListItemSchema,
|
||||||
OnePassSyncListItemSchema,
|
OnePassSyncListItemSchema,
|
||||||
RenderSyncListItemSchema,
|
RenderSyncListItemSchema,
|
||||||
FlyioSyncListItemSchema
|
FlyioSyncListItemSchema,
|
||||||
|
CloudflarePagesSyncListItemSchema
|
||||||
]);
|
]);
|
||||||
|
|
||||||
export const registerSecretSyncRouter = async (server: FastifyZodProvider) => {
|
export const registerSecretSyncRouter = async (server: FastifyZodProvider) => {
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ import { ValidateAzureKeyVaultConnectionCredentialsSchema } from "./azure-key-va
|
|||||||
import { ValidateCamundaConnectionCredentialsSchema } from "./camunda";
|
import { ValidateCamundaConnectionCredentialsSchema } from "./camunda";
|
||||||
import { camundaConnectionService } from "./camunda/camunda-connection-service";
|
import { camundaConnectionService } from "./camunda/camunda-connection-service";
|
||||||
import { ValidateCloudflareConnectionCredentialsSchema } from "./cloudflare/cloudflare-connection-schema";
|
import { ValidateCloudflareConnectionCredentialsSchema } from "./cloudflare/cloudflare-connection-schema";
|
||||||
|
import { cloudflareConnectionService } from "./cloudflare/cloudflare-connection-service";
|
||||||
import { ValidateDatabricksConnectionCredentialsSchema } from "./databricks";
|
import { ValidateDatabricksConnectionCredentialsSchema } from "./databricks";
|
||||||
import { databricksConnectionService } from "./databricks/databricks-connection-service";
|
import { databricksConnectionService } from "./databricks/databricks-connection-service";
|
||||||
import { ValidateFlyioConnectionCredentialsSchema } from "./flyio";
|
import { ValidateFlyioConnectionCredentialsSchema } from "./flyio";
|
||||||
@@ -519,6 +520,7 @@ export const appConnectionServiceFactory = ({
|
|||||||
oci: ociConnectionService(connectAppConnectionById, licenseService),
|
oci: ociConnectionService(connectAppConnectionById, licenseService),
|
||||||
onepass: onePassConnectionService(connectAppConnectionById),
|
onepass: onePassConnectionService(connectAppConnectionById),
|
||||||
render: renderConnectionService(connectAppConnectionById),
|
render: renderConnectionService(connectAppConnectionById),
|
||||||
|
cloudflare: cloudflareConnectionService(connectAppConnectionById),
|
||||||
flyio: flyioConnectionService(connectAppConnectionById)
|
flyio: flyioConnectionService(connectAppConnectionById)
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,10 +3,14 @@ import { AxiosError } from "axios";
|
|||||||
import { request } from "@app/lib/config/request";
|
import { request } from "@app/lib/config/request";
|
||||||
import { BadRequestError } from "@app/lib/errors";
|
import { BadRequestError } from "@app/lib/errors";
|
||||||
import { AppConnection } from "@app/services/app-connection/app-connection-enums";
|
import { AppConnection } from "@app/services/app-connection/app-connection-enums";
|
||||||
|
import { IntegrationUrls } from "@app/services/integration-auth/integration-list";
|
||||||
|
|
||||||
import { CloudflareConnectionMethod } from "./cloudflare-connection-enum";
|
import { CloudflareConnectionMethod } from "./cloudflare-connection-enum";
|
||||||
import { TCloudflareConnectionConfig } from "./cloudflare-connection-types";
|
import {
|
||||||
import { IntegrationUrls } from "@app/services/integration-auth/integration-list";
|
TCloudflareConnection,
|
||||||
|
TCloudflareConnectionConfig,
|
||||||
|
TCloudflarePagesProject
|
||||||
|
} from "./cloudflare-connection-types";
|
||||||
|
|
||||||
export const getCloudflareConnectionListItem = () => {
|
export const getCloudflareConnectionListItem = () => {
|
||||||
return {
|
return {
|
||||||
@@ -16,6 +20,29 @@ export const getCloudflareConnectionListItem = () => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const listCloudflarePagesProjects = async (
|
||||||
|
appConnection: TCloudflareConnection
|
||||||
|
): Promise<TCloudflarePagesProject[]> => {
|
||||||
|
const {
|
||||||
|
credentials: { apiToken, accountId }
|
||||||
|
} = appConnection;
|
||||||
|
|
||||||
|
const { data } = await request.get<{ result: { name: string; id: string }[] }>(
|
||||||
|
`${IntegrationUrls.CLOUDFLARE_API_URL}/client/v4/accounts/${accountId}/pages/projects`,
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${apiToken}`,
|
||||||
|
Accept: "application/json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return data.result.map((a) => ({
|
||||||
|
name: a.name,
|
||||||
|
id: a.id
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
export const validateCloudflareConnectionCredentials = async (config: TCloudflareConnectionConfig) => {
|
export const validateCloudflareConnectionCredentials = async (config: TCloudflareConnectionConfig) => {
|
||||||
const { apiToken, accountId } = config.credentials;
|
const { apiToken, accountId } = config.credentials;
|
||||||
|
|
||||||
@@ -27,7 +54,7 @@ export const validateCloudflareConnectionCredentials = async (config: TCloudflar
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (resp.data.data === null) {
|
if (resp.data === null) {
|
||||||
throw new BadRequestError({
|
throw new BadRequestError({
|
||||||
message: "Unable to validate connection: Invalid API token provided."
|
message: "Unable to validate connection: Invalid API token provided."
|
||||||
});
|
});
|
||||||
@@ -35,6 +62,7 @@ export const validateCloudflareConnectionCredentials = async (config: TCloudflar
|
|||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
if (error instanceof AxiosError) {
|
if (error instanceof AxiosError) {
|
||||||
throw new BadRequestError({
|
throw new BadRequestError({
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
||||||
message: `Failed to validate credentials: ${error.response?.data?.errors?.[0]?.message || error.message || "Unknown error"}`
|
message: `Failed to validate credentials: ${error.response?.data?.errors?.[0]?.message || error.message || "Unknown error"}`
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
import { logger } from "@app/lib/logger";
|
||||||
|
import { OrgServiceActor } from "@app/lib/types";
|
||||||
|
|
||||||
|
import { AppConnection } from "../app-connection-enums";
|
||||||
|
import { listCloudflarePagesProjects } from "./cloudflare-connection-fns";
|
||||||
|
import { TCloudflareConnection } from "./cloudflare-connection-types";
|
||||||
|
|
||||||
|
type TGetAppConnectionFunc = (
|
||||||
|
app: AppConnection,
|
||||||
|
connectionId: string,
|
||||||
|
actor: OrgServiceActor
|
||||||
|
) => Promise<TCloudflareConnection>;
|
||||||
|
|
||||||
|
export const cloudflareConnectionService = (getAppConnection: TGetAppConnectionFunc) => {
|
||||||
|
const listPagesProjects = async (connectionId: string, actor: OrgServiceActor) => {
|
||||||
|
const appConnection = await getAppConnection(AppConnection.Cloudflare, connectionId, actor);
|
||||||
|
try {
|
||||||
|
const projects = await listCloudflarePagesProjects(appConnection);
|
||||||
|
|
||||||
|
return projects;
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(error, "Failed to list Cloudflare Pages projects for Cloudflare connection");
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
listPagesProjects
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -23,3 +23,8 @@ export type TCloudflareConnectionConfig = DiscriminativePick<
|
|||||||
> & {
|
> & {
|
||||||
orgId: string;
|
orgId: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type TCloudflarePagesProject = {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
};
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
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 CLOUDFLARE_PAGES_SYNC_LIST_OPTION: TSecretSyncListItem = {
|
||||||
|
name: "Cloudflare Pages",
|
||||||
|
destination: SecretSync.CloudflarePages,
|
||||||
|
connection: AppConnection.Cloudflare,
|
||||||
|
canImportSecrets: false
|
||||||
|
};
|
||||||
@@ -0,0 +1,138 @@
|
|||||||
|
import { request } from "@app/lib/config/request";
|
||||||
|
import { IntegrationUrls } from "@app/services/integration-auth/integration-list";
|
||||||
|
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 { TCloudflarePagesSyncWithCredentials } from "./cloudflare-pages-types";
|
||||||
|
|
||||||
|
const getProjectEnvironmentSecrets = async (secretSync: TCloudflarePagesSyncWithCredentials) => {
|
||||||
|
const {
|
||||||
|
destinationConfig,
|
||||||
|
connection: {
|
||||||
|
credentials: { apiToken, accountId }
|
||||||
|
}
|
||||||
|
} = secretSync;
|
||||||
|
|
||||||
|
const secrets = (
|
||||||
|
await request.get<{
|
||||||
|
result: {
|
||||||
|
deployment_configs: Record<
|
||||||
|
string,
|
||||||
|
{
|
||||||
|
env_vars: Record<string, { type: "plain_text" | "secret_text"; value: string }>;
|
||||||
|
}
|
||||||
|
>;
|
||||||
|
};
|
||||||
|
}>(
|
||||||
|
`${IntegrationUrls.CLOUDFLARE_PAGES_API_URL}/client/v4/accounts/${accountId}/pages/projects/${destinationConfig.projectName}`,
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${apiToken}`,
|
||||||
|
Accept: "application/json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
).data.result.deployment_configs[destinationConfig.environment].env_vars;
|
||||||
|
|
||||||
|
return Object.entries(secrets ?? []).map(([key, envVar]) => ({
|
||||||
|
key,
|
||||||
|
value: envVar.value
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
|
export const CloudflarePagesSyncFns = {
|
||||||
|
syncSecrets: async (secretSync: TCloudflarePagesSyncWithCredentials, secretMap: TSecretMap) => {
|
||||||
|
const {
|
||||||
|
destinationConfig,
|
||||||
|
connection: {
|
||||||
|
credentials: { apiToken, accountId }
|
||||||
|
}
|
||||||
|
} = secretSync;
|
||||||
|
|
||||||
|
// Create/update secret entries
|
||||||
|
let secretEntries: [string, object | null][] = Object.entries(secretMap).map(([key, val]) => [
|
||||||
|
key,
|
||||||
|
{ type: "secret_text", value: val.value }
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Handle deletions if not disabled
|
||||||
|
if (!secretSync.syncOptions.disableSecretDeletion) {
|
||||||
|
const existingSecrets = await getProjectEnvironmentSecrets(secretSync);
|
||||||
|
const toDeleteKeys = existingSecrets
|
||||||
|
.filter(
|
||||||
|
(secret) =>
|
||||||
|
matchesSchema(secret.key, secretSync.environment?.slug || "", secretSync.syncOptions.keySchema) &&
|
||||||
|
!secretMap[secret.key]
|
||||||
|
)
|
||||||
|
.map((secret) => secret.key);
|
||||||
|
|
||||||
|
const toDeleteEntries: [string, null][] = toDeleteKeys.map((key) => [key, null]);
|
||||||
|
secretEntries = [...secretEntries, ...toDeleteEntries];
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = {
|
||||||
|
deployment_configs: {
|
||||||
|
[destinationConfig.environment]: {
|
||||||
|
env_vars: Object.fromEntries(secretEntries)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
await request.patch(
|
||||||
|
`${IntegrationUrls.CLOUDFLARE_PAGES_API_URL}/client/v4/accounts/${accountId}/pages/projects/${destinationConfig.projectName}`,
|
||||||
|
data,
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${apiToken}`,
|
||||||
|
Accept: "application/json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
getSecrets: async (secretSync: TCloudflarePagesSyncWithCredentials): Promise<TSecretMap> => {
|
||||||
|
throw new Error(`${SECRET_SYNC_NAME_MAP[secretSync.destination]} does not support importing secrets.`);
|
||||||
|
},
|
||||||
|
|
||||||
|
removeSecrets: async (secretSync: TCloudflarePagesSyncWithCredentials, secretMap: TSecretMap) => {
|
||||||
|
const {
|
||||||
|
destinationConfig,
|
||||||
|
connection: {
|
||||||
|
credentials: { apiToken, accountId }
|
||||||
|
}
|
||||||
|
} = secretSync;
|
||||||
|
|
||||||
|
const secrets = await getProjectEnvironmentSecrets(secretSync);
|
||||||
|
const toDeleteKeys = secrets
|
||||||
|
.filter(
|
||||||
|
(secret) =>
|
||||||
|
matchesSchema(secret.key, secretSync.environment?.slug || "", secretSync.syncOptions.keySchema) &&
|
||||||
|
secret.key in secretMap
|
||||||
|
)
|
||||||
|
.map((secret) => secret.key);
|
||||||
|
|
||||||
|
if (toDeleteKeys.length === 0) return;
|
||||||
|
|
||||||
|
const secretEntries: [string, null][] = toDeleteKeys.map((key) => [key, null]);
|
||||||
|
|
||||||
|
const data = {
|
||||||
|
deployment_configs: {
|
||||||
|
[destinationConfig.environment]: {
|
||||||
|
env_vars: Object.fromEntries(secretEntries)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
await request.patch(
|
||||||
|
`${IntegrationUrls.CLOUDFLARE_PAGES_API_URL}/client/v4/accounts/${accountId}/pages/projects/${destinationConfig.projectName}`,
|
||||||
|
data,
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${apiToken}`,
|
||||||
|
Accept: "application/json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
import { z } from "zod";
|
||||||
|
|
||||||
|
import { SecretSyncs } from "@app/lib/api-docs";
|
||||||
|
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";
|
||||||
|
|
||||||
|
const CloudflarePagesSyncDestinationConfigSchema = z.object({
|
||||||
|
projectName: z
|
||||||
|
.string()
|
||||||
|
.min(1, "Project name is required")
|
||||||
|
.describe(SecretSyncs.DESTINATION_CONFIG.CLOUDFLARE_PAGES.projectName),
|
||||||
|
environment: z
|
||||||
|
.string()
|
||||||
|
.min(1, "Environment is required")
|
||||||
|
.describe(SecretSyncs.DESTINATION_CONFIG.CLOUDFLARE_PAGES.environment)
|
||||||
|
});
|
||||||
|
|
||||||
|
const CloudflarePagesSyncOptionsConfig: TSyncOptionsConfig = { canImportSecrets: true };
|
||||||
|
|
||||||
|
export const CloudflarePagesSyncSchema = BaseSecretSyncSchema(
|
||||||
|
SecretSync.CloudflarePages,
|
||||||
|
CloudflarePagesSyncOptionsConfig
|
||||||
|
).extend({
|
||||||
|
destination: z.literal(SecretSync.CloudflarePages),
|
||||||
|
destinationConfig: CloudflarePagesSyncDestinationConfigSchema
|
||||||
|
});
|
||||||
|
|
||||||
|
export const CreateCloudflarePagesSyncSchema = GenericCreateSecretSyncFieldsSchema(
|
||||||
|
SecretSync.CloudflarePages,
|
||||||
|
CloudflarePagesSyncOptionsConfig
|
||||||
|
).extend({
|
||||||
|
destinationConfig: CloudflarePagesSyncDestinationConfigSchema
|
||||||
|
});
|
||||||
|
|
||||||
|
export const UpdateCloudflarePagesSyncSchema = GenericUpdateSecretSyncFieldsSchema(
|
||||||
|
SecretSync.CloudflarePages,
|
||||||
|
CloudflarePagesSyncOptionsConfig
|
||||||
|
).extend({
|
||||||
|
destinationConfig: CloudflarePagesSyncDestinationConfigSchema.optional()
|
||||||
|
});
|
||||||
|
|
||||||
|
export const CloudflarePagesSyncListItemSchema = z.object({
|
||||||
|
name: z.literal("Cloudflare Pages"),
|
||||||
|
connection: z.literal(AppConnection.Cloudflare),
|
||||||
|
destination: z.literal(SecretSync.CloudflarePages),
|
||||||
|
canImportSecrets: z.literal(false)
|
||||||
|
});
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import z from "zod";
|
||||||
|
|
||||||
|
import { TCloudflareConnection } from "@app/services/app-connection/cloudflare/cloudflare-connection-types";
|
||||||
|
|
||||||
|
import {
|
||||||
|
CloudflarePagesSyncListItemSchema,
|
||||||
|
CloudflarePagesSyncSchema,
|
||||||
|
CreateCloudflarePagesSyncSchema
|
||||||
|
} from "./cloudflare-pages-schema";
|
||||||
|
|
||||||
|
export type TCloudflarePagesSyncListItem = z.infer<typeof CloudflarePagesSyncListItemSchema>;
|
||||||
|
|
||||||
|
export type TCloudflarePagesSync = z.infer<typeof CloudflarePagesSyncSchema>;
|
||||||
|
|
||||||
|
export type TCloudflarePagesSyncInput = z.infer<typeof CreateCloudflarePagesSyncSchema>;
|
||||||
|
|
||||||
|
export type TCloudflarePagesSyncWithCredentials = TCloudflarePagesSync & {
|
||||||
|
connection: TCloudflareConnection;
|
||||||
|
};
|
||||||
@@ -17,7 +17,8 @@ export enum SecretSync {
|
|||||||
OCIVault = "oci-vault",
|
OCIVault = "oci-vault",
|
||||||
OnePass = "1password",
|
OnePass = "1password",
|
||||||
Render = "render",
|
Render = "render",
|
||||||
Flyio = "flyio"
|
Flyio = "flyio",
|
||||||
|
CloudflarePages = "cloudflare-pages"
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum SecretSyncInitialSyncBehavior {
|
export enum SecretSyncInitialSyncBehavior {
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ import { AZURE_APP_CONFIGURATION_SYNC_LIST_OPTION, azureAppConfigurationSyncFact
|
|||||||
import { AZURE_DEVOPS_SYNC_LIST_OPTION, azureDevOpsSyncFactory } from "./azure-devops";
|
import { AZURE_DEVOPS_SYNC_LIST_OPTION, azureDevOpsSyncFactory } from "./azure-devops";
|
||||||
import { AZURE_KEY_VAULT_SYNC_LIST_OPTION, azureKeyVaultSyncFactory } from "./azure-key-vault";
|
import { AZURE_KEY_VAULT_SYNC_LIST_OPTION, azureKeyVaultSyncFactory } from "./azure-key-vault";
|
||||||
import { CAMUNDA_SYNC_LIST_OPTION, camundaSyncFactory } from "./camunda";
|
import { CAMUNDA_SYNC_LIST_OPTION, camundaSyncFactory } from "./camunda";
|
||||||
|
import { CLOUDFLARE_PAGES_SYNC_LIST_OPTION } from "./cloudflare-pages/cloudflare-pages-constants";
|
||||||
|
import { CloudflarePagesSyncFns } from "./cloudflare-pages/cloudflare-pages-fns";
|
||||||
import { FLYIO_SYNC_LIST_OPTION, FlyioSyncFns } from "./flyio";
|
import { FLYIO_SYNC_LIST_OPTION, FlyioSyncFns } from "./flyio";
|
||||||
import { GCP_SYNC_LIST_OPTION } from "./gcp";
|
import { GCP_SYNC_LIST_OPTION } from "./gcp";
|
||||||
import { GcpSyncFns } from "./gcp/gcp-sync-fns";
|
import { GcpSyncFns } from "./gcp/gcp-sync-fns";
|
||||||
@@ -61,7 +63,8 @@ const SECRET_SYNC_LIST_OPTIONS: Record<SecretSync, TSecretSyncListItem> = {
|
|||||||
[SecretSync.OCIVault]: OCI_VAULT_SYNC_LIST_OPTION,
|
[SecretSync.OCIVault]: OCI_VAULT_SYNC_LIST_OPTION,
|
||||||
[SecretSync.OnePass]: ONEPASS_SYNC_LIST_OPTION,
|
[SecretSync.OnePass]: ONEPASS_SYNC_LIST_OPTION,
|
||||||
[SecretSync.Render]: RENDER_SYNC_LIST_OPTION,
|
[SecretSync.Render]: RENDER_SYNC_LIST_OPTION,
|
||||||
[SecretSync.Flyio]: FLYIO_SYNC_LIST_OPTION
|
[SecretSync.Flyio]: FLYIO_SYNC_LIST_OPTION,
|
||||||
|
[SecretSync.CloudflarePages]: CLOUDFLARE_PAGES_SYNC_LIST_OPTION
|
||||||
};
|
};
|
||||||
|
|
||||||
export const listSecretSyncOptions = () => {
|
export const listSecretSyncOptions = () => {
|
||||||
@@ -223,6 +226,8 @@ export const SecretSyncFns = {
|
|||||||
return RenderSyncFns.syncSecrets(secretSync, schemaSecretMap);
|
return RenderSyncFns.syncSecrets(secretSync, schemaSecretMap);
|
||||||
case SecretSync.Flyio:
|
case SecretSync.Flyio:
|
||||||
return FlyioSyncFns.syncSecrets(secretSync, schemaSecretMap);
|
return FlyioSyncFns.syncSecrets(secretSync, schemaSecretMap);
|
||||||
|
case SecretSync.CloudflarePages:
|
||||||
|
return CloudflarePagesSyncFns.syncSecrets(secretSync, schemaSecretMap);
|
||||||
default:
|
default:
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Unhandled sync destination for sync secrets fns: ${(secretSync as TSecretSyncWithCredentials).destination}`
|
`Unhandled sync destination for sync secrets fns: ${(secretSync as TSecretSyncWithCredentials).destination}`
|
||||||
@@ -306,6 +311,9 @@ export const SecretSyncFns = {
|
|||||||
case SecretSync.Flyio:
|
case SecretSync.Flyio:
|
||||||
secretMap = await FlyioSyncFns.getSecrets(secretSync);
|
secretMap = await FlyioSyncFns.getSecrets(secretSync);
|
||||||
break;
|
break;
|
||||||
|
case SecretSync.CloudflarePages:
|
||||||
|
secretMap = await CloudflarePagesSyncFns.getSecrets(secretSync);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Unhandled sync destination for get secrets fns: ${(secretSync as TSecretSyncWithCredentials).destination}`
|
`Unhandled sync destination for get secrets fns: ${(secretSync as TSecretSyncWithCredentials).destination}`
|
||||||
@@ -377,6 +385,8 @@ export const SecretSyncFns = {
|
|||||||
return RenderSyncFns.removeSecrets(secretSync, schemaSecretMap);
|
return RenderSyncFns.removeSecrets(secretSync, schemaSecretMap);
|
||||||
case SecretSync.Flyio:
|
case SecretSync.Flyio:
|
||||||
return FlyioSyncFns.removeSecrets(secretSync, schemaSecretMap);
|
return FlyioSyncFns.removeSecrets(secretSync, schemaSecretMap);
|
||||||
|
case SecretSync.CloudflarePages:
|
||||||
|
return CloudflarePagesSyncFns.removeSecrets(secretSync, schemaSecretMap);
|
||||||
default:
|
default:
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Unhandled sync destination for remove secrets fns: ${(secretSync as TSecretSyncWithCredentials).destination}`
|
`Unhandled sync destination for remove secrets fns: ${(secretSync as TSecretSyncWithCredentials).destination}`
|
||||||
|
|||||||
@@ -20,7 +20,8 @@ export const SECRET_SYNC_NAME_MAP: Record<SecretSync, string> = {
|
|||||||
[SecretSync.OCIVault]: "OCI Vault",
|
[SecretSync.OCIVault]: "OCI Vault",
|
||||||
[SecretSync.OnePass]: "1Password",
|
[SecretSync.OnePass]: "1Password",
|
||||||
[SecretSync.Render]: "Render",
|
[SecretSync.Render]: "Render",
|
||||||
[SecretSync.Flyio]: "Fly.io"
|
[SecretSync.Flyio]: "Fly.io",
|
||||||
|
[SecretSync.CloudflarePages]: "Cloudflare Pages"
|
||||||
};
|
};
|
||||||
|
|
||||||
export const SECRET_SYNC_CONNECTION_MAP: Record<SecretSync, AppConnection> = {
|
export const SECRET_SYNC_CONNECTION_MAP: Record<SecretSync, AppConnection> = {
|
||||||
@@ -42,7 +43,8 @@ export const SECRET_SYNC_CONNECTION_MAP: Record<SecretSync, AppConnection> = {
|
|||||||
[SecretSync.OCIVault]: AppConnection.OCI,
|
[SecretSync.OCIVault]: AppConnection.OCI,
|
||||||
[SecretSync.OnePass]: AppConnection.OnePass,
|
[SecretSync.OnePass]: AppConnection.OnePass,
|
||||||
[SecretSync.Render]: AppConnection.Render,
|
[SecretSync.Render]: AppConnection.Render,
|
||||||
[SecretSync.Flyio]: AppConnection.Flyio
|
[SecretSync.Flyio]: AppConnection.Flyio,
|
||||||
|
[SecretSync.CloudflarePages]: AppConnection.Cloudflare
|
||||||
};
|
};
|
||||||
|
|
||||||
export const SECRET_SYNC_PLAN_MAP: Record<SecretSync, SecretSyncPlanType> = {
|
export const SECRET_SYNC_PLAN_MAP: Record<SecretSync, SecretSyncPlanType> = {
|
||||||
@@ -64,5 +66,6 @@ export const SECRET_SYNC_PLAN_MAP: Record<SecretSync, SecretSyncPlanType> = {
|
|||||||
[SecretSync.OCIVault]: SecretSyncPlanType.Enterprise,
|
[SecretSync.OCIVault]: SecretSyncPlanType.Enterprise,
|
||||||
[SecretSync.OnePass]: SecretSyncPlanType.Regular,
|
[SecretSync.OnePass]: SecretSyncPlanType.Regular,
|
||||||
[SecretSync.Render]: SecretSyncPlanType.Regular,
|
[SecretSync.Render]: SecretSyncPlanType.Regular,
|
||||||
[SecretSync.Flyio]: SecretSyncPlanType.Regular
|
[SecretSync.Flyio]: SecretSyncPlanType.Regular,
|
||||||
|
[SecretSync.CloudflarePages]: SecretSyncPlanType.Regular
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -105,6 +105,12 @@ import {
|
|||||||
TTerraformCloudSyncWithCredentials
|
TTerraformCloudSyncWithCredentials
|
||||||
} from "./terraform-cloud";
|
} from "./terraform-cloud";
|
||||||
import { TVercelSync, TVercelSyncInput, TVercelSyncListItem, TVercelSyncWithCredentials } from "./vercel";
|
import { TVercelSync, TVercelSyncInput, TVercelSyncListItem, TVercelSyncWithCredentials } from "./vercel";
|
||||||
|
import {
|
||||||
|
TCloudflarePagesSync,
|
||||||
|
TCloudflarePagesSyncInput,
|
||||||
|
TCloudflarePagesSyncListItem,
|
||||||
|
TCloudflarePagesSyncWithCredentials
|
||||||
|
} from "./cloudflare-pages/cloudflare-pages-types";
|
||||||
|
|
||||||
export type TSecretSync =
|
export type TSecretSync =
|
||||||
| TAwsParameterStoreSync
|
| TAwsParameterStoreSync
|
||||||
@@ -125,7 +131,8 @@ export type TSecretSync =
|
|||||||
| TOCIVaultSync
|
| TOCIVaultSync
|
||||||
| TOnePassSync
|
| TOnePassSync
|
||||||
| TRenderSync
|
| TRenderSync
|
||||||
| TFlyioSync;
|
| TFlyioSync
|
||||||
|
| TCloudflarePagesSync;
|
||||||
|
|
||||||
export type TSecretSyncWithCredentials =
|
export type TSecretSyncWithCredentials =
|
||||||
| TAwsParameterStoreSyncWithCredentials
|
| TAwsParameterStoreSyncWithCredentials
|
||||||
@@ -146,7 +153,8 @@ export type TSecretSyncWithCredentials =
|
|||||||
| TOCIVaultSyncWithCredentials
|
| TOCIVaultSyncWithCredentials
|
||||||
| TOnePassSyncWithCredentials
|
| TOnePassSyncWithCredentials
|
||||||
| TRenderSyncWithCredentials
|
| TRenderSyncWithCredentials
|
||||||
| TFlyioSyncWithCredentials;
|
| TFlyioSyncWithCredentials
|
||||||
|
| TCloudflarePagesSyncWithCredentials;
|
||||||
|
|
||||||
export type TSecretSyncInput =
|
export type TSecretSyncInput =
|
||||||
| TAwsParameterStoreSyncInput
|
| TAwsParameterStoreSyncInput
|
||||||
@@ -167,7 +175,8 @@ export type TSecretSyncInput =
|
|||||||
| TOCIVaultSyncInput
|
| TOCIVaultSyncInput
|
||||||
| TOnePassSyncInput
|
| TOnePassSyncInput
|
||||||
| TRenderSyncInput
|
| TRenderSyncInput
|
||||||
| TFlyioSyncInput;
|
| TFlyioSyncInput
|
||||||
|
| TCloudflarePagesSyncInput;
|
||||||
|
|
||||||
export type TSecretSyncListItem =
|
export type TSecretSyncListItem =
|
||||||
| TAwsParameterStoreSyncListItem
|
| TAwsParameterStoreSyncListItem
|
||||||
@@ -188,7 +197,8 @@ export type TSecretSyncListItem =
|
|||||||
| TOCIVaultSyncListItem
|
| TOCIVaultSyncListItem
|
||||||
| TOnePassSyncListItem
|
| TOnePassSyncListItem
|
||||||
| TRenderSyncListItem
|
| TRenderSyncListItem
|
||||||
| TFlyioSyncListItem;
|
| TFlyioSyncListItem
|
||||||
|
| TCloudflarePagesSyncListItem;
|
||||||
|
|
||||||
export type TSyncOptionsConfig = {
|
export type TSyncOptionsConfig = {
|
||||||
canImportSecrets: boolean;
|
canImportSecrets: boolean;
|
||||||
|
|||||||
+95
@@ -0,0 +1,95 @@
|
|||||||
|
import { Controller, useFormContext, useWatch } from "react-hook-form";
|
||||||
|
import { SingleValue } from "react-select";
|
||||||
|
|
||||||
|
import { SecretSyncConnectionField } from "@app/components/secret-syncs/forms/SecretSyncConnectionField";
|
||||||
|
import { FilterableSelect, FormControl, Select, SelectItem } from "@app/components/v2";
|
||||||
|
import {
|
||||||
|
TCloudflareProject,
|
||||||
|
useCloudflareConnectionListPagesProjects
|
||||||
|
} from "@app/hooks/api/appConnections/cloudflare";
|
||||||
|
import { SecretSync } from "@app/hooks/api/secretSyncs";
|
||||||
|
|
||||||
|
import { TSecretSyncForm } from "../schemas";
|
||||||
|
|
||||||
|
const CLOUDFLARE_ENVIRONMENTS = [
|
||||||
|
{
|
||||||
|
name: "Preview",
|
||||||
|
value: "preview"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Production",
|
||||||
|
value: "production"
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
export const CloudflarePagesSyncFields = () => {
|
||||||
|
const { control, setValue } = useFormContext<
|
||||||
|
TSecretSyncForm & { destination: SecretSync.CloudflarePages }
|
||||||
|
>();
|
||||||
|
|
||||||
|
const connectionId = useWatch({ name: "connection.id", control });
|
||||||
|
|
||||||
|
const { data: projects = [], isPending: isProjectsPending } =
|
||||||
|
useCloudflareConnectionListPagesProjects(connectionId, {
|
||||||
|
enabled: Boolean(connectionId)
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<SecretSyncConnectionField
|
||||||
|
onChange={() => {
|
||||||
|
setValue("destinationConfig.projectName", "");
|
||||||
|
setValue("destinationConfig.environment", "preview");
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Controller
|
||||||
|
name="destinationConfig.projectName"
|
||||||
|
control={control}
|
||||||
|
render={({ field: { value, onChange }, fieldState: { error } }) => (
|
||||||
|
<FormControl errorText={error?.message} isError={Boolean(error?.message)} label="Project">
|
||||||
|
<FilterableSelect
|
||||||
|
isLoading={isProjectsPending && Boolean(connectionId)}
|
||||||
|
isDisabled={!connectionId}
|
||||||
|
value={projects ? (projects.find((project) => project.name === value) ?? []) : []}
|
||||||
|
onChange={(option) => {
|
||||||
|
onChange((option as SingleValue<TCloudflareProject>)?.name ?? null);
|
||||||
|
}}
|
||||||
|
options={projects}
|
||||||
|
placeholder="Select a project..."
|
||||||
|
getOptionLabel={(option) => option.name}
|
||||||
|
getOptionValue={(option) => option.id.toString()}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<Controller
|
||||||
|
name="destinationConfig.environment"
|
||||||
|
control={control}
|
||||||
|
defaultValue="preview"
|
||||||
|
render={({ field: { value, onChange }, fieldState: { error } }) => (
|
||||||
|
<FormControl
|
||||||
|
errorText={error?.message}
|
||||||
|
isError={Boolean(error?.message)}
|
||||||
|
label="Environment"
|
||||||
|
tooltipClassName="max-w-lg py-3"
|
||||||
|
>
|
||||||
|
<Select
|
||||||
|
value={value}
|
||||||
|
onValueChange={(val) => onChange(val)}
|
||||||
|
className="w-full border border-mineshaft-500 capitalize"
|
||||||
|
position="popper"
|
||||||
|
placeholder="Select a scope..."
|
||||||
|
dropdownContainerClassName="max-w-none"
|
||||||
|
>
|
||||||
|
{CLOUDFLARE_ENVIRONMENTS.map(({ name, value: envValue }) => (
|
||||||
|
<SelectItem className="capitalize" value={envValue} key={envValue}>
|
||||||
|
{name}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</Select>
|
||||||
|
</FormControl>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
+3
@@ -10,6 +10,7 @@ import { AzureAppConfigurationSyncFields } from "./AzureAppConfigurationSyncFiel
|
|||||||
import { AzureDevOpsSyncFields } from "./AzureDevOpsSyncFields";
|
import { AzureDevOpsSyncFields } from "./AzureDevOpsSyncFields";
|
||||||
import { AzureKeyVaultSyncFields } from "./AzureKeyVaultSyncFields";
|
import { AzureKeyVaultSyncFields } from "./AzureKeyVaultSyncFields";
|
||||||
import { CamundaSyncFields } from "./CamundaSyncFields";
|
import { CamundaSyncFields } from "./CamundaSyncFields";
|
||||||
|
import { CloudflarePagesSyncFields } from "./CloudflarePagesSyncFields";
|
||||||
import { DatabricksSyncFields } from "./DatabricksSyncFields";
|
import { DatabricksSyncFields } from "./DatabricksSyncFields";
|
||||||
import { FlyioSyncFields } from "./FlyioSyncFields";
|
import { FlyioSyncFields } from "./FlyioSyncFields";
|
||||||
import { GcpSyncFields } from "./GcpSyncFields";
|
import { GcpSyncFields } from "./GcpSyncFields";
|
||||||
@@ -67,6 +68,8 @@ export const SecretSyncDestinationFields = () => {
|
|||||||
return <RenderSyncFields />;
|
return <RenderSyncFields />;
|
||||||
case SecretSync.Flyio:
|
case SecretSync.Flyio:
|
||||||
return <FlyioSyncFields />;
|
return <FlyioSyncFields />;
|
||||||
|
case SecretSync.CloudflarePages:
|
||||||
|
return <CloudflarePagesSyncFields />;
|
||||||
default:
|
default:
|
||||||
throw new Error(`Unhandled Destination Config Field: ${destination}`);
|
throw new Error(`Unhandled Destination Config Field: ${destination}`);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
@@ -54,6 +54,7 @@ export const SecretSyncOptionsFields = ({ hideInitialSync }: Props) => {
|
|||||||
case SecretSync.OCIVault:
|
case SecretSync.OCIVault:
|
||||||
case SecretSync.Render:
|
case SecretSync.Render:
|
||||||
case SecretSync.Flyio:
|
case SecretSync.Flyio:
|
||||||
|
case SecretSync.CloudflarePages:
|
||||||
AdditionalSyncOptionsFieldsComponent = null;
|
AdditionalSyncOptionsFieldsComponent = null;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
import { useFormContext } from "react-hook-form";
|
||||||
|
|
||||||
|
import { TSecretSyncForm } from "@app/components/secret-syncs/forms/schemas";
|
||||||
|
import { GenericFieldLabel } from "@app/components/v2";
|
||||||
|
import { SecretSync } from "@app/hooks/api/secretSyncs";
|
||||||
|
|
||||||
|
export const CloudflarePagesSyncReviewFields = () => {
|
||||||
|
const { watch } = useFormContext<TSecretSyncForm & { destination: SecretSync.CloudflarePages }>();
|
||||||
|
const projectName = watch("destinationConfig.projectName");
|
||||||
|
const environment = watch("destinationConfig.environment");
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<GenericFieldLabel label="Project">{projectName}</GenericFieldLabel>
|
||||||
|
<GenericFieldLabel label="Environment">{environment}</GenericFieldLabel>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
+4
@@ -19,6 +19,7 @@ import { AzureAppConfigurationSyncReviewFields } from "./AzureAppConfigurationSy
|
|||||||
import { AzureDevOpsSyncReviewFields } from "./AzureDevOpsSyncReviewFields";
|
import { AzureDevOpsSyncReviewFields } from "./AzureDevOpsSyncReviewFields";
|
||||||
import { AzureKeyVaultSyncReviewFields } from "./AzureKeyVaultSyncReviewFields";
|
import { AzureKeyVaultSyncReviewFields } from "./AzureKeyVaultSyncReviewFields";
|
||||||
import { CamundaSyncReviewFields } from "./CamundaSyncReviewFields";
|
import { CamundaSyncReviewFields } from "./CamundaSyncReviewFields";
|
||||||
|
import { CloudflarePagesSyncReviewFields } from "./CloudflarePagesReviewFields";
|
||||||
import { DatabricksSyncReviewFields } from "./DatabricksSyncReviewFields";
|
import { DatabricksSyncReviewFields } from "./DatabricksSyncReviewFields";
|
||||||
import { FlyioSyncReviewFields } from "./FlyioSyncReviewFields";
|
import { FlyioSyncReviewFields } from "./FlyioSyncReviewFields";
|
||||||
import { GcpSyncReviewFields } from "./GcpSyncReviewFields";
|
import { GcpSyncReviewFields } from "./GcpSyncReviewFields";
|
||||||
@@ -112,6 +113,9 @@ export const SecretSyncReviewFields = () => {
|
|||||||
case SecretSync.Flyio:
|
case SecretSync.Flyio:
|
||||||
DestinationFieldsComponent = <FlyioSyncReviewFields />;
|
DestinationFieldsComponent = <FlyioSyncReviewFields />;
|
||||||
break;
|
break;
|
||||||
|
case SecretSync.CloudflarePages:
|
||||||
|
DestinationFieldsComponent = <CloudflarePagesSyncReviewFields />;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error(`Unhandled Destination Review Fields: ${destination}`);
|
throw new Error(`Unhandled Destination Review Fields: ${destination}`);
|
||||||
}
|
}
|
||||||
|
|||||||
+14
@@ -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 CloudflarePagesSyncDestinationSchema = BaseSecretSyncSchema().merge(
|
||||||
|
z.object({
|
||||||
|
destination: z.literal(SecretSync.CloudflarePages),
|
||||||
|
destinationConfig: z.object({
|
||||||
|
projectName: z.string().trim().min(1, "Project name is required"),
|
||||||
|
environment: z.string().trim().min(1, "Environment is required")
|
||||||
|
})
|
||||||
|
})
|
||||||
|
);
|
||||||
@@ -7,6 +7,7 @@ import { AzureAppConfigurationSyncDestinationSchema } from "./azure-app-configur
|
|||||||
import { AzureDevOpsSyncDestinationSchema } from "./azure-devops-sync-destination-schema";
|
import { AzureDevOpsSyncDestinationSchema } from "./azure-devops-sync-destination-schema";
|
||||||
import { AzureKeyVaultSyncDestinationSchema } from "./azure-key-vault-sync-destination-schema";
|
import { AzureKeyVaultSyncDestinationSchema } from "./azure-key-vault-sync-destination-schema";
|
||||||
import { CamundaSyncDestinationSchema } from "./camunda-sync-destination-schema";
|
import { CamundaSyncDestinationSchema } from "./camunda-sync-destination-schema";
|
||||||
|
import { CloudflarePagesSyncDestinationSchema } from "./cloudflare-pages-sync-destination-schema";
|
||||||
import { DatabricksSyncDestinationSchema } from "./databricks-sync-destination-schema";
|
import { DatabricksSyncDestinationSchema } from "./databricks-sync-destination-schema";
|
||||||
import { FlyioSyncDestinationSchema } from "./flyio-sync-destination-schema";
|
import { FlyioSyncDestinationSchema } from "./flyio-sync-destination-schema";
|
||||||
import { GcpSyncDestinationSchema } from "./gcp-sync-destination-schema";
|
import { GcpSyncDestinationSchema } from "./gcp-sync-destination-schema";
|
||||||
@@ -39,7 +40,8 @@ const SecretSyncUnionSchema = z.discriminatedUnion("destination", [
|
|||||||
OCIVaultSyncDestinationSchema,
|
OCIVaultSyncDestinationSchema,
|
||||||
OnePassSyncDestinationSchema,
|
OnePassSyncDestinationSchema,
|
||||||
RenderSyncDestinationSchema,
|
RenderSyncDestinationSchema,
|
||||||
FlyioSyncDestinationSchema
|
FlyioSyncDestinationSchema,
|
||||||
|
CloudflarePagesSyncDestinationSchema
|
||||||
]);
|
]);
|
||||||
|
|
||||||
export const SecretSyncFormSchema = SecretSyncUnionSchema;
|
export const SecretSyncFormSchema = SecretSyncUnionSchema;
|
||||||
|
|||||||
@@ -69,6 +69,10 @@ export const SECRET_SYNC_MAP: Record<SecretSync, { name: string; image: string }
|
|||||||
[SecretSync.Flyio]: {
|
[SecretSync.Flyio]: {
|
||||||
name: "Fly.io",
|
name: "Fly.io",
|
||||||
image: "Flyio.svg"
|
image: "Flyio.svg"
|
||||||
|
},
|
||||||
|
[SecretSync.CloudflarePages]: {
|
||||||
|
name: "Cloudflare Pages",
|
||||||
|
image: "Cloudflare.png"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -91,7 +95,8 @@ export const SECRET_SYNC_CONNECTION_MAP: Record<SecretSync, AppConnection> = {
|
|||||||
[SecretSync.OCIVault]: AppConnection.OCI,
|
[SecretSync.OCIVault]: AppConnection.OCI,
|
||||||
[SecretSync.OnePass]: AppConnection.OnePass,
|
[SecretSync.OnePass]: AppConnection.OnePass,
|
||||||
[SecretSync.Render]: AppConnection.Render,
|
[SecretSync.Render]: AppConnection.Render,
|
||||||
[SecretSync.Flyio]: AppConnection.Flyio
|
[SecretSync.Flyio]: AppConnection.Flyio,
|
||||||
|
[SecretSync.CloudflarePages]: AppConnection.Cloudflare
|
||||||
};
|
};
|
||||||
|
|
||||||
export const SECRET_SYNC_INITIAL_SYNC_BEHAVIOR_MAP: Record<
|
export const SECRET_SYNC_INITIAL_SYNC_BEHAVIOR_MAP: Record<
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
export * from "./queries";
|
||||||
|
export * from "./types";
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
import { useQuery, UseQueryOptions } from "@tanstack/react-query";
|
||||||
|
|
||||||
|
import { apiRequest } from "@app/config/request";
|
||||||
|
|
||||||
|
import { appConnectionKeys } from "../queries";
|
||||||
|
import { TCloudflareProject } from "./types";
|
||||||
|
|
||||||
|
const cloudflareConnectionKeys = {
|
||||||
|
all: [...appConnectionKeys.all, "cloudflare"] as const,
|
||||||
|
listPagesProjects: (connectionId: string) =>
|
||||||
|
[...cloudflareConnectionKeys.all, "pages-projects", connectionId] as const
|
||||||
|
};
|
||||||
|
|
||||||
|
export const useCloudflareConnectionListPagesProjects = (
|
||||||
|
connectionId: string,
|
||||||
|
options?: Omit<
|
||||||
|
UseQueryOptions<
|
||||||
|
TCloudflareProject[],
|
||||||
|
unknown,
|
||||||
|
TCloudflareProject[],
|
||||||
|
ReturnType<typeof cloudflareConnectionKeys.listPagesProjects>
|
||||||
|
>,
|
||||||
|
"queryKey" | "queryFn"
|
||||||
|
>
|
||||||
|
) => {
|
||||||
|
return useQuery({
|
||||||
|
queryKey: cloudflareConnectionKeys.listPagesProjects(connectionId),
|
||||||
|
queryFn: async () => {
|
||||||
|
const { data } = await apiRequest.get<TCloudflareProject[]>(
|
||||||
|
`/api/v1/app-connections/cloudflare/${connectionId}/cloudflare-pages-projects`
|
||||||
|
);
|
||||||
|
|
||||||
|
return data;
|
||||||
|
},
|
||||||
|
...options
|
||||||
|
});
|
||||||
|
};
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
export type TCloudflareProject = {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
};
|
||||||
@@ -17,7 +17,8 @@ export enum SecretSync {
|
|||||||
OCIVault = "oci-vault",
|
OCIVault = "oci-vault",
|
||||||
OnePass = "1password",
|
OnePass = "1password",
|
||||||
Render = "render",
|
Render = "render",
|
||||||
Flyio = "flyio"
|
Flyio = "flyio",
|
||||||
|
CloudflarePages = "cloudflare-pages"
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum SecretSyncStatus {
|
export enum SecretSyncStatus {
|
||||||
|
|||||||
@@ -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 TCloudflarePagesSync = TRootSecretSync & {
|
||||||
|
destination: SecretSync.CloudflarePages;
|
||||||
|
destinationConfig: {
|
||||||
|
projectName: string;
|
||||||
|
environment: string;
|
||||||
|
};
|
||||||
|
connection: {
|
||||||
|
app: AppConnection.Cloudflare;
|
||||||
|
name: string;
|
||||||
|
id: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -9,6 +9,7 @@ import { TAzureAppConfigurationSync } from "./azure-app-configuration-sync";
|
|||||||
import { TAzureDevOpsSync } from "./azure-devops-sync";
|
import { TAzureDevOpsSync } from "./azure-devops-sync";
|
||||||
import { TAzureKeyVaultSync } from "./azure-key-vault-sync";
|
import { TAzureKeyVaultSync } from "./azure-key-vault-sync";
|
||||||
import { TCamundaSync } from "./camunda-sync";
|
import { TCamundaSync } from "./camunda-sync";
|
||||||
|
import { TCloudflarePagesSync } from "./cloudflare-pages-sync";
|
||||||
import { TDatabricksSync } from "./databricks-sync";
|
import { TDatabricksSync } from "./databricks-sync";
|
||||||
import { TFlyioSync } from "./flyio-sync";
|
import { TFlyioSync } from "./flyio-sync";
|
||||||
import { TGcpSync } from "./gcp-sync";
|
import { TGcpSync } from "./gcp-sync";
|
||||||
@@ -47,7 +48,8 @@ export type TSecretSync =
|
|||||||
| TOCIVaultSync
|
| TOCIVaultSync
|
||||||
| TOnePassSync
|
| TOnePassSync
|
||||||
| TRenderSync
|
| TRenderSync
|
||||||
| TFlyioSync;
|
| TFlyioSync
|
||||||
|
| TCloudflarePagesSync;
|
||||||
|
|
||||||
export type TListSecretSyncs = { secretSyncs: TSecretSync[] };
|
export type TListSecretSyncs = { secretSyncs: TSecretSync[] };
|
||||||
|
|
||||||
|
|||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
import { TCloudflarePagesSync } from "@app/hooks/api/secretSyncs/types/cloudflare-pages-sync";
|
||||||
|
|
||||||
|
import { getSecretSyncDestinationColValues } from "../helpers";
|
||||||
|
import { SecretSyncTableCell } from "../SecretSyncTableCell";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
secretSync: TCloudflarePagesSync;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const CloudflarePagesSyncDestinationCol = ({ secretSync }: Props) => {
|
||||||
|
const { primaryText, secondaryText } = getSecretSyncDestinationColValues(secretSync);
|
||||||
|
|
||||||
|
return <SecretSyncTableCell primaryText={primaryText} secondaryText={secondaryText} />;
|
||||||
|
};
|
||||||
+3
@@ -7,6 +7,7 @@ import { AzureAppConfigurationDestinationSyncCol } from "./AzureAppConfiguration
|
|||||||
import { AzureDevOpsSyncDestinationCol } from "./AzureDevOpsSyncDestinationCol";
|
import { AzureDevOpsSyncDestinationCol } from "./AzureDevOpsSyncDestinationCol";
|
||||||
import { AzureKeyVaultDestinationSyncCol } from "./AzureKeyVaultDestinationSyncCol";
|
import { AzureKeyVaultDestinationSyncCol } from "./AzureKeyVaultDestinationSyncCol";
|
||||||
import { CamundaSyncDestinationCol } from "./CamundaSyncDestinationCol";
|
import { CamundaSyncDestinationCol } from "./CamundaSyncDestinationCol";
|
||||||
|
import { CloudflarePagesSyncDestinationCol } from "./CloudflarePagesSyncDestinationCol";
|
||||||
import { DatabricksSyncDestinationCol } from "./DatabricksSyncDestinationCol";
|
import { DatabricksSyncDestinationCol } from "./DatabricksSyncDestinationCol";
|
||||||
import { FlyioSyncDestinationCol } from "./FlyioSyncDestinationCol";
|
import { FlyioSyncDestinationCol } from "./FlyioSyncDestinationCol";
|
||||||
import { GcpSyncDestinationCol } from "./GcpSyncDestinationCol";
|
import { GcpSyncDestinationCol } from "./GcpSyncDestinationCol";
|
||||||
@@ -64,6 +65,8 @@ export const SecretSyncDestinationCol = ({ secretSync }: Props) => {
|
|||||||
return <RenderSyncDestinationCol secretSync={secretSync} />;
|
return <RenderSyncDestinationCol secretSync={secretSync} />;
|
||||||
case SecretSync.Flyio:
|
case SecretSync.Flyio:
|
||||||
return <FlyioSyncDestinationCol secretSync={secretSync} />;
|
return <FlyioSyncDestinationCol secretSync={secretSync} />;
|
||||||
|
case SecretSync.CloudflarePages:
|
||||||
|
return <CloudflarePagesSyncDestinationCol secretSync={secretSync} />;
|
||||||
default:
|
default:
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Unhandled Secret Sync Destination Col: ${(secretSync as TSecretSync).destination}`
|
`Unhandled Secret Sync Destination Col: ${(secretSync as TSecretSync).destination}`
|
||||||
|
|||||||
+4
@@ -124,6 +124,10 @@ export const getSecretSyncDestinationColValues = (secretSync: TSecretSync) => {
|
|||||||
primaryText = destinationConfig.appId;
|
primaryText = destinationConfig.appId;
|
||||||
secondaryText = "App ID";
|
secondaryText = "App ID";
|
||||||
break;
|
break;
|
||||||
|
case SecretSync.CloudflarePages:
|
||||||
|
primaryText = destinationConfig.projectName;
|
||||||
|
secondaryText = destinationConfig.environment;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error(`Unhandled Destination Col Values ${destination}`);
|
throw new Error(`Unhandled Destination Col Values ${destination}`);
|
||||||
}
|
}
|
||||||
|
|||||||
+19
@@ -0,0 +1,19 @@
|
|||||||
|
import { GenericFieldLabel } from "@app/components/secret-syncs";
|
||||||
|
import { TCloudflarePagesSync } from "@app/hooks/api/secretSyncs/types/cloudflare-pages-sync";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
secretSync: TCloudflarePagesSync;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const CloudflarePagesSyncDestinationSection = ({ secretSync }: Props) => {
|
||||||
|
const {
|
||||||
|
destinationConfig: { projectName, environment }
|
||||||
|
} = secretSync;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<GenericFieldLabel label="Project">{projectName}</GenericFieldLabel>
|
||||||
|
<GenericFieldLabel label="Environment">{environment}</GenericFieldLabel>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
+4
@@ -18,6 +18,7 @@ import { AzureAppConfigurationSyncDestinationSection } from "./AzureAppConfigura
|
|||||||
import { AzureDevOpsSyncDestinationSection } from "./AzureDevOpsSyncDestinationSection";
|
import { AzureDevOpsSyncDestinationSection } from "./AzureDevOpsSyncDestinationSection";
|
||||||
import { AzureKeyVaultSyncDestinationSection } from "./AzureKeyVaultSyncDestinationSection";
|
import { AzureKeyVaultSyncDestinationSection } from "./AzureKeyVaultSyncDestinationSection";
|
||||||
import { CamundaSyncDestinationSection } from "./CamundaSyncDestinationSection";
|
import { CamundaSyncDestinationSection } from "./CamundaSyncDestinationSection";
|
||||||
|
import { CloudflarePagesSyncDestinationSection } from "./CloudflarePagesSyncDestinationSection";
|
||||||
import { DatabricksSyncDestinationSection } from "./DatabricksSyncDestinationSection";
|
import { DatabricksSyncDestinationSection } from "./DatabricksSyncDestinationSection";
|
||||||
import { FlyioSyncDestinationSection } from "./FlyioSyncDestinationSection";
|
import { FlyioSyncDestinationSection } from "./FlyioSyncDestinationSection";
|
||||||
import { GcpSyncDestinationSection } from "./GcpSyncDestinationSection";
|
import { GcpSyncDestinationSection } from "./GcpSyncDestinationSection";
|
||||||
@@ -102,6 +103,9 @@ export const SecretSyncDestinationSection = ({ secretSync, onEditDestination }:
|
|||||||
case SecretSync.Flyio:
|
case SecretSync.Flyio:
|
||||||
DestinationComponents = <FlyioSyncDestinationSection secretSync={secretSync} />;
|
DestinationComponents = <FlyioSyncDestinationSection secretSync={secretSync} />;
|
||||||
break;
|
break;
|
||||||
|
case SecretSync.CloudflarePages:
|
||||||
|
DestinationComponents = <CloudflarePagesSyncDestinationSection secretSync={secretSync} />;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error(`Unhandled Destination Section components: ${destination}`);
|
throw new Error(`Unhandled Destination Section components: ${destination}`);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
@@ -57,6 +57,7 @@ export const SecretSyncOptionsSection = ({ secretSync, onEditOptions }: Props) =
|
|||||||
case SecretSync.OnePass:
|
case SecretSync.OnePass:
|
||||||
case SecretSync.Render:
|
case SecretSync.Render:
|
||||||
case SecretSync.Flyio:
|
case SecretSync.Flyio:
|
||||||
|
case SecretSync.CloudflarePages:
|
||||||
AdditionalSyncOptionsComponent = null;
|
AdditionalSyncOptionsComponent = null;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user