feat: allow specifying database password in separate config parameter

This commit is contained in:
spiral 2022-06-13 15:23:13 -04:00
parent 9dd3fba7e6
commit b75e59da2f
No known key found for this signature in database
GPG Key ID: 244A11E4B0BCF40E
2 changed files with 8 additions and 2 deletions

View File

@ -5,6 +5,7 @@ namespace PluralKit.Core;
public class CoreConfig
{
public string Database { get; set; }
public string? DatabasePassword { get; set; }
public string RedisAddr { get; set; }
public bool UseRedisMetrics { get; set; } = false;
public string SentryUrl { get; set; }

View File

@ -35,7 +35,7 @@ internal partial class Database: IDatabase
_migrator = migrator;
_logger = logger.ForContext<Database>();
_connectionString = new NpgsqlConnectionStringBuilder(_config.Database)
var connectionString = new NpgsqlConnectionStringBuilder(_config.Database)
{
Pooling = true,
Enlist = false,
@ -43,7 +43,12 @@ internal partial class Database: IDatabase
// Lower timeout than default (15s -> 2s), should ideally fail-fast instead of hanging
Timeout = 2
}.ConnectionString;
};
if (_config.DatabasePassword != null)
connectionString.Password = _config.DatabasePassword;
_connectionString = connectionString.ConnectionString;
}
private static readonly PostgresCompiler _compiler = new();