feat: ssh keys filesystel

This commit is contained in:
Lorenzo Migliorero
2024-07-25 20:16:49 +02:00
parent d243470029
commit 1f81ebd4fe
6 changed files with 56 additions and 26 deletions

View File

@@ -11,12 +11,12 @@ export const cloneGitRepository = async (
appName: string;
customGitUrl?: string | null;
customGitBranch?: string | null;
customGitSSHKey?: string | null;
customGitSSHKeyId?: string | null;
},
logPath: string,
isCompose = false,
) => {
const { appName, customGitUrl, customGitBranch, customGitSSHKey } = entity;
const { appName, customGitUrl, customGitBranch, customGitSSHKeyId } = entity;
if (!customGitUrl || !customGitBranch) {
throw new TRPCError({
@@ -26,7 +26,7 @@ export const cloneGitRepository = async (
}
const writeStream = createWriteStream(logPath, { flags: "a" });
const keyPath = path.join(SSH_PATH, `${appName}_rsa`);
const keyPath = path.join(SSH_PATH, `${customGitSSHKeyId}_rsa`);
const basePath = isCompose ? COMPOSE_PATH : APPLICATIONS_PATH;
const outputPath = join(basePath, appName, "code");
const knownHostsPath = path.join(SSH_PATH, "known_hosts");
@@ -39,7 +39,7 @@ export const cloneGitRepository = async (
writeStream.write(
`\nCloning Repo Custom ${customGitUrl} to ${outputPath}: ✅\n`,
);
console.log(customGitSSHKeyId);
await spawnAsync(
"git",
[
@@ -60,7 +60,7 @@ export const cloneGitRepository = async (
{
env: {
...process.env,
...(customGitSSHKey && {
...(customGitSSHKeyId && {
GIT_SSH_COMMAND: `ssh -i ${keyPath} -o UserKnownHostsFile=${knownHostsPath}`,
}),
},