From 2adad3a7bdb7926a3ffdd7d0fa4cf0c1473b2451 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 7 Mar 2023 11:46:23 +0100 Subject: [PATCH] fix: handle log format volumes --- apps/api/src/lib/buildPacks/compose.ts | 62 +++++++++++++------ .../routes/applications/[id]/__layout.svelte | 46 +++++++------- .../routes/applications/[id]/storages.svelte | 52 +++++++++++----- 3 files changed, 104 insertions(+), 56 deletions(-) diff --git a/apps/api/src/lib/buildPacks/compose.ts b/apps/api/src/lib/buildPacks/compose.ts index f47d92fd6..839f3e3ae 100644 --- a/apps/api/src/lib/buildPacks/compose.ts +++ b/apps/api/src/lib/buildPacks/compose.ts @@ -78,28 +78,54 @@ export default async function (data) { // TODO: If we support separated volume for each service, we need to add it here if (value['volumes']?.length > 0) { value['volumes'] = value['volumes'].map((volume) => { - let [v, path, permission] = volume.split(':'); - if ( - v.startsWith('.') || - v.startsWith('..') || - v.startsWith('/') || - v.startsWith('~') || - v.startsWith('$PWD') - ) { - v = v.replace('$.', `~`).replace('$..', '~').replace('$$PWD', '~'); - } else { - if (!path) { - path = v; - v = `${applicationId}${v.replace(/\//gi, '-').replace(/\./gi, '')}`; + if (typeof volume === 'string') { + let [v, path, permission] = volume.split(':'); + if ( + v.startsWith('.') || + v.startsWith('..') || + v.startsWith('/') || + v.startsWith('~') || + v.startsWith('$PWD') + ) { + v = v.replace(/^\./, `~`).replace(/^\.\./, '~').replace(/^\$PWD/, '~'); } else { - v = `${applicationId}${v.replace(/\//gi, '-').replace(/\./gi, '')}`; + if (!path) { + path = v; + v = `${applicationId}${v.replace(/\//gi, '-').replace(/\./gi, '')}`; + } else { + v = `${applicationId}${v.replace(/\//gi, '-').replace(/\./gi, '')}`; + } + composeVolumes[v] = { + name: v + }; } - composeVolumes[v] = { - name: v - }; + return `${v}:${path}${permission ? ':' + permission : ''}`; + } + if (typeof volume === 'object') { + let { source, target, mode } = volume; + if ( + source.startsWith('.') || + source.startsWith('..') || + source.startsWith('/') || + source.startsWith('~') || + source.startsWith('$PWD') + ) { + + source = source.replace(/^\./, `~`).replace(/^\.\./, '~').replace(/^\$PWD/, '~'); + console.log({source}) + + } else { + if (!target) { + target = source; + source = `${applicationId}${source.replace(/\//gi, '-').replace(/\./gi, '')}`; + } else { + source = `${applicationId}${source.replace(/\//gi, '-').replace(/\./gi, '')}`; + } + } + + return `${source}:${target}${mode ? ':' + mode : ''}`; } - return `${v}:${path}${permission ? ':' + permission : ''}`; }); } if (volumes.length > 0) { diff --git a/apps/ui/src/routes/applications/[id]/__layout.svelte b/apps/ui/src/routes/applications/[id]/__layout.svelte index 6e29cf9b3..a61b27486 100644 --- a/apps/ui/src/routes/applications/[id]/__layout.svelte +++ b/apps/ui/src/routes/applications/[id]/__layout.svelte @@ -427,29 +427,6 @@ Stop {:else if $isDeploymentEnabled && !$page.url.pathname.startsWith(`/applications/${id}/configuration/`)} - {#if $status.application.overallStatus === 'degraded'} - - {/if} + {/if} {/if} {#if $location && $status.application.overallStatus === 'healthy'}