mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-14 17:50:13 +00:00
feat: allow specifying database password in separate config parameter
This commit is contained in:
parent
9dd3fba7e6
commit
b75e59da2f
2 changed files with 8 additions and 2 deletions
|
|
@ -5,6 +5,7 @@ namespace PluralKit.Core;
|
||||||
public class CoreConfig
|
public class CoreConfig
|
||||||
{
|
{
|
||||||
public string Database { get; set; }
|
public string Database { get; set; }
|
||||||
|
public string? DatabasePassword { get; set; }
|
||||||
public string RedisAddr { get; set; }
|
public string RedisAddr { get; set; }
|
||||||
public bool UseRedisMetrics { get; set; } = false;
|
public bool UseRedisMetrics { get; set; } = false;
|
||||||
public string SentryUrl { get; set; }
|
public string SentryUrl { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ internal partial class Database: IDatabase
|
||||||
_migrator = migrator;
|
_migrator = migrator;
|
||||||
_logger = logger.ForContext<Database>();
|
_logger = logger.ForContext<Database>();
|
||||||
|
|
||||||
_connectionString = new NpgsqlConnectionStringBuilder(_config.Database)
|
var connectionString = new NpgsqlConnectionStringBuilder(_config.Database)
|
||||||
{
|
{
|
||||||
Pooling = true,
|
Pooling = true,
|
||||||
Enlist = false,
|
Enlist = false,
|
||||||
|
|
@ -43,7 +43,12 @@ internal partial class Database: IDatabase
|
||||||
|
|
||||||
// Lower timeout than default (15s -> 2s), should ideally fail-fast instead of hanging
|
// Lower timeout than default (15s -> 2s), should ideally fail-fast instead of hanging
|
||||||
Timeout = 2
|
Timeout = 2
|
||||||
}.ConnectionString;
|
};
|
||||||
|
|
||||||
|
if (_config.DatabasePassword != null)
|
||||||
|
connectionString.Password = _config.DatabasePassword;
|
||||||
|
|
||||||
|
_connectionString = connectionString.ConnectionString;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly PostgresCompiler _compiler = new();
|
private static readonly PostgresCompiler _compiler = new();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue