Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

address greptile comments

adilsonaa3468d479c6
diff --git a/backend/src/services/secret-sync/gcp/gcp-sync-fns.ts b/backend/src/services/secret-sync/gcp/gcp-sync-fns.ts
index 98afb00d35..dc4ddcf452 100644
--- a/backend/src/services/secret-sync/gcp/gcp-sync-fns.ts
+++ b/backend/src/services/secret-sync/gcp/gcp-sync-fns.ts
@@ -8,7 +8,7 @@ import { GcpSyncScope } from "@app/services/secret-sync/gcp/gcp-sync-enums";
import { matchesSchema } from "@app/services/secret-sync/secret-sync-fns";
import { SecretSyncError } from "../secret-sync-errors";
-import { TSecretMap } from "../secret-sync-types";
+import { TPreSaveTransformDestinationConfigFn, TSecretMap } from "../secret-sync-types";
import {
GCPLatestSecretVersionAccess,
GCPSecret,
@@ -16,9 +16,20 @@ import {
TGcpSyncWithCredentials
} from "./gcp-sync-types";
+export const gcpPreSaveTransformDestinationConfig: TPreSaveTransformDestinationConfigFn = async ({
+ destinationConfig
+}) => {
+ if (!destinationConfig) return destinationConfig;
+ if (destinationConfig.scope !== GcpSyncScope.Global) return destinationConfig;
+ if (!destinationConfig.locationId) return destinationConfig;
+
+ const { locationId, ...rest } = destinationConfig;
+ return rest;
+};
+
const getGlobalReplication = (userReplicaLocationIds?: string[], locationId?: string) => {
// eslint-disable-next-line no-nested-ternary
- const locations = userReplicaLocationIds?.length ? userReplicaLocationIds : locationId ? [locationId] : [];
+ const locations = userReplicaLocationIds ?? (locationId ? [locationId] : []);
if (locations.length) {
return { userManaged: { replicas: locations.map((location) => ({ location })) } };
diff --git a/backend/src/services/secret-sync/secret-sync-fns.ts b/backend/src/services/secret-sync/secret-sync-fns.ts
index 3803b63f16..1d02b26518 100644
--- a/backend/src/services/secret-sync/secret-sync-fns.ts
+++ b/backend/src/services/secret-sync/secret-sync-fns.ts
@@ -63,7 +63,7 @@ import {
import { EXTERNAL_INFISICAL_SYNC_LIST_OPTION, ExternalInfisicalSyncFns } from "./external-infisical";
import { FLYIO_SYNC_LIST_OPTION, FlyioSyncFns } from "./flyio";
import { GCP_SYNC_LIST_OPTION } from "./gcp";
-import { GcpSyncFns } from "./gcp/gcp-sync-fns";
+import { gcpPreSaveTransformDestinationConfig, GcpSyncFns } from "./gcp/gcp-sync-fns";
import { GITLAB_SYNC_LIST_OPTION, GitLabSyncFns } from "./gitlab";
import { HASURA_CLOUD_SYNC_LIST_OPTION } from "./hasura-cloud/hasura-cloud-sync-constants";
import { HasuraCloudSyncFns } from "./hasura-cloud/hasura-cloud-sync-fns";
@@ -152,7 +152,8 @@ const PRE_SAVE_TRANSFORM_SYNC_OPTIONS_MAP: Partial<Record<SecretSync, TPreSaveTr
};
const PRE_SAVE_TRANSFORM_DESTINATION_CONFIG_MAP: Partial<Record<SecretSync, TPreSaveTransformDestinationConfigFn>> = {
- [SecretSync.AzureEntraIdScim]: azureEntraIdScimPreSaveTransformDestinationConfig
+ [SecretSync.AzureEntraIdScim]: azureEntraIdScimPreSaveTransformDestinationConfig,
+ [SecretSync.GCPSecretManager]: gcpPreSaveTransformDestinationConfig
};
export const preSaveTransformSyncOptions = async (
diff --git a/frontend/src/components/secret-syncs/forms/SecretSyncDestinationFields/GcpSyncFields.tsx b/frontend/src/components/secret-syncs/forms/SecretSyncDestinationFields/GcpSyncFields.tsx
index b0648a973b..32bfeb7f52 100644
--- a/frontend/src/components/secret-syncs/forms/SecretSyncDestinationFields/GcpSyncFields.tsx
+++ b/frontend/src/components/secret-syncs/forms/SecretSyncDestinationFields/GcpSyncFields.tsx
@@ -73,7 +73,7 @@ export const GcpSyncFields = () => {
shouldDirty: false
});
}
- }, [selectedScope, locationId, userReplicaLocationIds, setValue]);
+ }, []);
return (
<FieldGroup>
diff --git a/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/GcpSyncReviewFields.tsx b/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/GcpSyncReviewFields.tsx
index d848f95846..cb154e97ba 100644
--- a/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/GcpSyncReviewFields.tsx
+++ b/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/GcpSyncReviewFields.tsx
@@ -31,7 +31,9 @@ export const GcpSyncReviewFields = () => {
Boolean(destinationConfig.userReplicaLocationIds?.length) && (
<Detail>
<DetailLabel>Replica Regions</DetailLabel>
- <DetailValue>{destinationConfig.userReplicaLocationIds?.join(", ")}</DetailValue>
+ <DetailValue>
+ {destinationConfig.userReplicaLocationIds?.join(", ") ?? destinationConfig.locationId}
+ </DetailValue>
</Detail>
)}
</>
diff --git a/frontend/src/pages/secret-manager/IntegrationsListPage/components/SecretSyncsTab/SecretSyncTable/helpers/index.ts b/frontend/src/pages/secret-manager/IntegrationsListPage/components/SecretSyncsTab/SecretSyncTable/helpers/index.ts
index 2a31553ca6..f6cedfaa4d 100644
--- a/frontend/src/pages/secret-manager/IntegrationsListPage/components/SecretSyncsTab/SecretSyncTable/helpers/index.ts
+++ b/frontend/src/pages/secret-manager/IntegrationsListPage/components/SecretSyncsTab/SecretSyncTable/helpers/index.ts
@@ -54,9 +54,10 @@ export const getSecretSyncDestinationColValues = (secretSync: TSecretSync) => {
case SecretSync.GCPSecretManager:
primaryText = destinationConfig.projectId;
if (destinationConfig.scope === GcpSyncScope.Global) {
- secondaryText = destinationConfig.userReplicaLocationIds?.length
- ? `Global - ${destinationConfig.userReplicaLocationIds.join(", ")}`
- : "Global";
+ const regions = destinationConfig.userReplicaLocationIds?.length
+ ? destinationConfig.userReplicaLocationIds.join(", ")
+ : destinationConfig.locationId;
+ secondaryText = regions ? `Global - ${regions}` : "Global";
} else {
secondaryText = destinationConfig.locationId;
}