fix: exposedport on save

This commit is contained in:
Andras Bacsai 2022-09-01 14:01:31 +02:00
parent 44a691ae29
commit e6ea07f9b7
2 changed files with 28 additions and 29 deletions

View File

@ -139,10 +139,10 @@ export const prisma = new PrismaClient({
}); });
// prisma.$on('query', (e) => { // prisma.$on('query', (e) => {
// console.log({e}) // console.log({e})
// console.log('Query: ' + e.query) // console.log('Query: ' + e.query)
// console.log('Params: ' + e.params) // console.log('Params: ' + e.params)
// console.log('Duration: ' + e.duration + 'ms') // console.log('Duration: ' + e.duration + 'ms')
// }) // })
export const base64Encode = (text: string): string => { export const base64Encode = (text: string): string => {
return Buffer.from(text).toString('base64'); return Buffer.from(text).toString('base64');
@ -1089,7 +1089,6 @@ export async function checkExposedPort({ id, configuredPort, exposePort, dockerI
if (exposePort < 1024 || exposePort > 65535) { if (exposePort < 1024 || exposePort > 65535) {
throw { status: 500, message: `Exposed Port needs to be between 1024 and 65535.` } throw { status: 500, message: `Exposed Port needs to be between 1024 and 65535.` }
} }
if (configuredPort) { if (configuredPort) {
if (configuredPort !== exposePort) { if (configuredPort !== exposePort) {
const availablePort = await getFreeExposedPort(id, exposePort, dockerId, remoteIpAddress); const availablePort = await getFreeExposedPort(id, exposePort, dockerId, remoteIpAddress);
@ -1311,7 +1310,7 @@ export function saveUpdateableFields(type: string, data: any) {
} }
if (k.isNumber && temp === '') { if (k.isNumber && temp === '') {
temp = null temp = null
} }
update[k.name] = temp update[k.name] = temp
}); });
} }
@ -1518,26 +1517,26 @@ export function defaultComposeConfiguration(network: string): any {
} }
} }
export function decryptApplication(application: any) { export function decryptApplication(application: any) {
if (application) { if (application) {
if (application?.gitSource?.githubApp?.clientSecret) { if (application?.gitSource?.githubApp?.clientSecret) {
application.gitSource.githubApp.clientSecret = decrypt(application.gitSource.githubApp.clientSecret) || null; application.gitSource.githubApp.clientSecret = decrypt(application.gitSource.githubApp.clientSecret) || null;
} }
if (application?.gitSource?.githubApp?.webhookSecret) { if (application?.gitSource?.githubApp?.webhookSecret) {
application.gitSource.githubApp.webhookSecret = decrypt(application.gitSource.githubApp.webhookSecret) || null; application.gitSource.githubApp.webhookSecret = decrypt(application.gitSource.githubApp.webhookSecret) || null;
} }
if (application?.gitSource?.githubApp?.privateKey) { if (application?.gitSource?.githubApp?.privateKey) {
application.gitSource.githubApp.privateKey = decrypt(application.gitSource.githubApp.privateKey) || null; application.gitSource.githubApp.privateKey = decrypt(application.gitSource.githubApp.privateKey) || null;
} }
if (application?.gitSource?.gitlabApp?.appSecret) { if (application?.gitSource?.gitlabApp?.appSecret) {
application.gitSource.gitlabApp.appSecret = decrypt(application.gitSource.gitlabApp.appSecret) || null; application.gitSource.gitlabApp.appSecret = decrypt(application.gitSource.gitlabApp.appSecret) || null;
} }
if (application?.secrets.length > 0) { if (application?.secrets.length > 0) {
application.secrets = application.secrets.map((s: any) => { application.secrets = application.secrets.map((s: any) => {
s.value = decrypt(s.value) || null s.value = decrypt(s.value) || null
return s; return s;
}); });
} }
return application; return application;
} }
} }

View File

@ -249,8 +249,8 @@ export async function saveApplication(request: FastifyRequest<SaveApplication>,
exposePort = Number(exposePort); exposePort = Number(exposePort);
} }
const { destinationDocker: { id: dockerId, remoteIpAddress } } = await prisma.application.findUnique({ where: { id }, include: { destinationDocker: true } }) const { destinationDocker: { id: dockerId, remoteIpAddress }, exposePort: configuredPort } = await prisma.application.findUnique({ where: { id }, include: { destinationDocker: true } })
if (exposePort) await checkExposedPort({ id, exposePort, dockerId, remoteIpAddress }) if (exposePort) await checkExposedPort({ id, configuredPort, exposePort, dockerId, remoteIpAddress })
if (denoOptions) denoOptions = denoOptions.trim(); if (denoOptions) denoOptions = denoOptions.trim();
const defaultConfiguration = await setDefaultConfiguration({ const defaultConfiguration = await setDefaultConfiguration({
buildPack, buildPack,