Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3540365
D4832.id15652.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D4832.id15652.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D4832: [keyserver] Introduce assertValidDBType
Attached
Detach File
Event Timeline
Log In to Comment