diff options
author | vnugent <public@vaughnnugent.com> | 2024-09-14 16:09:23 -0400 |
---|---|---|
committer | vnugent <public@vaughnnugent.com> | 2024-09-14 16:09:23 -0400 |
commit | 11fa713e33a1a5cc6f2262c25f1ab69567aa6530 (patch) | |
tree | 8e052c9a77733aa08abc00045f6ee7db3ab6114c /lib/sql-providers/sqlite/VNLib.Plugins.Extensions.Loading.Sql.SQLite/src | |
parent | 641bdbe75cb0128c09e27f1b92709c86574026ac (diff) |
commit 181f499c92ac7b772307e40d48d2a26ea45e156b
Author: vnugent <public@vaughnnugent.com>
Date: Sat Sep 14 16:01:28 2024 -0400
taskfile prettier
commit 0d47b4d25cf61d29c44a17ae491d775cf84938ab
Author: vnugent <public@vaughnnugent.com>
Date: Wed Sep 11 16:43:36 2024 -0400
Managed library & package updates
commit 940f151f2f4e708282deb5569cffe5b0935f5c3b
Author: vnugent <public@vaughnnugent.com>
Date: Mon Sep 2 13:54:16 2024 -0400
expand config extensions, and update some sql provider usage
commit b269019103acce18e0df8debd9f7bfdf203083b8
Merge: 87887c0 641bdbe
Author: vnugent <public@vaughnnugent.com>
Date: Sun Jul 28 18:53:41 2024 -0400
Merge branch 'master' into develop
Diffstat (limited to 'lib/sql-providers/sqlite/VNLib.Plugins.Extensions.Loading.Sql.SQLite/src')
2 files changed, 16 insertions, 15 deletions
diff --git a/lib/sql-providers/sqlite/VNLib.Plugins.Extensions.Loading.Sql.SQLite/src/SQLiteExport.cs b/lib/sql-providers/sqlite/VNLib.Plugins.Extensions.Loading.Sql.SQLite/src/SQLiteExport.cs index ff74051..e712e29 100644 --- a/lib/sql-providers/sqlite/VNLib.Plugins.Extensions.Loading.Sql.SQLite/src/SQLiteExport.cs +++ b/lib/sql-providers/sqlite/VNLib.Plugins.Extensions.Loading.Sql.SQLite/src/SQLiteExport.cs @@ -49,18 +49,20 @@ namespace VNLib.Plugins.Extensions.Sql private async Task<string> BuildConnStringAsync() { + IOnDemandSecret pwd = plugin.Secrets().GetOnDemandSecret("db_password"); + SqliteConnectionStringBuilder sb; //See if the user suggested a raw connection string - if (config.TryGetProperty("connection_string", ps => ps.GetString(), out string? conString)) + if (config.TryGetProperty("connection_string", out string? conString)) { sb = new(conString); //If the user did not provide a password, try to get it from secret storage if (string.IsNullOrWhiteSpace(sb.Password)) { - using ISecretResult? password = await plugin.TryGetSecretAsync("db_password"); - sb.Password = password?.Result.ToString(); + using ISecretResult? secret = await pwd.FetchSecretAsync(); + sb.Password = secret?.Result.ToString(); } } else if (config.TryGetValue("json", out JsonElement value)) @@ -75,25 +77,24 @@ namespace VNLib.Plugins.Extensions.Sql sb = value.Deserialize<SqliteConnectionStringBuilder>(opt)!; //Get the password from the secret manager - using ISecretResult? secret = await plugin.TryGetSecretAsync("db_password"); + using ISecretResult? secret = await pwd.FetchSecretAsync(); sb.Password = secret?.Result.ToString(); } else { //Get the password from the secret manager - using ISecretResult? secret = await plugin.TryGetSecretAsync("db_password"); + using ISecretResult? secret = await pwd.FetchSecretAsync(); // Build connection strin sb = new() { - DataSource = config["source"].GetString(), - Pooling = true, - Cache = SqliteCacheMode.Default, - RecursiveTriggers = config.GetValueOrDefault("recursive_triggers", p => p.GetBoolean(), false), - DefaultTimeout = config.GetValueOrDefault("timeout", p => p.GetInt32(), 30), - Mode = config.GetValueOrDefault("mode", p => (SqliteOpenMode)p.GetInt32(), SqliteOpenMode.ReadWriteCreate), - - Password = secret?.Result.ToString(), + Pooling = true, + Cache = SqliteCacheMode.Default, + DataSource = config.GetRequiredProperty<string>("source"), + RecursiveTriggers = config.GetValueOrDefault("recursive_triggers", false), + DefaultTimeout = config.GetValueOrDefault("timeout", 30), + Mode = config.GetValueOrDefault("mode", p => (SqliteOpenMode)p.GetInt32(), SqliteOpenMode.ReadWriteCreate), + Password = secret?.Result.ToString(), }; } @@ -119,7 +120,7 @@ namespace VNLib.Plugins.Extensions.Sql b.UseSqlite(connString); //Write debug loggin to the debug log if the user has it enabled or the plugin is in debug mode - if (config.GetValueOrDefault("debug", p => p.GetBoolean(), false) || plugin.IsDebug()) + if (config.GetValueOrDefault("debug", false) || plugin.IsDebug()) { //Write the SQL to the debug log b.LogTo((v) => plugin.Log.Debug("SQLite: {v}", v)); diff --git a/lib/sql-providers/sqlite/VNLib.Plugins.Extensions.Loading.Sql.SQLite/src/VNLib.Plugins.Extensions.Loading.Sql.SQLite.csproj b/lib/sql-providers/sqlite/VNLib.Plugins.Extensions.Loading.Sql.SQLite/src/VNLib.Plugins.Extensions.Loading.Sql.SQLite.csproj index b27fc00..9df3236 100644 --- a/lib/sql-providers/sqlite/VNLib.Plugins.Extensions.Loading.Sql.SQLite/src/VNLib.Plugins.Extensions.Loading.Sql.SQLite.csproj +++ b/lib/sql-providers/sqlite/VNLib.Plugins.Extensions.Loading.Sql.SQLite/src/VNLib.Plugins.Extensions.Loading.Sql.SQLite.csproj @@ -49,7 +49,7 @@ <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> </PackageReference> - <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.7" /> + <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.8" /> </ItemGroup> <ItemGroup> |