Page MenuHomePhabricator

D4832.id15652.diff
No OneTemporary

D4832.id15652.diff

diff --git a/keyserver/src/database/db-config.js b/keyserver/src/database/db-config.js
--- a/keyserver/src/database/db-config.js
+++ b/keyserver/src/database/db-config.js
@@ -13,6 +13,17 @@
+dbType: DBType,
};
+function assertValidDBType(dbType: ?string): DBType {
+ if (!dbType) {
+ return 'mysql5.7';
+ }
+ invariant(
+ dbType === 'mysql5.7' || dbType === 'mariadb10.8',
+ `${dbType} is not a valid dbType`,
+ );
+ return dbType;
+}
+
let dbConfig;
async function getDBConfig(): Promise<DBConfig> {
if (dbConfig !== undefined) {
@@ -28,10 +39,7 @@
user: process.env.COMM_DATABASE_USER,
password: process.env.COMM_DATABASE_PASSWORD,
database: process.env.COMM_DATABASE_DATABASE,
- dbType:
- process.env.COMM_DATABASE_TYPE === 'mariadb10.8'
- ? 'mariadb10.8'
- : 'mysql5.7',
+ dbType: assertValidDBType(process.env.COMM_DATABASE_TYPE),
};
} else {
const importedDBConfig = await importJSON({
@@ -41,8 +49,7 @@
invariant(importedDBConfig, 'DB config missing');
dbConfig = {
...importedDBConfig,
- dbType:
- importedDBConfig.dbType === 'mariadb10.8' ? 'mariadb10.8' : 'mysql5.7',
+ dbType: assertValidDBType(importedDBConfig.dbType),
};
}
return dbConfig;

File Metadata

Mime Type
text/plain
Expires
Fri, Dec 27, 4:48 AM (9 h, 8 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2704587
Default Alt Text
D4832.id15652.diff (1 KB)

Event Timeline