Skip to content

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

use enum

Matheus Nogueira9aa3379a9ef8
diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/shared/SqlCredentialsRotationParametersFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/shared/SqlCredentialsRotationParametersFields.tsx
index cb3bb1ebe9..54b83d1c77 100644
--- a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/shared/SqlCredentialsRotationParametersFields.tsx
+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/shared/SqlCredentialsRotationParametersFields.tsx
@@ -10,7 +10,7 @@ import { useTimedReset } from "@app/hooks";
import { AppConnection } from "@app/hooks/api/appConnections/enums";
import { SecretRotation, useSecretRotationV2Option } from "@app/hooks/api/secretRotationsV2";
import {
- SecretRotationRuleProvider,
+ SECRET_ROTATION_TO_RULE_PROVIDER,
SecretValidationRuleType
} from "@app/hooks/api/secretValidationRules";
@@ -155,34 +155,10 @@ export const SqlCredentialsRotationParametersFields = () => {
)}
/>
<div className="flex flex-col gap-3">
- {type === SecretRotation.PostgresCredentials && (
+ {SECRET_ROTATION_TO_RULE_PROVIDER[type] && (
<ValidationRuleOverrideNotice
type={SecretValidationRuleType.SecretRotations}
- provider={SecretRotationRuleProvider.PostgresCredentials}
- environmentSlug={environmentSlug}
- secretPath={secretPath}
- />
- )}
- {type === SecretRotation.MySqlCredentials && (
- <ValidationRuleOverrideNotice
- type={SecretValidationRuleType.SecretRotations}
- provider={SecretRotationRuleProvider.MySqlCredentials}
- environmentSlug={environmentSlug}
- secretPath={secretPath}
- />
- )}
- {type === SecretRotation.MsSqlCredentials && (
- <ValidationRuleOverrideNotice
- type={SecretValidationRuleType.SecretRotations}
- provider={SecretRotationRuleProvider.MsSqlCredentials}
- environmentSlug={environmentSlug}
- secretPath={secretPath}
- />
- )}
- {type === SecretRotation.OracleDBCredentials && (
- <ValidationRuleOverrideNotice
- type={SecretValidationRuleType.SecretRotations}
- provider={SecretRotationRuleProvider.OracleDBCredentials}
+ provider={SECRET_ROTATION_TO_RULE_PROVIDER[type]}
environmentSlug={environmentSlug}
secretPath={secretPath}
/>
diff --git a/frontend/src/hooks/api/secretValidationRules/index.ts b/frontend/src/hooks/api/secretValidationRules/index.ts
index d0cee27f3e..509b4d405a 100644
--- a/frontend/src/hooks/api/secretValidationRules/index.ts
+++ b/frontend/src/hooks/api/secretValidationRules/index.ts
@@ -15,6 +15,7 @@ export {
ConstraintTarget,
ConstraintType,
DynamicSecretRuleProvider,
+ SECRET_ROTATION_TO_RULE_PROVIDER,
SecretRotationRuleProvider,
SecretValidationRuleType
} from "./types";
diff --git a/frontend/src/hooks/api/secretValidationRules/types.ts b/frontend/src/hooks/api/secretValidationRules/types.ts
index 0273641b11..8a3b70c5aa 100644
--- a/frontend/src/hooks/api/secretValidationRules/types.ts
+++ b/frontend/src/hooks/api/secretValidationRules/types.ts
@@ -1,3 +1,5 @@
+import { SecretRotation } from "@app/hooks/api/secretRotationsV2";
+
export enum SecretValidationRuleType {
StaticSecrets = "static-secrets",
DynamicSecrets = "dynamic-secrets",
@@ -37,6 +39,19 @@ export enum SecretRotationRuleProvider {
LdapPassword = "ldap-password"
}
+// Maps SecretRotation types to their corresponding validation rule provider.
+// Used by rotation forms to look up the correct provider for ValidationRuleOverrideNotice.
+export const SECRET_ROTATION_TO_RULE_PROVIDER: Partial<
+ Record<SecretRotation, SecretRotationRuleProvider>
+> = {
+ [SecretRotation.PostgresCredentials]: SecretRotationRuleProvider.PostgresCredentials,
+ [SecretRotation.MySqlCredentials]: SecretRotationRuleProvider.MySqlCredentials,
+ [SecretRotation.MsSqlCredentials]: SecretRotationRuleProvider.MsSqlCredentials,
+ [SecretRotation.OracleDBCredentials]: SecretRotationRuleProvider.OracleDBCredentials,
+ [SecretRotation.UnixLinuxLocalAccount]: SecretRotationRuleProvider.UnixLinuxLocalAccount,
+ [SecretRotation.LdapPassword]: SecretRotationRuleProvider.LdapPassword
+};
+
export type TConstraint = {
type: ConstraintType;
appliesTo: ConstraintTarget;