Patch sync Laravel Forge integration

This commit is contained in:
Tuan Dang
2023-07-05 23:40:43 +07:00
parent 732d0dfdca
commit 4e6fae03ff
5 changed files with 27 additions and 13 deletions

View File

@@ -1167,12 +1167,20 @@ const syncSecretsLaravelForge = async ({
accessId: string | null; accessId: string | null;
accessToken: string; accessToken: string;
}) => { }) => {
function transformObjectToString(obj: any) {
let result = "";
for (const key in obj) {
result += `${key}=${obj[key]}\n`;
}
return result;
}
await standardRequest.put( await standardRequest.put(
`${INTEGRATION_LARAVELFORGE_API_URL}/api/v1/servers/${accessId}/sites/${integration.appId}/env`, `${INTEGRATION_LARAVELFORGE_API_URL}/api/v1/servers/${accessId}/sites/${integration.appId}/env`,
Object.keys(secrets).map((key) => ({ {
key, content: transformObjectToString(secrets),
value: secrets[key], },
})),
{ {
headers: { headers: {
Authorization: `Bearer ${accessToken}`, Authorization: `Bearer ${accessToken}`,
@@ -1890,7 +1898,7 @@ const syncSecretsCloudflarePages = async ({
} }
) )
) )
.data.result['deployment_configs'][integration.targetEnvironment]['env_vars']; .data.result["deployment_configs"][integration.targetEnvironment]["env_vars"];
// copy the secrets object, so we can set deleted keys to null // copy the secrets object, so we can set deleted keys to null
const secretsObj: any = {...secrets}; const secretsObj: any = {...secrets};

View File

@@ -19,13 +19,13 @@ import {
INTEGRATION_RENDER, INTEGRATION_RENDER,
INTEGRATION_SUPABASE, INTEGRATION_SUPABASE,
INTEGRATION_TRAVISCI, INTEGRATION_TRAVISCI,
INTEGRATION_VERCEL, INTEGRATION_VERCEL
} from "../variables"; } from "../variables";
export interface IIntegrationAuth extends Document { export interface IIntegrationAuth extends Document {
_id: Types.ObjectId; _id: Types.ObjectId;
workspace: Types.ObjectId; workspace: Types.ObjectId;
integration: 'heroku' | 'vercel' | 'netlify' | 'github' | 'gitlab' | 'render' | 'railway' | 'flyio' | 'azure-key-vault' | 'laravel-forge' | 'circleci' | 'travisci' | 'supabase' | 'aws-parameter-store' | 'aws-secret-manager' | 'checkly' | 'cloudflare-pages'; integration: "heroku" | "vercel" | "netlify" | "github" | "gitlab" | "render" | "railway" | "flyio" | "azure-key-vault" | "laravel-forge" | "circleci" | "travisci" | "supabase" | "aws-parameter-store" | "aws-secret-manager" | "checkly" | "cloudflare-pages";
teamId: string; teamId: string;
accountId: string; accountId: string;
url: string; url: string;

View File

@@ -17,9 +17,13 @@ export default function LaravelForgeCreateIntegrationPage() {
setApiKeyErrorText(""); setApiKeyErrorText("");
setServerIdErrorText(""); setServerIdErrorText("");
if (apiKey.length === 0 || serverId.length === 0) { if (apiKey.length === 0) {
if (apiKey.length === 0) setApiKeyErrorText("Access Token cannot be blank"); setApiKeyErrorText("Access Token cannot be blank");
if (serverId.length === 0) setServerIdErrorText("Server Id cannot be blank"); return;
}
if (serverId.length === 0) {
setServerIdErrorText("Server Id cannot be blank");
return; return;
} }
@@ -54,11 +58,11 @@ export default function LaravelForgeCreateIntegrationPage() {
<Input placeholder="Access Token" value={apiKey} onChange={(e) => setApiKey(e.target.value)} /> <Input placeholder="Access Token" value={apiKey} onChange={(e) => setApiKey(e.target.value)} />
</FormControl> </FormControl>
<FormControl <FormControl
label="Laravel Forge Server Id" label="Laravel Forge Server ID"
errorText={serverIdErrorText} errorText={serverIdErrorText}
isError={serverIdErrorText !== "" ?? false} isError={serverIdErrorText !== "" ?? false}
> >
<Input placeholder="Server Id" value={serverId} onChange={(e) => setServerId(e.target.value)} /> <Input placeholder="123456" value={serverId} onChange={(e) => setServerId(e.target.value)} />
</FormControl> </FormControl>
<Button <Button
onClick={handleButtonClick} onClick={handleButtonClick}

View File

@@ -1,3 +1,4 @@
import { ChangeLanguageSection } from "../ChangeLanguageSection";
import { ChangePasswordSection } from "../ChangePasswordSection"; import { ChangePasswordSection } from "../ChangePasswordSection";
import { EmergencyKitSection } from "../EmergencyKitSection"; import { EmergencyKitSection } from "../EmergencyKitSection";
import { SecuritySection } from "../SecuritySection"; import { SecuritySection } from "../SecuritySection";
@@ -6,6 +7,7 @@ import { SessionsSection } from "../SessionsSection";
export const PersonalSecurityTab = () => { export const PersonalSecurityTab = () => {
return ( return (
<div> <div>
<ChangeLanguageSection />
<SecuritySection /> <SecuritySection />
<SessionsSection /> <SessionsSection />
<ChangePasswordSection /> <ChangePasswordSection />

View File

@@ -5,7 +5,7 @@ import { PersonalAPIKeyTab } from "../PersonalAPIKeyTab";
import { PersonalSecurityTab } from "../PersonalSecurityTab"; import { PersonalSecurityTab } from "../PersonalSecurityTab";
const tabs = [ const tabs = [
{ name: "Security", key: "tab-account-security" }, { name: "General", key: "tab-account-security" },
{ name: "API Keys", key: "tab-account-api-keys" } { name: "API Keys", key: "tab-account-api-keys" }
]; ];