fix: secrets with newline

This commit is contained in:
Andras Bacsai 2022-12-19 21:48:31 +01:00
parent 88f3f628ef
commit 29530f3b17
15 changed files with 199 additions and 7 deletions

View File

@ -148,15 +148,27 @@ import * as buildpacks from '../lib/buildPacks';
(s) => s.name === secret.name && s.isPRMRSecret
);
if (isSecretFound.length > 0) {
if (isSecretFound[0].value.includes('\\n')) {
envs.push(`${secret.name}=${isSecretFound[0].value}`);
} else {
envs.push(`${secret.name}='${isSecretFound[0].value}'`);
}
} else {
if (secret.value.includes('\\n')) {
envs.push(`${secret.name}=${secret.value}`);
} else {
envs.push(`${secret.name}='${secret.value}'`);
}
}
} else {
if (!secret.isPRMRSecret) {
if (secret.value.includes('\\n')) {
envs.push(`${secret.name}=${secret.value}`);
} else {
envs.push(`${secret.name}='${secret.value}'`);
}
}
}
}
}
});
}
await fs.writeFile(`${workdir}/.env`, envs.join('\n'));
@ -706,13 +718,25 @@ import * as buildpacks from '../lib/buildPacks';
(s) => s.name === secret.name && s.isPRMRSecret
);
if (isSecretFound.length > 0) {
if (isSecretFound[0].value.includes('\\n')) {
envs.push(`${secret.name}=${isSecretFound[0].value}`);
} else {
envs.push(`${secret.name}='${isSecretFound[0].value}'`);
}
} else {
if (secret.value.includes('\\n')) {
envs.push(`${secret.name}=${secret.value}`);
} else {
envs.push(`${secret.name}='${secret.value}'`);
}
}
} else {
if (!secret.isPRMRSecret) {
if (secret.value.includes('\\n')) {
envs.push(`${secret.name}=${secret.value}`);
} else {
envs.push(`${secret.name}='${secret.value}'`);
}
}
}
});

View File

@ -792,13 +792,25 @@ export async function buildCacheImageWithNode(data, imageForBuild) {
if (pullmergeRequestId) {
const isSecretFound = secrets.filter((s) => s.name === secret.name && s.isPRMRSecret);
if (isSecretFound.length > 0) {
if (isSecretFound[0].value.includes('\\n')) {
Dockerfile.push(`ARG ${secret.name}=${isSecretFound[0].value}`);
} else {
Dockerfile.push(`ARG ${secret.name}='${isSecretFound[0].value}'`);
}
} else {
if (secret.value.includes('\\n')) {
Dockerfile.push(`ARG ${secret.name}=${secret.value}`);
} else {
Dockerfile.push(`ARG ${secret.name}='${secret.value}'`);
}
}
} else {
if (!secret.isPRMRSecret) {
if (secret.value.includes('\\n')) {
Dockerfile.push(`ARG ${secret.name}=${secret.value}`);
} else {
Dockerfile.push(`ARG ${secret.name}='${secret.value}'`);
}
}
}
}
@ -828,15 +840,28 @@ export async function buildCacheImageForLaravel(data, imageForBuild) {
secrets.forEach((secret) => {
if (secret.isBuildSecret) {
if (pullmergeRequestId) {
const isSecretFound = secrets.filter((s) => s.name === secret.name && s.isPRMRSecret);
const isSecretFound = secrets.filter(s => s.name === secret.name && s.isPRMRSecret)
if (isSecretFound.length > 0) {
if (isSecretFound[0].value.includes('\\n')) {
Dockerfile.push(`ARG ${secret.name}=${isSecretFound[0].value}`);
} else {
Dockerfile.push(`ARG ${secret.name}='${isSecretFound[0].value}'`);
}
} else {
if (secret.value.includes('\\n')) {
Dockerfile.push(`ARG ${secret.name}=${secret.value}`);
} else {
Dockerfile.push(`ARG ${secret.name}='${secret.value}'`);
}
}
} else {
if (!secret.isPRMRSecret) {
if (secret.value.includes('\\n')) {
Dockerfile.push(`ARG ${secret.name}=${secret.value}`);
} else {
Dockerfile.push(`ARG ${secret.name}='${secret.value}'`);
}
}
}
}

View File

@ -31,13 +31,25 @@ export default async function (data) {
if (pullmergeRequestId) {
const isSecretFound = secrets.filter((s) => s.name === secret.name && s.isPRMRSecret);
if (isSecretFound.length > 0) {
if (isSecretFound[0].value.includes('\\n')) {
envs.push(`${secret.name}='${isSecretFound[0].value}'`);
} else {
envs.push(`${secret.name}=${isSecretFound[0].value}`);
}
} else {
if (secret.value.includes('\\n')) {
envs.push(`${secret.name}=${secret.value}`);
} else {
envs.push(`${secret.name}='${secret.value}'`);
}
}
} else {
if (!secret.isPRMRSecret) {
if (secret.value.includes('\\n')) {
envs.push(`${secret.name}=${secret.value}`);
} else {
envs.push(`${secret.name}='${secret.value}'`);
}
}
}
});

View File

@ -29,13 +29,26 @@ const createDockerfile = async (data, image): Promise<void> => {
if (pullmergeRequestId) {
const isSecretFound = secrets.filter(s => s.name === secret.name && s.isPRMRSecret)
if (isSecretFound.length > 0) {
if (isSecretFound[0].value.includes('\\n')) {
Dockerfile.push(`ARG ${secret.name}=${isSecretFound[0].value}`);
} else {
Dockerfile.push(`ARG ${secret.name}='${isSecretFound[0].value}'`);
}
} else {
if (secret.value.includes('\\n')) {
Dockerfile.push(`ARG ${secret.name}=${secret.value}`);
} else {
Dockerfile.push(`ARG ${secret.name}='${secret.value}'`);
}
}
} else {
if (!secret.isPRMRSecret) {
if (secret.value.includes('\\n')) {
Dockerfile.push(`ARG ${secret.name}=${secret.value}`);
} else {
Dockerfile.push(`ARG ${secret.name}='${secret.value}'`);
}
}
}
}

View File

@ -21,7 +21,11 @@ export default async function (data) {
) {
Dockerfile.forEach((line, index) => {
if (line.startsWith('FROM')) {
if (secret.value.includes('\\n')) {
Dockerfile.splice(index + 1, 0, `ARG ${secret.name}=${secret.value}`);
} else {
Dockerfile.splice(index + 1, 0, `ARG ${secret.name}='${secret.value}'`);
}
}
});
}

View File

@ -29,13 +29,25 @@ const createDockerfile = async (data, image): Promise<void> => {
if (pullmergeRequestId) {
const isSecretFound = secrets.filter(s => s.name === secret.name && s.isPRMRSecret)
if (isSecretFound.length > 0) {
if (isSecretFound[0].value.includes('\\n')) {
Dockerfile.push(`ARG ${secret.name}=${isSecretFound[0].value}`);
} else {
Dockerfile.push(`ARG ${secret.name}='${isSecretFound[0].value}'`);
}
} else {
if (secrets.value.includes('\\n')) {
Dockerfile.push(`ARG ${secret.name}=${secret.value}`);
} else {
Dockerfile.push(`ARG ${secret.name}='${secret.value}'`);
}
}
} else {
if (!secret.isPRMRSecret) {
if (secrets.value.includes('\\n')) {
Dockerfile.push(`ARG ${secret.name}=${secret.value}`);
} else {
Dockerfile.push(`ARG ${secret.name}='${secret.value}'`);
}
}
}
}

View File

@ -23,15 +23,28 @@ const createDockerfile = async (data, image): Promise<void> => {
secrets.forEach((secret) => {
if (secret.isBuildSecret) {
if (pullmergeRequestId) {
const isSecretFound = secrets.filter((s) => s.name === secret.name && s.isPRMRSecret);
const isSecretFound = secrets.filter(s => s.name === secret.name && s.isPRMRSecret)
if (isSecretFound.length > 0) {
if (isSecretFound[0].value.includes('\\n')) {
Dockerfile.push(`ARG ${secret.name}=${isSecretFound[0].value}`);
} else {
Dockerfile.push(`ARG ${secret.name}='${isSecretFound[0].value}'`);
}
} else {
if (secret.value.includes('\\n')) {
Dockerfile.push(`ARG ${secret.name}=${secret.value}`);
} else {
Dockerfile.push(`ARG ${secret.name}='${secret.value}'`);
}
}
} else {
if (!secret.isPRMRSecret) {
if (secret.value.includes('\\n')) {
Dockerfile.push(`ARG ${secret.name}=${secret.value}`);
} else {
Dockerfile.push(`ARG ${secret.name}='${secret.value}'`);
}
}
}
}

View File

@ -29,13 +29,26 @@ const createDockerfile = async (data, image): Promise<void> => {
if (pullmergeRequestId) {
const isSecretFound = secrets.filter(s => s.name === secret.name && s.isPRMRSecret)
if (isSecretFound.length > 0) {
if (isSecretFound[0].value.includes('\\n')) {
Dockerfile.push(`ARG ${secret.name}=${isSecretFound[0].value}`);
} else {
Dockerfile.push(`ARG ${secret.name}='${isSecretFound[0].value}'`);
}
} else {
if (secret.value.includes('\\n')) {
Dockerfile.push(`ARG ${secret.name}=${secret.value}`);
} else {
Dockerfile.push(`ARG ${secret.name}='${secret.value}'`);
}
}
} else {
if (!secret.isPRMRSecret) {
if (secret.value.includes('\\n')) {
Dockerfile.push(`ARG ${secret.name}=${secret.value}`);
} else {
Dockerfile.push(`ARG ${secret.name}='${secret.value}'`);
}
}
}
}

View File

@ -18,13 +18,26 @@ const createDockerfile = async (data, image, htaccessFound): Promise<void> => {
if (pullmergeRequestId) {
const isSecretFound = secrets.filter(s => s.name === secret.name && s.isPRMRSecret)
if (isSecretFound.length > 0) {
if (isSecretFound[0].value.includes('\\n')) {
Dockerfile.push(`ARG ${secret.name}=${isSecretFound[0].value}`);
} else {
Dockerfile.push(`ARG ${secret.name}='${isSecretFound[0].value}'`);
}
} else {
if (secret.value.includes('\\n')) {
Dockerfile.push(`ARG ${secret.name}=${secret.value}`);
} else {
Dockerfile.push(`ARG ${secret.name}='${secret.value}'`);
}
}
} else {
if (!secret.isPRMRSecret) {
if (secret.value.includes('\\n')) {
Dockerfile.push(`ARG ${secret.name}=${secret.value}`);
} else {
Dockerfile.push(`ARG ${secret.name}='${secret.value}'`);
}
}
}
}

View File

@ -23,13 +23,26 @@ const createDockerfile = async (data, image): Promise<void> => {
if (pullmergeRequestId) {
const isSecretFound = secrets.filter(s => s.name === secret.name && s.isPRMRSecret)
if (isSecretFound.length > 0) {
if (isSecretFound[0].value.includes('\\n')) {
Dockerfile.push(`ARG ${secret.name}=${isSecretFound[0].value}`);
} else {
Dockerfile.push(`ARG ${secret.name}='${isSecretFound[0].value}'`);
}
} else {
if (secret.value.includes('\\n')) {
Dockerfile.push(`ARG ${secret.name}=${secret.value}`);
} else {
Dockerfile.push(`ARG ${secret.name}='${secret.value}'`);
}
}
} else {
if (!secret.isPRMRSecret) {
if (secret.value.includes('\\n')) {
Dockerfile.push(`ARG ${secret.name}=${secret.value}`);
} else {
Dockerfile.push(`ARG ${secret.name}='${secret.value}'`);
}
}
}
}

View File

@ -30,13 +30,26 @@ const createDockerfile = async (data, image): Promise<void> => {
if (pullmergeRequestId) {
const isSecretFound = secrets.filter(s => s.name === secret.name && s.isPRMRSecret)
if (isSecretFound.length > 0) {
if (isSecretFound[0].value.includes('\\n')) {
Dockerfile.push(`ARG ${secret.name}=${isSecretFound[0].value}`);
} else {
Dockerfile.push(`ARG ${secret.name}='${isSecretFound[0].value}'`);
}
} else {
if (secret.value.includes('\\n')) {
Dockerfile.push(`ARG ${secret.name}=${secret.value}`);
} else {
Dockerfile.push(`ARG ${secret.name}='${secret.value}'`);
}
}
} else {
if (!secret.isPRMRSecret) {
if (secret.value.includes('\\n')) {
Dockerfile.push(`ARG ${secret.name}=${secret.value}`);
} else {
Dockerfile.push(`ARG ${secret.name}='${secret.value}'`);
}
}
}
}

View File

@ -19,7 +19,7 @@ import { saveBuildLog, saveDockerRegistryCredentials } from './buildPacks/common
import { scheduler } from './scheduler';
import type { ExecaChildProcess } from 'execa';
export const version = '3.12.2';
export const version = '3.12.3';
export const isDev = process.env.NODE_ENV === 'development';
export const sentryDSN =
'https://409f09bcb7af47928d3e0f46b78987f3@o1082494.ingest.sentry.io/4504236622217216';

View File

@ -468,13 +468,26 @@ export async function restartApplication(request: FastifyRequest<RestartApplicat
if (pullmergeRequestId) {
const isSecretFound = secrets.filter(s => s.name === secret.name && s.isPRMRSecret)
if (isSecretFound.length > 0) {
if (isSecretFound[0].value.includes('\\n')) {
envs.push(`${secret.name}=${isSecretFound[0].value}`);
} else {
envs.push(`${secret.name}='${isSecretFound[0].value}'`);
}
} else {
if (secret.value.includes('\\n')) {
envs.push(`${secret.name}=${secret.value}`);
} else {
envs.push(`${secret.name}='${secret.value}'`);
}
}
} else {
if (!secret.isPRMRSecret) {
if (secret.value.includes('\\n')) {
envs.push(`${secret.name}=${secret.value}`);
} else {
envs.push(`${secret.name}='${secret.value}'`);
}
}
}
});
@ -1169,13 +1182,25 @@ export async function restartPreview(request: FastifyRequest<RestartPreviewAppli
if (pullmergeRequestId) {
const isSecretFound = secrets.filter(s => s.name === secret.name && s.isPRMRSecret)
if (isSecretFound.length > 0) {
if (isSecretFound[0].value.includes('\\n')) {
envs.push(`${secret.name}=${isSecretFound[0].value}`);
} else {
envs.push(`${secret.name}='${isSecretFound[0].value}'`);
}
} else {
if (secret.value.includes('\\n')) {
envs.push(`${secret.name}=${secret.value}`);
} else {
envs.push(`${secret.name}='${secret.value}'`);
}
}
} else {
if (!secret.isPRMRSecret) {
if (secret.value.includes('\\n')) {
envs.push(`${secret.name}=${secret.value}`);
} else {
envs.push(`${secret.name}='${secret.value}'`);
}
}
}
});
@ -1604,4 +1629,4 @@ export async function removeBranchDatabase(database: any, pullmergeRequestId: st
} catch ({ status, message }) {
return errorHandler({ status, message })
}
}
}

View File

@ -210,13 +210,25 @@ export const applicationsRouter = router({
if (pullmergeRequestId) {
const isSecretFound = secrets.filter((s) => s.name === secret.name && s.isPRMRSecret);
if (isSecretFound.length > 0) {
if (isSecretFound[0].value.includes('\\n')) {
envs.push(`${secret.name}=${isSecretFound[0].value}`);
} else {
envs.push(`${secret.name}='${isSecretFound[0].value}'`);
}
} else {
if (secret.value.includes('\\n')) {
envs.push(`${secret.name}=${secret.value}`);
} else {
envs.push(`${secret.name}='${secret.value}'`);
}
}
} else {
if (!secret.isPRMRSecret) {
if (secret.value.includes('\\n')) {
envs.push(`${secret.name}=${secret.value}`);
} else {
envs.push(`${secret.name}='${secret.value}'`);
}
}
}
});

View File

@ -1,7 +1,7 @@
{
"name": "coolify",
"description": "An open-source & self-hostable Heroku / Netlify alternative.",
"version": "3.12.2",
"version": "3.12.3",
"license": "Apache-2.0",
"repository": "github:coollabsio/coolify",
"scripts": {