feat: Add enable ssl field to PostgreSQL connection

This commit is contained in:
Faruk AYDIN
2023-05-15 16:02:06 +02:00
committed by Ali BARIN
parent 7a1af268ae
commit 183b9b0d88
3 changed files with 35 additions and 8 deletions

View File

@@ -23,6 +23,7 @@ export default {
readOnly: false, readOnly: false,
value: '127.0.0.1', value: '127.0.0.1',
placeholder: null, placeholder: null,
description: 'The host of the PostgreSQL database.',
clickToCopy: false, clickToCopy: false,
}, },
{ {
@@ -33,16 +34,39 @@ export default {
readOnly: false, readOnly: false,
value: '5432', value: '5432',
placeholder: null, placeholder: null,
description: 'The port of the PostgreSQL database.',
clickToCopy: false, clickToCopy: false,
}, },
{
key: 'enableSsl',
label: 'Enable SSL',
type: 'dropdown' as const,
required: true,
readOnly: false,
value: 'false',
description: 'The port of the PostgreSQL database.',
variables: false,
clickToCopy: false,
options: [
{
label: 'True',
value: 'true',
},
{
label: 'False',
value: 'false',
},
],
},
{ {
key: 'database', key: 'database',
label: 'Database Name', label: 'Database name',
type: 'string' as const, type: 'string' as const,
required: true, required: true,
readOnly: false, readOnly: false,
value: null, value: null,
placeholder: null, placeholder: null,
description: 'The database name of the PostgreSQL database.',
clickToCopy: false, clickToCopy: false,
}, },
{ {
@@ -53,8 +77,7 @@ export default {
readOnly: false, readOnly: false,
value: null, value: null,
placeholder: null, placeholder: null,
description: description: 'The user who has access on postgres database.',
'The user who has access on postgres database.',
clickToCopy: false, clickToCopy: false,
}, },
{ {
@@ -65,11 +88,11 @@ export default {
readOnly: false, readOnly: false,
value: null, value: null,
placeholder: null, placeholder: null,
description: 'The password of the PostgreSQL database user.',
clickToCopy: false, clickToCopy: false,
}, },
], ],
verifyCredentials, verifyCredentials,
isStillVerified isStillVerified,
}; };

View File

@@ -14,9 +14,11 @@ const verifyCredentials = async ($: IGlobalVariable) => {
version: $.auth.data.version, version: $.auth.data.version,
host: $.auth.data.host, host: $.auth.data.host,
port: Number($.auth.data.port), port: Number($.auth.data.port),
enableSsl:
$.auth.data.enableSsl === 'true' || $.auth.data.enableSsl === true,
user: $.auth.data.user, user: $.auth.data.user,
password: $.auth.data.password, password: $.auth.data.password,
database: $.auth.data.database database: $.auth.data.database,
}); });
}; };

View File

@@ -8,11 +8,13 @@ const getClient = ($: IGlobalVariable): Knex<any, unknown[]> => {
connection: { connection: {
host: $.auth.data.host as string, host: $.auth.data.host as string,
port: Number($.auth.data.port), port: Number($.auth.data.port),
ssl: ($.auth.data.enableSsl === 'true' ||
$.auth.data.enableSsl === true) as boolean,
user: $.auth.data.user as string, user: $.auth.data.user as string,
password: $.auth.data.password as string, password: $.auth.data.password as string,
database: $.auth.data.database as string, database: $.auth.data.database as string,
} },
}) });
return client; return client;
}; };