mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 00:27: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 lines = str.split("\n");
|
||||||
const parsed: { key: string; value: string }[] = [];
|
const parsed: { key: string; value: string }[] = [];
|
||||||
|
|
||||||
lines.forEach((line) => {
|
let i = 0;
|
||||||
const trimmed = line.trim();
|
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 equalIndex = trimmed.indexOf("=");
|
||||||
const key = trimmed.substring(0, equalIndex).trim();
|
const key = trimmed.substring(0, equalIndex).trim();
|
||||||
const valueRaw = trimmed.substring(equalIndex + 1).trim();
|
const valueRaw = trimmed.substring(equalIndex + 1).trim();
|
||||||
let value = valueRaw;
|
|
||||||
|
|
||||||
if ((value.startsWith(`"`) && value.endsWith(`"`)) || (value.startsWith(`'`) && value.endsWith(`'`))) {
|
// Check if value starts with a quote
|
||||||
value = value.slice(1, -1);
|
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;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
parsed.push({
|
i += 1;
|
||||||
key,
|
|
||||||
value
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
return parsed;
|
return parsed;
|
||||||
};
|
};
|
||||||
@@ -70,12 +108,22 @@ const getLaravelForgeSecrets = async (secretSync: TLaravelForgeSyncWithCredentia
|
|||||||
};
|
};
|
||||||
|
|
||||||
const buildEnvString = (secrets: LaravelForgeSecret[]) => {
|
const buildEnvString = (secrets: LaravelForgeSecret[]) => {
|
||||||
|
if (secrets.length === 0) {
|
||||||
|
return "# .env";
|
||||||
|
}
|
||||||
|
|
||||||
return secrets
|
return secrets
|
||||||
.map((secret) => {
|
.map((secret) => {
|
||||||
if (secret.value.includes(" ")) {
|
const { value } = secret;
|
||||||
return `${secret.key}="${secret.value}"`;
|
|
||||||
|
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");
|
.join("\n");
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -12,14 +12,11 @@ import { TSyncOptionsConfig } from "@app/services/secret-sync/secret-sync-types"
|
|||||||
|
|
||||||
const LaravelForgeSyncDestinationConfigSchema = z.object({
|
const LaravelForgeSyncDestinationConfigSchema = z.object({
|
||||||
orgSlug: z.string().min(1, "Org Slug is required").describe(SecretSyncs.DESTINATION_CONFIG.LARAVEL_FORGE.orgSlug),
|
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),
|
serverId: z.string().min(1, "Server ID is required").describe(SecretSyncs.DESTINATION_CONFIG.LARAVEL_FORGE.serverId),
|
||||||
serverName: z
|
serverName: z.string().optional().describe(SecretSyncs.DESTINATION_CONFIG.LARAVEL_FORGE.serverName),
|
||||||
.string()
|
|
||||||
.min(1, "Server Name is required")
|
|
||||||
.describe(SecretSyncs.DESTINATION_CONFIG.LARAVEL_FORGE.serverName),
|
|
||||||
siteId: z.string().min(1, "Site ID is required").describe(SecretSyncs.DESTINATION_CONFIG.LARAVEL_FORGE.siteId),
|
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 };
|
const LaravelForgeSyncOptionsConfig: TSyncOptionsConfig = { canImportSecrets: true };
|
||||||
|
|||||||
@@ -149,11 +149,8 @@ description: "Learn how to configure a Laravel Forge Sync for Infisical."
|
|||||||
"destination": "laravel-forge",
|
"destination": "laravel-forge",
|
||||||
"destinationConfig": {
|
"destinationConfig": {
|
||||||
"orgSlug": "org-abc123",
|
"orgSlug": "org-abc123",
|
||||||
"orgName": "org-name",
|
|
||||||
"serverId": "server-abc123",
|
"serverId": "server-abc123",
|
||||||
"serverName": "server-name",
|
|
||||||
"siteId": "site-abc123",
|
"siteId": "site-abc123",
|
||||||
"siteName": "site-name"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export const SecretSyncModalHeader = ({ destination, isConfigured }: Props) => {
|
|||||||
<img
|
<img
|
||||||
alt={`${destinationDetails.name} logo`}
|
alt={`${destinationDetails.name} logo`}
|
||||||
src={`/images/integrations/${destinationDetails.image}`}
|
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>
|
||||||
<div className="flex items-center text-mineshaft-300">
|
<div className="flex items-center text-mineshaft-300">
|
||||||
|
|||||||
@@ -63,7 +63,6 @@ export const APP_CONNECTION_MAP: Record<
|
|||||||
size?: number;
|
size?: number;
|
||||||
icon?: IconDefinition;
|
icon?: IconDefinition;
|
||||||
enterprise?: boolean;
|
enterprise?: boolean;
|
||||||
imageClassName?: string;
|
|
||||||
}
|
}
|
||||||
> = {
|
> = {
|
||||||
[AppConnection.AWS]: { name: "AWS", image: "Amazon Web Services.png" },
|
[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.Redis]: { name: "Redis", image: "Redis.png" },
|
||||||
[AppConnection.LaravelForge]: {
|
[AppConnection.LaravelForge]: {
|
||||||
name: "Laravel Forge",
|
name: "Laravel Forge",
|
||||||
image: "Laravel Forge.png",
|
image: "Laravel Forge.png"
|
||||||
imageClassName: "object-contain"
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -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 { HumanitecSyncScope } from "@app/hooks/api/secretSyncs/types/humanitec-sync";
|
||||||
import { RenderSyncScope } from "@app/hooks/api/secretSyncs/types/render-sync";
|
import { RenderSyncScope } from "@app/hooks/api/secretSyncs/types/render-sync";
|
||||||
|
|
||||||
export const SECRET_SYNC_MAP: Record<
|
export const SECRET_SYNC_MAP: Record<SecretSync, { name: string; image: string }> = {
|
||||||
SecretSync,
|
|
||||||
{ name: string; image: string; imageClassName?: string }
|
|
||||||
> = {
|
|
||||||
[SecretSync.AWSParameterStore]: { name: "AWS Parameter Store", image: "Amazon Web Services.png" },
|
[SecretSync.AWSParameterStore]: { name: "AWS Parameter Store", image: "Amazon Web Services.png" },
|
||||||
[SecretSync.AWSSecretsManager]: { name: "AWS Secrets Manager", image: "Amazon Web Services.png" },
|
[SecretSync.AWSSecretsManager]: { name: "AWS Secrets Manager", image: "Amazon Web Services.png" },
|
||||||
[SecretSync.GitHub]: { name: "GitHub", image: "GitHub.png" },
|
[SecretSync.GitHub]: { name: "GitHub", image: "GitHub.png" },
|
||||||
@@ -119,8 +116,7 @@ export const SECRET_SYNC_MAP: Record<
|
|||||||
},
|
},
|
||||||
[SecretSync.LaravelForge]: {
|
[SecretSync.LaravelForge]: {
|
||||||
name: "Laravel Forge",
|
name: "Laravel Forge",
|
||||||
image: "Laravel Forge.png",
|
image: "Laravel Forge.png"
|
||||||
imageClassName: "object-contain"
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -19,7 +19,7 @@ export const AppConnectionHeader = ({ app, isConnected, onBack }: Props) => {
|
|||||||
<img
|
<img
|
||||||
alt={`${appDetails.name} logo`}
|
alt={`${appDetails.name} logo`}
|
||||||
src={`/images/integrations/${appDetails.image}`}
|
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 && (
|
{appDetails.icon && (
|
||||||
<FontAwesomeIcon
|
<FontAwesomeIcon
|
||||||
|
|||||||
Reference in New Issue
Block a user