fix: escape % in secrets
This commit is contained in:
parent
211c6585fa
commit
eebec3b92f
@ -28,9 +28,6 @@ const customConfig: Config = {
|
||||
length: 3
|
||||
};
|
||||
|
||||
export const defaultProxyImage = `coolify-haproxy-alpine:latest`;
|
||||
export const defaultProxyImageTcp = `coolify-haproxy-tcp-alpine:latest`;
|
||||
export const defaultProxyImageHttp = `coolify-haproxy-http-alpine:latest`;
|
||||
export const defaultTraefikImage = `traefik:v2.8`;
|
||||
export function getAPIUrl() {
|
||||
if (process.env.GITPOD_WORKSPACE_URL) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
import { prisma } from '../common';
|
||||
import { decrypt, prisma } from '../common';
|
||||
|
||||
export async function removeService({ id }: { id: string }): Promise<void> {
|
||||
await prisma.serviceSecret.deleteMany({ where: { serviceId: id } });
|
||||
@ -23,3 +23,17 @@ export async function removeService({ id }: { id: string }): Promise<void> {
|
||||
|
||||
await prisma.service.delete({ where: { id } });
|
||||
}
|
||||
export async function verifyAndDecryptServiceSecrets(id: string) {
|
||||
const secrets = await prisma.serviceSecret.findMany({ where: { serviceId: id } })
|
||||
let decryptedSecrets = secrets.map(secret => {
|
||||
const { name, value } = secret
|
||||
if (value) {
|
||||
let rawValue = decrypt(value)
|
||||
rawValue = rawValue.replaceAll(/\$/gi, '$$$')
|
||||
return { name, value: rawValue }
|
||||
}
|
||||
return { name, value }
|
||||
|
||||
})
|
||||
return decryptedSecrets
|
||||
}
|
@ -7,6 +7,7 @@ import { parseAndFindServiceTemplates } from '../../routes/api/v1/services/handl
|
||||
|
||||
import { ServiceStartStop } from '../../routes/api/v1/services/types';
|
||||
import { OnlyId } from '../../types';
|
||||
import { verifyAndDecryptServiceSecrets } from './common';
|
||||
|
||||
export async function stopService(request: FastifyRequest<ServiceStartStop>) {
|
||||
try {
|
||||
@ -65,15 +66,17 @@ export async function startService(request: FastifyRequest<ServiceStartStop>, fa
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const secrets = await prisma.serviceSecret.findMany({ where: { serviceId: id } })
|
||||
const secrets = await verifyAndDecryptServiceSecrets(id)
|
||||
for (const secret of secrets) {
|
||||
const { name, value } = secret
|
||||
if (value) {
|
||||
const foundEnv = !!template.services[s].environment?.find(env => env.startsWith(`${name}=`))
|
||||
const foundNewEnv = !!newEnvironments?.find(env => env.startsWith(`${name}=`))
|
||||
if (foundEnv && !foundNewEnv) {
|
||||
newEnvironments.push(`${name}=${decrypt(value)}`)
|
||||
newEnvironments.push(`${name}=${value}`)
|
||||
}
|
||||
if (!foundEnv && !foundNewEnv && s === id) {
|
||||
newEnvironments.push(`${name}=${value}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user