Allow "USER" instead of "USER ID" in the configuration

This commit is contained in:
Zoe Roux 2022-05-12 20:49:26 +02:00
parent f226b4c8b2
commit 6db43bb19a
No known key found for this signature in database
GPG Key ID: 54F19BB73170955D
2 changed files with 13 additions and 2 deletions

View File

@ -9,7 +9,7 @@ services:
- BASICS__PUBLICURL=http://localhost:5000
- DATABASE__ENABLED=postgres
- DATABASE__CONFIGURATIONS__POSTGRES__SERVER=postgres
- DATABASE__CONFIGURATIONS__POSTGRES__USER ID=kyoo
- DATABASE__CONFIGURATIONS__POSTGRES__USER=kyoo
- DATABASE__CONFIGURATIONS__POSTGRES__PASSWORD=kyooPassword
- TVDB__APIKEY=${TVDB__APIKEY}
- THEMOVIEDB__APIKEY=${THEMOVIEDB__APIKEY}

View File

@ -34,10 +34,21 @@ namespace Kyoo.Database
/// <returns>A parsed connection string</returns>
public static string GetDatabaseConnection(this IConfiguration config, string database)
{
static string ToDbProperty(string key)
{
return key switch
{
"USER" => "USER ID",
_ => key
};
}
DbConnectionStringBuilder builder = new();
IConfigurationSection section = config.GetSection("database:configurations").GetSection(database);
foreach (IConfigurationSection child in section.GetChildren())
builder[child.Key] = child.Value;
{
builder[ToDbProperty(child.Key)] = child.Value;
}
return builder.ConnectionString;
}