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/mysql | |
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/mysql')
-rw-r--r-- | lib/sql-providers/mysql/VNLib.Plugins.Extensions.Loading.Sql.MySql/src/MYSqlExport.cs | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/lib/sql-providers/mysql/VNLib.Plugins.Extensions.Loading.Sql.MySql/src/MYSqlExport.cs b/lib/sql-providers/mysql/VNLib.Plugins.Extensions.Loading.Sql.MySql/src/MYSqlExport.cs index efe5410..3bafc23 100644 --- a/lib/sql-providers/mysql/VNLib.Plugins.Extensions.Loading.Sql.MySql/src/MYSqlExport.cs +++ b/lib/sql-providers/mysql/VNLib.Plugins.Extensions.Loading.Sql.MySql/src/MYSqlExport.cs @@ -48,6 +48,8 @@ namespace VNLib.Plugins.Extensions.Sql { private async Task<string> BuildConnStringAsync() { + IOnDemandSecret pwd = plugin.Secrets().GetOnDemandSecret("db_password"); + MySqlConnectionStringBuilder sb; //See if the user suggested a raw connection string @@ -58,7 +60,7 @@ namespace VNLib.Plugins.Extensions.Sql //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"); + using ISecretResult? password = await pwd.FetchSecretAsync(); sb.Password = password?.Result.ToString(); } @@ -76,62 +78,62 @@ namespace VNLib.Plugins.Extensions.Sql sb = value.Deserialize<MySqlConnectionStringBuilder>(opt)!; //Get the db 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(); sb = new() { - Server = config["hostname"].GetString(), - Database = config["catalog"].GetString(), - UserID = config["username"].GetString(), - Pooling = true, - MinimumPoolSize = config.GetValueOrDefault("min_pool_size", p => p.GetUInt32(), 10u), - MaximumPoolSize = config.GetValueOrDefault("max_pool_size", p => p.GetUInt32(), 50u), - Password = secret?.Result.ToString(), + Pooling = true, + Server = config.GetRequiredProperty<string>("hostname"), + Database = config.GetRequiredProperty<string>("catalog"), + UserID = config.GetRequiredProperty<string>("username"), + MinimumPoolSize = config.GetValueOrDefault("min_pool_size", 10u), + MaximumPoolSize = config.GetValueOrDefault("max_pool_size", 50u), + Password = secret?.Result.ToString(), }; - if (config.TryGetProperty("port", p => p.GetUInt16(), out ushort port)) + if (config.TryGetProperty("port", out ushort port)) { sb.Port = port; } - if (config.TryGetProperty("ssl_mode", p => p.GetString(), out string? sslMode) + if (config.TryGetProperty("ssl_mode", out string? sslMode) && Enum.TryParse(sslMode, true, out MySqlSslMode mode)) { sb.SslMode = mode; } - if (config.TryGetProperty("connection_lifetime", value => value.GetUInt32(), out uint connLife)) + if (config.TryGetProperty("connection_lifetime", out uint connLife)) { sb.ConnectionLifeTime = connLife; } - if (config.TryGetProperty("connection_timeout", value => value.GetUInt32(), out uint connTimeout)) + if (config.TryGetProperty("connection_timeout", out uint connTimeout)) { sb.ConnectionTimeout = connTimeout; } - if (config.TryGetProperty("pipe_name", value => value.GetString(), out string? pipeName)) + if (config.TryGetProperty("pipe_name", out string? pipeName)) { sb.PipeName = pipeName; } - if (config.TryGetProperty("allow_load_local_infile", value => value.GetBoolean(), out bool allowLoadLocalInfile)) + if (config.TryGetProperty("allow_load_local_infile", out bool allowLoadLocalInfile)) { sb.AllowLoadLocalInfile = allowLoadLocalInfile; } - if (config.TryGetProperty("default_command_timeout", value => value.GetUInt32(), out uint defaultCommandTimeout)) + if (config.TryGetProperty("default_command_timeout", out uint defaultCommandTimeout)) { sb.DefaultCommandTimeout = defaultCommandTimeout; } - if (config.TryGetProperty("interactive_session", value => value.GetBoolean(), out bool interactiveSession)) + if (config.TryGetProperty("interactive_session", out bool interactiveSession)) { sb.InteractiveSession = interactiveSession; } |