From 40cbee0d758f199c182ca9ebf77cc479b597bf98 Mon Sep 17 00:00:00 2001 From: Aaron Styles Date: Sat, 30 Apr 2022 21:34:00 +1000 Subject: [PATCH] Removed some checking that doesn't work properly. Added a switch for exposing a port. --- src/lib/locales/en.json | 1 + src/lib/locales/fr.json | 1 + src/routes/applications/[id]/check.json.ts | 3 -- src/routes/applications/[id]/index.json.ts | 3 -- src/routes/applications/[id]/index.svelte | 53 ++++++++----------- .../services/[id]/wordpress/settings.json.ts | 1 - 6 files changed, 25 insertions(+), 37 deletions(-) diff --git a/src/lib/locales/en.json b/src/lib/locales/en.json index d77d2a1c1..11fe2e71c 100644 --- a/src/lib/locales/en.json +++ b/src/lib/locales/en.json @@ -200,6 +200,7 @@ "enable_automatic_deployment": "Enable Automatic Deployment", "enable_auto_deploy_webhooks": "Enable automatic deployment through webhooks.", "enable_mr_pr_previews": "Enable MR/PR Previews", + "expose_a_port": "Expose a port", "enable_preview_deploy_mr_pr_requests": "Enable preview deployments from pull or merge requests.", "debug_logs": "Debug Logs", "enable_debug_log_during_build": "Enable debug logs during build phase.
Sensitive information could be visible and saved in logs.", diff --git a/src/lib/locales/fr.json b/src/lib/locales/fr.json index 36f10dfb4..242ac6fce 100644 --- a/src/lib/locales/fr.json +++ b/src/lib/locales/fr.json @@ -61,6 +61,7 @@ "enable_debug_log_during_build": "Activez les journaux de débogage pendant la phase de build.
Les informations sensibles peuvent être visibles et enregistrées dans les journaux.", "enable_mr_pr_previews": "Activer les aperçus MR/PR", "enable_preview_deploy_mr_pr_requests": "Activez les déploiements de prévisualisation à partir de demandes d'extraction ou de fusion.", + "expose_a_port": "Exposer un port", "features": "Caractéristiques", "git_repository": "Dépôt Git", "git_source": "Source Git", diff --git a/src/routes/applications/[id]/check.json.ts b/src/routes/applications/[id]/check.json.ts index db794e9bd..f432b5dba 100644 --- a/src/routes/applications/[id]/check.json.ts +++ b/src/routes/applications/[id]/check.json.ts @@ -54,9 +54,6 @@ export const post: RequestHandler = async (event) => { } const publicPort = await getPort({ port: exposePort }); - if (exposePort !== publicPort) { - throw { message: `Expose Port ${exposePort} is already in use` }; - } } return { diff --git a/src/routes/applications/[id]/index.json.ts b/src/routes/applications/[id]/index.json.ts index 560ec21e7..558e44a9f 100644 --- a/src/routes/applications/[id]/index.json.ts +++ b/src/routes/applications/[id]/index.json.ts @@ -3,10 +3,7 @@ import * as db from '$lib/database'; import { ErrorHandler } from '$lib/database'; import { checkContainer, isContainerExited } from '$lib/haproxy'; import type { RequestHandler } from '@sveltejs/kit'; -import jsonwebtoken from 'jsonwebtoken'; -import { get as getRequest } from '$lib/api'; import { setDefaultConfiguration } from '$lib/buildPacks/common'; -import getPort from 'get-port'; export const get: RequestHandler = async (event) => { const { teamId, status, body } = await getUserDetails(event); diff --git a/src/routes/applications/[id]/index.svelte b/src/routes/applications/[id]/index.svelte index 07bcd4f36..80b4b2542 100644 --- a/src/routes/applications/[id]/index.svelte +++ b/src/routes/applications/[id]/index.svelte @@ -60,6 +60,7 @@ let previews = application.settings.previews; let dualCerts = application.settings.dualCerts; let autodeploy = application.settings.autodeploy; + let showExposePort = application.exposePort !== null; let wsgis = [ { @@ -174,29 +175,6 @@ {/if} - - {#if application.exposePort} - - - - - - - {/if} - - { + showExposePort = !showExposePort; + application.exposePort = undefined; + }} + title={$t('application.expose_a_port')} + description="Expose a port to the host system" /> + + {#if showExposePort} +
+ + +
+ {/if} {/if} {#if !notNodeDeployments.includes(application.buildPack)}
diff --git a/src/routes/services/[id]/wordpress/settings.json.ts b/src/routes/services/[id]/wordpress/settings.json.ts index 4f9c1f9b2..cee85bc41 100644 --- a/src/routes/services/[id]/wordpress/settings.json.ts +++ b/src/routes/services/[id]/wordpress/settings.json.ts @@ -8,7 +8,6 @@ import type { ComposeFile } from '$lib/types/composeFile'; import type { RequestHandler } from '@sveltejs/kit'; import cuid from 'cuid'; import fs from 'fs/promises'; -import getPort, { portNumbers } from 'get-port'; import yaml from 'js-yaml'; export const post: RequestHandler = async (event) => {