mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
fix: review comments
This commit is contained in:
@@ -29,27 +29,65 @@ const parseEnv = (str: string) => {
|
||||
const lines = str.split("\n");
|
||||
const parsed: { key: string; value: string }[] = [];
|
||||
|
||||
lines.forEach((line) => {
|
||||
const trimmed = line.trim();
|
||||
let i = 0;
|
||||
while (i < lines.length) {
|
||||
const trimmed = lines[i].trim();
|
||||
|
||||
const isInvalidLine = trimmed === "" || trimmed.startsWith("#");
|
||||
// Skip empty lines and comments
|
||||
if (trimmed === "" || trimmed.startsWith("#")) {
|
||||
i += 1;
|
||||
// eslint-disable-next-line no-continue
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isInvalidLine && trimmed.includes("=")) {
|
||||
if (trimmed.includes("=")) {
|
||||
const equalIndex = trimmed.indexOf("=");
|
||||
const key = trimmed.substring(0, equalIndex).trim();
|
||||
const valueRaw = trimmed.substring(equalIndex + 1).trim();
|
||||
let value = valueRaw;
|
||||
|
||||
if ((value.startsWith(`"`) && value.endsWith(`"`)) || (value.startsWith(`'`) && value.endsWith(`'`))) {
|
||||
value = value.slice(1, -1);
|
||||
// Check if value starts with a quote
|
||||
const startsWithDoubleQuote = valueRaw.startsWith('"');
|
||||
const startsWithSingleQuote = valueRaw.startsWith("'");
|
||||
|
||||
if (startsWithDoubleQuote || startsWithSingleQuote) {
|
||||
const quoteChar = startsWithDoubleQuote ? '"' : "'";
|
||||
|
||||
const closingQuoteIndex = valueRaw.indexOf(quoteChar, 1);
|
||||
|
||||
if (closingQuoteIndex !== -1) {
|
||||
// Single-line quoted value
|
||||
const value = valueRaw.slice(1, closingQuoteIndex);
|
||||
parsed.push({ key, value });
|
||||
i += 1;
|
||||
} else {
|
||||
// Multiline quoted value - collect lines until closing quote
|
||||
let value = valueRaw.slice(1);
|
||||
i += 1;
|
||||
|
||||
while (i < lines.length) {
|
||||
const nextLine = lines[i];
|
||||
const closingIndex = nextLine.indexOf(quoteChar);
|
||||
|
||||
if (closingIndex !== -1) {
|
||||
value += `\n${nextLine.substring(0, closingIndex)}`;
|
||||
parsed.push({ key, value });
|
||||
i += 1;
|
||||
break;
|
||||
} else {
|
||||
value += `\n${nextLine}`;
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Unquoted value
|
||||
parsed.push({ key, value: valueRaw });
|
||||
i += 1;
|
||||
}
|
||||
|
||||
parsed.push({
|
||||
key,
|
||||
value
|
||||
});
|
||||
} else {
|
||||
i += 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return parsed;
|
||||
};
|
||||
@@ -70,12 +108,22 @@ const getLaravelForgeSecrets = async (secretSync: TLaravelForgeSyncWithCredentia
|
||||
};
|
||||
|
||||
const buildEnvString = (secrets: LaravelForgeSecret[]) => {
|
||||
if (secrets.length === 0) {
|
||||
return "# .env";
|
||||
}
|
||||
|
||||
return secrets
|
||||
.map((secret) => {
|
||||
if (secret.value.includes(" ")) {
|
||||
return `${secret.key}="${secret.value}"`;
|
||||
const { value } = secret;
|
||||
|
||||
if (value.includes(`"`)) {
|
||||
return `${secret.key}='${value}'`;
|
||||
}
|
||||
return `${secret.key}=${secret.value}`;
|
||||
|
||||
if (value.includes(" ") || value.includes("\n") || value.includes(`'`)) {
|
||||
return `${secret.key}="${value}"`;
|
||||
}
|
||||
return `${secret.key}=${value}`;
|
||||
})
|
||||
.join("\n");
|
||||
};
|
||||
|
||||
@@ -12,14 +12,11 @@ import { TSyncOptionsConfig } from "@app/services/secret-sync/secret-sync-types"
|
||||
|
||||
const LaravelForgeSyncDestinationConfigSchema = z.object({
|
||||
orgSlug: z.string().min(1, "Org Slug is required").describe(SecretSyncs.DESTINATION_CONFIG.LARAVEL_FORGE.orgSlug),
|
||||
orgName: z.string().min(1, "Org Name is required").describe(SecretSyncs.DESTINATION_CONFIG.LARAVEL_FORGE.orgName),
|
||||
orgName: z.string().optional().describe(SecretSyncs.DESTINATION_CONFIG.LARAVEL_FORGE.orgName),
|
||||
serverId: z.string().min(1, "Server ID is required").describe(SecretSyncs.DESTINATION_CONFIG.LARAVEL_FORGE.serverId),
|
||||
serverName: z
|
||||
.string()
|
||||
.min(1, "Server Name is required")
|
||||
.describe(SecretSyncs.DESTINATION_CONFIG.LARAVEL_FORGE.serverName),
|
||||
serverName: z.string().optional().describe(SecretSyncs.DESTINATION_CONFIG.LARAVEL_FORGE.serverName),
|
||||
siteId: z.string().min(1, "Site ID is required").describe(SecretSyncs.DESTINATION_CONFIG.LARAVEL_FORGE.siteId),
|
||||
siteName: z.string().min(1, "Site Name is required").describe(SecretSyncs.DESTINATION_CONFIG.LARAVEL_FORGE.siteName)
|
||||
siteName: z.string().optional().describe(SecretSyncs.DESTINATION_CONFIG.LARAVEL_FORGE.siteName)
|
||||
});
|
||||
|
||||
const LaravelForgeSyncOptionsConfig: TSyncOptionsConfig = { canImportSecrets: true };
|
||||
|
||||
@@ -149,11 +149,8 @@ description: "Learn how to configure a Laravel Forge Sync for Infisical."
|
||||
"destination": "laravel-forge",
|
||||
"destinationConfig": {
|
||||
"orgSlug": "org-abc123",
|
||||
"orgName": "org-name",
|
||||
"serverId": "server-abc123",
|
||||
"serverName": "server-name",
|
||||
"siteId": "site-abc123",
|
||||
"siteName": "site-name"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ export const SecretSyncModalHeader = ({ destination, isConfigured }: Props) => {
|
||||
<img
|
||||
alt={`${destinationDetails.name} logo`}
|
||||
src={`/images/integrations/${destinationDetails.image}`}
|
||||
className={`h-12 w-12 rounded-md bg-bunker-500 p-2 ${destinationDetails.imageClassName}`}
|
||||
className="h-12 w-12 rounded-md bg-bunker-500 object-contain p-2"
|
||||
/>
|
||||
<div>
|
||||
<div className="flex items-center text-mineshaft-300">
|
||||
|
||||
@@ -63,7 +63,6 @@ export const APP_CONNECTION_MAP: Record<
|
||||
size?: number;
|
||||
icon?: IconDefinition;
|
||||
enterprise?: boolean;
|
||||
imageClassName?: string;
|
||||
}
|
||||
> = {
|
||||
[AppConnection.AWS]: { name: "AWS", image: "Amazon Web Services.png" },
|
||||
@@ -126,8 +125,7 @@ export const APP_CONNECTION_MAP: Record<
|
||||
[AppConnection.Redis]: { name: "Redis", image: "Redis.png" },
|
||||
[AppConnection.LaravelForge]: {
|
||||
name: "Laravel Forge",
|
||||
image: "Laravel Forge.png",
|
||||
imageClassName: "object-contain"
|
||||
image: "Laravel Forge.png"
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -8,10 +8,7 @@ import { GcpSyncScope } from "@app/hooks/api/secretSyncs/types/gcp-sync";
|
||||
import { HumanitecSyncScope } from "@app/hooks/api/secretSyncs/types/humanitec-sync";
|
||||
import { RenderSyncScope } from "@app/hooks/api/secretSyncs/types/render-sync";
|
||||
|
||||
export const SECRET_SYNC_MAP: Record<
|
||||
SecretSync,
|
||||
{ name: string; image: string; imageClassName?: string }
|
||||
> = {
|
||||
export const SECRET_SYNC_MAP: Record<SecretSync, { name: string; image: string }> = {
|
||||
[SecretSync.AWSParameterStore]: { name: "AWS Parameter Store", image: "Amazon Web Services.png" },
|
||||
[SecretSync.AWSSecretsManager]: { name: "AWS Secrets Manager", image: "Amazon Web Services.png" },
|
||||
[SecretSync.GitHub]: { name: "GitHub", image: "GitHub.png" },
|
||||
@@ -119,8 +116,7 @@ export const SECRET_SYNC_MAP: Record<
|
||||
},
|
||||
[SecretSync.LaravelForge]: {
|
||||
name: "Laravel Forge",
|
||||
image: "Laravel Forge.png",
|
||||
imageClassName: "object-contain"
|
||||
image: "Laravel Forge.png"
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ export const AppConnectionHeader = ({ app, isConnected, onBack }: Props) => {
|
||||
<img
|
||||
alt={`${appDetails.name} logo`}
|
||||
src={`/images/integrations/${appDetails.image}`}
|
||||
className={`h-12 w-12 rounded-md bg-bunker-500 p-2 ${appDetails.imageClassName}`}
|
||||
className="h-12 w-12 rounded-md bg-bunker-500 object-contain p-2"
|
||||
/>
|
||||
{appDetails.icon && (
|
||||
<FontAwesomeIcon
|
||||
|
||||
Reference in New Issue
Block a user