From c135a068a2541ce7fbe7998973349c370512b6fc Mon Sep 17 00:00:00 2001 From: Jan Prochazka Date: Thu, 17 Mar 2022 20:19:53 +0100 Subject: [PATCH] dbconfig support in env variables --- packages/api/env/singledb/.env | 2 ++ packages/api/src/controllers/connections.js | 2 ++ 2 files changed, 4 insertions(+) diff --git a/packages/api/env/singledb/.env b/packages/api/env/singledb/.env index 136f6429..cf816aa1 100644 --- a/packages/api/env/singledb/.env +++ b/packages/api/env/singledb/.env @@ -8,6 +8,8 @@ USER_mysql=root PASSWORD_mysql=test PORT_mysql=3307 ENGINE_mysql=mysql@dbgate-plugin-mysql +DBCONFIG_mysql=[{"name":"Chinook","connectionColor":"cyan"}] + SINGLE_CONNECTION=mysql SINGLE_DATABASE=Chinook diff --git a/packages/api/src/controllers/connections.js b/packages/api/src/controllers/connections.js index 35e85eb9..54c0e572 100644 --- a/packages/api/src/controllers/connections.js +++ b/packages/api/src/controllers/connections.js @@ -11,6 +11,7 @@ const { pickSafeConnectionInfo } = require('../utility/crypting'); const JsonLinesDatabase = require('../utility/JsonLinesDatabase'); const processArgs = require('../utility/processArgs'); +const { safeJsonParse } = require('dbgate-tools'); function getNamedArgs() { const res = {}; @@ -56,6 +57,7 @@ function getPortalCollections() { singleDatabase: !!process.env[`DATABASE_${id}`] || !!process.env[`FILE_${id}`], displayName: process.env[`LABEL_${id}`], isReadOnly: process.env[`READONLY_${id}`], + databases: process.env[`DBCONFIG_${id}`] ? safeJsonParse(process.env[`DBCONFIG_${id}`]) : null, // SSH tunnel useSshTunnel: process.env[`USE_SSH_${id}`],