From d0a0be410f27c417f49d8c78ebcc2596ba24f58f Mon Sep 17 00:00:00 2001 From: Alexanderius Date: Fri, 17 Oct 2025 16:57:27 +0500 Subject: [PATCH 1/7] [#8] [add] impl --- .../Auth/EnvironmentCredentialsFactory.cs | 22 ++++++ .../ConfigurationBuilderExtensions.cs | 2 + .../EtcdApplicationEnvironment.cs | 76 +++++++++++++++++-- 3 files changed, 94 insertions(+), 6 deletions(-) create mode 100644 src/Etcd.Microsoft.Extensions.Configuration/Auth/EnvironmentCredentialsFactory.cs diff --git a/src/Etcd.Microsoft.Extensions.Configuration/Auth/EnvironmentCredentialsFactory.cs b/src/Etcd.Microsoft.Extensions.Configuration/Auth/EnvironmentCredentialsFactory.cs new file mode 100644 index 0000000..335dd0e --- /dev/null +++ b/src/Etcd.Microsoft.Extensions.Configuration/Auth/EnvironmentCredentialsFactory.cs @@ -0,0 +1,22 @@ +namespace Etcd.Microsoft.Extensions.Configuration.Auth; + +/// +/// Provides a factory for creating environment-based credentials for etcd. +/// +public static class EnvironmentCredentialsFactory +{ + /// + /// Tries to create credentials from environment variables. + /// + /// Credentials if both username and password are set; otherwise, null. + public static ICredentials? TryCreate() + { + var userName = EtcdApplicationEnvironment.UserName; + var password = EtcdApplicationEnvironment.Password; + + if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(password)) + return null; + + return new Credentials(userName, password); + } +} \ No newline at end of file diff --git a/src/Etcd.Microsoft.Extensions.Configuration/ConfigurationBuilderExtensions.cs b/src/Etcd.Microsoft.Extensions.Configuration/ConfigurationBuilderExtensions.cs index f347080..59bc79e 100644 --- a/src/Etcd.Microsoft.Extensions.Configuration/ConfigurationBuilderExtensions.cs +++ b/src/Etcd.Microsoft.Extensions.Configuration/ConfigurationBuilderExtensions.cs @@ -98,6 +98,8 @@ public static IConfigurationBuilder AddEtcd(this IConfigurationBuilder configura { ArgumentNullException.ThrowIfNull(configurationBuilder); + credentials = EnvironmentCredentialsFactory.TryCreate() ?? credentials; + var clientFactory = new EtcdClientFactory(settings); var client = new EtcdKeyValueClient(clientFactory, credentials, enableWatch, unwatchOnDispose); diff --git a/src/Etcd.Microsoft.Extensions.Configuration/EtcdApplicationEnvironment.cs b/src/Etcd.Microsoft.Extensions.Configuration/EtcdApplicationEnvironment.cs index e3ef278..762733e 100644 --- a/src/Etcd.Microsoft.Extensions.Configuration/EtcdApplicationEnvironment.cs +++ b/src/Etcd.Microsoft.Extensions.Configuration/EtcdApplicationEnvironment.cs @@ -7,12 +7,55 @@ namespace Etcd.Microsoft.Extensions.Configuration; /// public static class EtcdApplicationEnvironment { + private static string _connectionStringEnvironmentVariableName = "ETCD_CLIENT_CONNECTION_STRING"; + private static string _userNameEnvironmentVariableName = "ETCD_CLIENT_USER_NAME"; + private static string _passwordEnvironmentVariableName = "ETCD_CLIENT_PASSWORD"; + private static string? _connectionString; + /// /// The connection string environment variable name /// - public const string ConnectionStringEnvironmentVariableName = "ETCD_CLIENT_CONNECTION_STRING"; + public static string ConnectionStringEnvironmentVariableName + { + get => _connectionStringEnvironmentVariableName; + set + { + if (string.IsNullOrEmpty(value)) + throw new ArgumentNullException(nameof(value)); - private static string? _connectionString; + _connectionStringEnvironmentVariableName = value; + } + } + + /// + /// The client user name environment variable name + /// + public static string UserNameEnvironmentVariableName + { + get => _userNameEnvironmentVariableName; + set + { + if (string.IsNullOrEmpty(value)) + throw new ArgumentNullException(nameof(value)); + + _userNameEnvironmentVariableName = value; + } + } + + /// + /// The client password environment variable name + /// + public static string PasswordEnvironmentVariableName + { + get => _passwordEnvironmentVariableName; + set + { + if (string.IsNullOrEmpty(value)) + throw new ArgumentNullException(nameof(value)); + + _passwordEnvironmentVariableName = value; + } + } /// /// Gets or sets the connection string. @@ -20,13 +63,34 @@ public static class EtcdApplicationEnvironment /// /// The connection string. /// - /// value + /// value public static string? ConnectionString { - get + get => _connectionString ??= Environment.GetEnvironmentVariable(ConnectionStringEnvironmentVariableName); + set { - return _connectionString ??= Environment.GetEnvironmentVariable(ConnectionStringEnvironmentVariableName); + if (string.IsNullOrEmpty(value)) + throw new ArgumentNullException(nameof(value)); + + _connectionString = value; } - set => _connectionString = value ?? throw new ArgumentNullException(nameof(value)); } + + /// + /// Gets or sets the user name. + /// + /// + /// The user name. + /// + /// value + public static string? UserName => Environment.GetEnvironmentVariable(UserNameEnvironmentVariableName); + + /// + /// Gets or sets the password. + /// + /// + /// The password. + /// + /// value + public static string? Password => Environment.GetEnvironmentVariable(PasswordEnvironmentVariableName); } \ No newline at end of file From a259a294615c65e51a30362408a3b7fdd6fadfd2 Mon Sep 17 00:00:00 2001 From: Alexanderius Date: Tue, 21 Oct 2025 15:52:31 +0500 Subject: [PATCH 2/7] [#8] [add] factory methods based impl --- .../Auth/Credentials.cs | 179 +++++++++++++++++- .../Auth/CredentialsSource.cs | 17 ++ .../Auth/EnvironmentCredentialsFactory.cs | 22 --- .../ConfigurationBuilderExtensions.cs | 2 - .../EtcdApplicationEnvironment.cs | 74 +------- .../ConfigurationBuilderTests.cs | 36 +++- 6 files changed, 233 insertions(+), 97 deletions(-) create mode 100644 src/Etcd.Microsoft.Extensions.Configuration/Auth/CredentialsSource.cs delete mode 100644 src/Etcd.Microsoft.Extensions.Configuration/Auth/EnvironmentCredentialsFactory.cs diff --git a/src/Etcd.Microsoft.Extensions.Configuration/Auth/Credentials.cs b/src/Etcd.Microsoft.Extensions.Configuration/Auth/Credentials.cs index 297e3db..37cd588 100644 --- a/src/Etcd.Microsoft.Extensions.Configuration/Auth/Credentials.cs +++ b/src/Etcd.Microsoft.Extensions.Configuration/Auth/Credentials.cs @@ -3,29 +3,50 @@ namespace Etcd.Microsoft.Extensions.Configuration.Auth; /// -/// Provides credentials +/// Provides credentials. /// /// public class Credentials : ICredentials { + private const string DefaultUserNameEnvironmentVariableName = "ETCD_CLIENT_USER_NAME"; + private const string DefaultPasswordEnvironmentVariableName = "ETCD_CLIENT_PASSWORD"; + /// /// Initializes a new instance of the class. /// /// Name of the user. /// The password. + /// The source of the username. + /// The source of the password. + /// The information about the credentials. /// /// Value cannot be null or empty. - userName /// or /// Value cannot be null or empty. - password /// - public Credentials(string userName, string password) + public Credentials(string userName, string password, + CredentialsSource userNameSource = CredentialsSource.Code, + CredentialsSource passwordSource = CredentialsSource.Code, + string? information = null) { if (string.IsNullOrEmpty(userName)) throw new ArgumentException("Value cannot be null or empty.", nameof(userName)); if (string.IsNullOrEmpty(password)) throw new ArgumentException("Value cannot be null or empty.", nameof(password)); UserName = userName; Password = password; + UserNameSource = userNameSource; + PasswordSource = passwordSource; + Information = information; } + /// + /// Gets the source of the user name. + /// + public CredentialsSource UserNameSource { get; } + + /// + /// Gets the source of the password. + /// + public CredentialsSource PasswordSource { get; } /// /// Gets the name of the user. @@ -42,4 +63,158 @@ public Credentials(string userName, string password) /// The password. /// public string Password { get; } + + /// + /// Gets the information about the credentials. + /// + public string? Information { get; private set; } + + /// + /// Gets the string representation of the credentials. + /// + override public string ToString() => Information ?? "Code based credentials"; + + /// + /// Creates a new credentials instance overriding values from environment variables if they are exists. + /// + /// The user name. + /// The password. + /// The name of the user name environment variable. + /// The name of the password environment variable. + /// The etcd user name or password are not provided via code and not found in the environment variable `{userNameEnvironmentVariableName}`. + public static ICredentials WithOverrideFromEnvironmentVariables( + string userName, + string password, + string userNameEnvironmentVariableName = DefaultUserNameEnvironmentVariableName, + string passwordEnvironmentVariableName = DefaultPasswordEnvironmentVariableName) + { + var userNameSource = CredentialsSource.Code; + var passwordSource = CredentialsSource.Code; + + var environmentUserName = Environment.GetEnvironmentVariable(userNameEnvironmentVariableName); + var environmentPassword = Environment.GetEnvironmentVariable(passwordEnvironmentVariableName); + + if (!string.IsNullOrEmpty(environmentUserName)) + { + userName = environmentUserName; + + userNameSource = CredentialsSource.EnvironmentVariables; + } + + if (string.IsNullOrEmpty(userName)) + throw new EtcdException($"Etcd user name is not provided via code and not found in the environment variable `{userNameEnvironmentVariableName}`."); + + if (!string.IsNullOrEmpty(environmentPassword)) + { + password = environmentPassword; + + passwordSource = CredentialsSource.EnvironmentVariables; + } + + if (string.IsNullOrEmpty(password)) + throw new EtcdException($"Etcd password is not provided via code and not found in the environment variable `{passwordEnvironmentVariableName}`."); + + return new Credentials(userName, password, userNameSource, passwordSource, + FormatInformation( + userNameSource, + passwordSource, + userNameEnvironmentVariableName, + passwordEnvironmentVariableName)); + } + + /// + /// Creates a new credentials instance overriding values from environment variables if they are exists. + /// + /// The user name. + /// The password. + /// The name of the password environment variable. + /// The etcd user name or password are not provided via code and not found in the environment variable `{userNameEnvironmentVariableName}`. + public static ICredentials WithOverrideFromEnvironmentVariables( + string userName, + string password, + string passwordEnvironmentVariableName = DefaultPasswordEnvironmentVariableName) + { + var userNameSource = CredentialsSource.Code; + var passwordSource = CredentialsSource.Code; + + var environmentPassword = Environment.GetEnvironmentVariable(passwordEnvironmentVariableName); + + if (string.IsNullOrEmpty(userName)) + throw new EtcdException($"Etcd user name is not provided."); + + if (!string.IsNullOrEmpty(environmentPassword)) + { + password = environmentPassword; + + passwordSource = CredentialsSource.EnvironmentVariables; + } + + if (string.IsNullOrEmpty(password)) + throw new EtcdException($"Etcd password is not provided via code and not found in the environment variable `{passwordEnvironmentVariableName}`."); + + return new Credentials(userName, password, userNameSource, passwordSource, + FormatInformation( + userNameSource, + passwordSource, + null, + passwordEnvironmentVariableName)); + } + + + /// + /// Creates a new credentials instance from environment variables. + /// + /// The name of the user name environment variable. + /// The name of the password environment variable. + /// The etcd user name or password are not provided via code and not found in the environment variable `{userNameEnvironmentVariableName}`. + public static ICredentials FromEnvironmentVariables( + string userNameEnvironmentVariableName = DefaultUserNameEnvironmentVariableName, + string passwordEnvironmentVariableName = DefaultPasswordEnvironmentVariableName) + { + var userNameSource = CredentialsSource.EnvironmentVariables; + var passwordSource = CredentialsSource.EnvironmentVariables; + + var userName = Environment.GetEnvironmentVariable(userNameEnvironmentVariableName); + var password = Environment.GetEnvironmentVariable(passwordEnvironmentVariableName); + + if (string.IsNullOrEmpty(userName)) + throw new EtcdException($"Etcd user name is not found in the environment variable `{userNameEnvironmentVariableName}`."); + + if (string.IsNullOrEmpty(password)) + throw new EtcdException($"Etcd password is not found in the environment variable `{passwordEnvironmentVariableName}`."); + + return new Credentials(userName, password, userNameSource, passwordSource, + FormatInformation( + userNameSource, + passwordSource, + userNameEnvironmentVariableName, + passwordEnvironmentVariableName)); + } + + private static string FormatInformation( + CredentialsSource userNameSource, + CredentialsSource passwordSource, + string? userNameEnvironmentVariableName = null, + string? passwordEnvironmentVariableName = null) => + FormatUserNameInformation(userNameSource, userNameEnvironmentVariableName) + ", " + FormatPassword(passwordSource, passwordEnvironmentVariableName); + + private static string FormatUserNameInformation(CredentialsSource userNameSource, string? userNameEnvironmentVariableName = null) + { + var result = $"UserName source: {userNameSource}"; + + if (userNameSource == CredentialsSource.EnvironmentVariables) + result += $", variable name: {userNameEnvironmentVariableName}"; + + return result; + } + + private static string FormatPassword(CredentialsSource passwordSource, string? passwordEnvironmentVariableName = null) + { + var result = $"password source: {passwordSource}"; + + if (passwordSource == CredentialsSource.EnvironmentVariables) + result += $", variable name: {passwordEnvironmentVariableName}"; + + return result; + } } \ No newline at end of file diff --git a/src/Etcd.Microsoft.Extensions.Configuration/Auth/CredentialsSource.cs b/src/Etcd.Microsoft.Extensions.Configuration/Auth/CredentialsSource.cs new file mode 100644 index 0000000..4bf9aff --- /dev/null +++ b/src/Etcd.Microsoft.Extensions.Configuration/Auth/CredentialsSource.cs @@ -0,0 +1,17 @@ +namespace Etcd.Microsoft.Extensions.Configuration.Auth +{ + /// + /// Possible sources for credentials. + /// + public enum CredentialsSource + { + /// + /// Credentials provided via code. + /// + Code = 0, + /// + /// Credentials provided via environment variables. + /// + EnvironmentVariables = 1 + } +} \ No newline at end of file diff --git a/src/Etcd.Microsoft.Extensions.Configuration/Auth/EnvironmentCredentialsFactory.cs b/src/Etcd.Microsoft.Extensions.Configuration/Auth/EnvironmentCredentialsFactory.cs deleted file mode 100644 index 335dd0e..0000000 --- a/src/Etcd.Microsoft.Extensions.Configuration/Auth/EnvironmentCredentialsFactory.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace Etcd.Microsoft.Extensions.Configuration.Auth; - -/// -/// Provides a factory for creating environment-based credentials for etcd. -/// -public static class EnvironmentCredentialsFactory -{ - /// - /// Tries to create credentials from environment variables. - /// - /// Credentials if both username and password are set; otherwise, null. - public static ICredentials? TryCreate() - { - var userName = EtcdApplicationEnvironment.UserName; - var password = EtcdApplicationEnvironment.Password; - - if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(password)) - return null; - - return new Credentials(userName, password); - } -} \ No newline at end of file diff --git a/src/Etcd.Microsoft.Extensions.Configuration/ConfigurationBuilderExtensions.cs b/src/Etcd.Microsoft.Extensions.Configuration/ConfigurationBuilderExtensions.cs index 59bc79e..f347080 100644 --- a/src/Etcd.Microsoft.Extensions.Configuration/ConfigurationBuilderExtensions.cs +++ b/src/Etcd.Microsoft.Extensions.Configuration/ConfigurationBuilderExtensions.cs @@ -98,8 +98,6 @@ public static IConfigurationBuilder AddEtcd(this IConfigurationBuilder configura { ArgumentNullException.ThrowIfNull(configurationBuilder); - credentials = EnvironmentCredentialsFactory.TryCreate() ?? credentials; - var clientFactory = new EtcdClientFactory(settings); var client = new EtcdKeyValueClient(clientFactory, credentials, enableWatch, unwatchOnDispose); diff --git a/src/Etcd.Microsoft.Extensions.Configuration/EtcdApplicationEnvironment.cs b/src/Etcd.Microsoft.Extensions.Configuration/EtcdApplicationEnvironment.cs index 762733e..950798f 100644 --- a/src/Etcd.Microsoft.Extensions.Configuration/EtcdApplicationEnvironment.cs +++ b/src/Etcd.Microsoft.Extensions.Configuration/EtcdApplicationEnvironment.cs @@ -7,55 +7,12 @@ namespace Etcd.Microsoft.Extensions.Configuration; /// public static class EtcdApplicationEnvironment { - private static string _connectionStringEnvironmentVariableName = "ETCD_CLIENT_CONNECTION_STRING"; - private static string _userNameEnvironmentVariableName = "ETCD_CLIENT_USER_NAME"; - private static string _passwordEnvironmentVariableName = "ETCD_CLIENT_PASSWORD"; - private static string? _connectionString; - /// /// The connection string environment variable name /// - public static string ConnectionStringEnvironmentVariableName - { - get => _connectionStringEnvironmentVariableName; - set - { - if (string.IsNullOrEmpty(value)) - throw new ArgumentNullException(nameof(value)); - - _connectionStringEnvironmentVariableName = value; - } - } - - /// - /// The client user name environment variable name - /// - public static string UserNameEnvironmentVariableName - { - get => _userNameEnvironmentVariableName; - set - { - if (string.IsNullOrEmpty(value)) - throw new ArgumentNullException(nameof(value)); - - _userNameEnvironmentVariableName = value; - } - } - - /// - /// The client password environment variable name - /// - public static string PasswordEnvironmentVariableName - { - get => _passwordEnvironmentVariableName; - set - { - if (string.IsNullOrEmpty(value)) - throw new ArgumentNullException(nameof(value)); + public const string ConnectionStringEnvironmentVariableName = "ETCD_CLIENT_CONNECTION_STRING"; - _passwordEnvironmentVariableName = value; - } - } + private static string? _connectionString; /// /// Gets or sets the connection string. @@ -66,31 +23,10 @@ public static string PasswordEnvironmentVariableName /// value public static string? ConnectionString { - get => _connectionString ??= Environment.GetEnvironmentVariable(ConnectionStringEnvironmentVariableName); - set + get { - if (string.IsNullOrEmpty(value)) - throw new ArgumentNullException(nameof(value)); - - _connectionString = value; + return _connectionString ??= Environment.GetEnvironmentVariable(ConnectionStringEnvironmentVariableName); } + set => _connectionString = value ?? throw new ArgumentNullException(nameof(value)); } - - /// - /// Gets or sets the user name. - /// - /// - /// The user name. - /// - /// value - public static string? UserName => Environment.GetEnvironmentVariable(UserNameEnvironmentVariableName); - - /// - /// Gets or sets the password. - /// - /// - /// The password. - /// - /// value - public static string? Password => Environment.GetEnvironmentVariable(PasswordEnvironmentVariableName); } \ No newline at end of file diff --git a/tests/Integration/Etcd.Microsoft.Extensions.Configuration.IntegrationTests/ConfigurationBuilderTests.cs b/tests/Integration/Etcd.Microsoft.Extensions.Configuration.IntegrationTests/ConfigurationBuilderTests.cs index 4c1041b..f225d6c 100644 --- a/tests/Integration/Etcd.Microsoft.Extensions.Configuration.IntegrationTests/ConfigurationBuilderTests.cs +++ b/tests/Integration/Etcd.Microsoft.Extensions.Configuration.IntegrationTests/ConfigurationBuilderTests.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using Etcd.Microsoft.Extensions.Configuration.Auth; using Etcd.Microsoft.Extensions.Configuration.Settings; @@ -26,7 +27,38 @@ public void Build_WithSettingsFromEtcd_ValuesLoaded() .Build(); // Act + PerformTest(config); + } + + [Test] + public void Build_WithSettingsFromEtcdAndCredentialsFromEnvironment_ValuesLoaded() + { + // Arrange + + Environment.SetEnvironmentVariable("ETCD_TEST_USERNAME", "MyUserName"); + Environment.SetEnvironmentVariable("ETCD_TEST_PASSWORD", "passw"); + + var credentials = new Credentials("MyUserName", "passw"); + var envCredentials = Credentials.WithOverrideFromEnvironmentVariables("foo", "bar", "ETCD_TEST_USERNAME", "ETCD_TEST_PASSWORD"); + var envCredentials2 = Credentials.WithOverrideFromEnvironmentVariables("MyUserName", "bar", "ETCD_TEST_PASSWORD"); + + var etcdSettings = new EtcdSettings("http://localhost:2379"); + var config = new ConfigurationBuilder() + .AddEtcd(credentials, etcdSettings) + .AddEtcd(envCredentials, etcdSettings, "MyPrefix") + .AddEtcd(envCredentials2, etcdSettings, "MYCOMPLEX/prefix", "/") + .Build(); + + // Act + PerformTest(config); + + // Assert + Assert.Pass("Credentials info: " + envCredentials.ToString()); + } + + private static void PerformTest(IConfigurationRoot config) + { var testSection = config.GetSection("TestSection"); var testSubSection = testSection.GetSection("SubSection"); var list = testSection.GetSection("ArraySection").Get>(); @@ -49,6 +81,6 @@ public void Build_WithSettingsFromEtcd_ValuesLoaded() Assert.That(list[1], Is.EqualTo("Item 2")); Assert.That(testAppSection["Item1"], Is.EqualTo("1234321")); - Assert.That(complexPrefixSection["TestKey"], Is.EqualTo("Test value")); + Assert.That(complexPrefixSection["TestKey"], Is.EqualTo("Test value")); // This method is just to have a breakpoint target for debugging purposes. } } \ No newline at end of file From 5e1b5f24861651d254aa5b1589253c700fd81846 Mon Sep 17 00:00:00 2001 From: Alexanderius Date: Tue, 21 Oct 2025 15:54:30 +0500 Subject: [PATCH 3/7] [del] redundant --- .../ConfigurationBuilderTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Integration/Etcd.Microsoft.Extensions.Configuration.IntegrationTests/ConfigurationBuilderTests.cs b/tests/Integration/Etcd.Microsoft.Extensions.Configuration.IntegrationTests/ConfigurationBuilderTests.cs index f225d6c..46ad9b5 100644 --- a/tests/Integration/Etcd.Microsoft.Extensions.Configuration.IntegrationTests/ConfigurationBuilderTests.cs +++ b/tests/Integration/Etcd.Microsoft.Extensions.Configuration.IntegrationTests/ConfigurationBuilderTests.cs @@ -81,6 +81,6 @@ private static void PerformTest(IConfigurationRoot config) Assert.That(list[1], Is.EqualTo("Item 2")); Assert.That(testAppSection["Item1"], Is.EqualTo("1234321")); - Assert.That(complexPrefixSection["TestKey"], Is.EqualTo("Test value")); // This method is just to have a breakpoint target for debugging purposes. + Assert.That(complexPrefixSection["TestKey"], Is.EqualTo("Test value")); } } \ No newline at end of file From fa26e89799888fcb33c45e93e065c9f3c9224bb9 Mon Sep 17 00:00:00 2001 From: Alexanderius Date: Tue, 21 Oct 2025 15:55:37 +0500 Subject: [PATCH 4/7] [#8] [edit] version/changelog --- src/Etcd.Microsoft.Extensions.Configuration/CHANGELOG.md | 6 ++++++ .../Etcd.Microsoft.Extensions.Configuration.csproj | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Etcd.Microsoft.Extensions.Configuration/CHANGELOG.md b/src/Etcd.Microsoft.Extensions.Configuration/CHANGELOG.md index eb340b0..53afd10 100644 --- a/src/Etcd.Microsoft.Extensions.Configuration/CHANGELOG.md +++ b/src/Etcd.Microsoft.Extensions.Configuration/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [3.1.0] - 2025-10-21 + +### Added + +- Possibility to load credentials from environment variables + ## [3.0.0] - 2025-06-26 ### Removed diff --git a/src/Etcd.Microsoft.Extensions.Configuration/Etcd.Microsoft.Extensions.Configuration.csproj b/src/Etcd.Microsoft.Extensions.Configuration/Etcd.Microsoft.Extensions.Configuration.csproj index 3805fb9..4648c08 100644 --- a/src/Etcd.Microsoft.Extensions.Configuration/Etcd.Microsoft.Extensions.Configuration.csproj +++ b/src/Etcd.Microsoft.Extensions.Configuration/Etcd.Microsoft.Extensions.Configuration.csproj @@ -8,7 +8,7 @@ snupkg true - 3.0 + 3.1-pre01 Etcd based configuration provider for Microsoft.Extensions.Configuration Simplify community From e3497bd8de08ad23cdbc4947b770c87bb3bd2231 Mon Sep 17 00:00:00 2001 From: Alexanderius Date: Tue, 21 Oct 2025 17:12:22 +0500 Subject: [PATCH 5/7] [#8] [edit] formatting --- .../Auth/Credentials.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Etcd.Microsoft.Extensions.Configuration/Auth/Credentials.cs b/src/Etcd.Microsoft.Extensions.Configuration/Auth/Credentials.cs index 37cd588..ee6a9b3 100644 --- a/src/Etcd.Microsoft.Extensions.Configuration/Auth/Credentials.cs +++ b/src/Etcd.Microsoft.Extensions.Configuration/Auth/Credentials.cs @@ -38,6 +38,7 @@ public Credentials(string userName, string password, PasswordSource = passwordSource; Information = information; } + /// /// Gets the source of the user name. /// @@ -72,7 +73,7 @@ public Credentials(string userName, string password, /// /// Gets the string representation of the credentials. /// - override public string ToString() => Information ?? "Code based credentials"; + override public string ToString() => Information ?? "etcd code based credentials"; /// /// Creates a new credentials instance overriding values from environment variables if they are exists. @@ -200,20 +201,20 @@ private static string FormatInformation( private static string FormatUserNameInformation(CredentialsSource userNameSource, string? userNameEnvironmentVariableName = null) { - var result = $"UserName source: {userNameSource}"; + var result = $"etcd user name source: {userNameSource}"; if (userNameSource == CredentialsSource.EnvironmentVariables) - result += $", variable name: {userNameEnvironmentVariableName}"; + result += $"({userNameEnvironmentVariableName})"; return result; } private static string FormatPassword(CredentialsSource passwordSource, string? passwordEnvironmentVariableName = null) { - var result = $"password source: {passwordSource}"; + var result = $"etcd password source: {passwordSource}"; if (passwordSource == CredentialsSource.EnvironmentVariables) - result += $", variable name: {passwordEnvironmentVariableName}"; + result += $"({passwordEnvironmentVariableName})"; return result; } From 2346574f6e7a05cd0cfd15f0cb70d09dfac6b984 Mon Sep 17 00:00:00 2001 From: Alexanderius Date: Tue, 21 Oct 2025 17:15:09 +0500 Subject: [PATCH 6/7] [edit] pre-version set --- .../Etcd.Microsoft.Extensions.Configuration.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Etcd.Microsoft.Extensions.Configuration/Etcd.Microsoft.Extensions.Configuration.csproj b/src/Etcd.Microsoft.Extensions.Configuration/Etcd.Microsoft.Extensions.Configuration.csproj index 4648c08..f8c75df 100644 --- a/src/Etcd.Microsoft.Extensions.Configuration/Etcd.Microsoft.Extensions.Configuration.csproj +++ b/src/Etcd.Microsoft.Extensions.Configuration/Etcd.Microsoft.Extensions.Configuration.csproj @@ -8,7 +8,7 @@ snupkg true - 3.1-pre01 + 3.1-pre02 Etcd based configuration provider for Microsoft.Extensions.Configuration Simplify community From 7264137229a4d8f7186b8228bd97d4887304dbb4 Mon Sep 17 00:00:00 2001 From: Alexanderius Date: Wed, 22 Oct 2025 10:16:09 +0500 Subject: [PATCH 7/7] [#8] [edit] formatting [#8] [edit] version/changelog --- .../Auth/Credentials.cs | 4 ++-- src/Etcd.Microsoft.Extensions.Configuration/CHANGELOG.md | 2 +- .../Etcd.Microsoft.Extensions.Configuration.csproj | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Etcd.Microsoft.Extensions.Configuration/Auth/Credentials.cs b/src/Etcd.Microsoft.Extensions.Configuration/Auth/Credentials.cs index ee6a9b3..5085c68 100644 --- a/src/Etcd.Microsoft.Extensions.Configuration/Auth/Credentials.cs +++ b/src/Etcd.Microsoft.Extensions.Configuration/Auth/Credentials.cs @@ -204,7 +204,7 @@ private static string FormatUserNameInformation(CredentialsSource userNameSource var result = $"etcd user name source: {userNameSource}"; if (userNameSource == CredentialsSource.EnvironmentVariables) - result += $"({userNameEnvironmentVariableName})"; + result += $" ({userNameEnvironmentVariableName})"; return result; } @@ -214,7 +214,7 @@ private static string FormatPassword(CredentialsSource passwordSource, string? p var result = $"etcd password source: {passwordSource}"; if (passwordSource == CredentialsSource.EnvironmentVariables) - result += $"({passwordEnvironmentVariableName})"; + result += $" ({passwordEnvironmentVariableName})"; return result; } diff --git a/src/Etcd.Microsoft.Extensions.Configuration/CHANGELOG.md b/src/Etcd.Microsoft.Extensions.Configuration/CHANGELOG.md index 53afd10..8464e1c 100644 --- a/src/Etcd.Microsoft.Extensions.Configuration/CHANGELOG.md +++ b/src/Etcd.Microsoft.Extensions.Configuration/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## [3.1.0] - 2025-10-21 +## [3.1.0] - 2025-10-22 ### Added diff --git a/src/Etcd.Microsoft.Extensions.Configuration/Etcd.Microsoft.Extensions.Configuration.csproj b/src/Etcd.Microsoft.Extensions.Configuration/Etcd.Microsoft.Extensions.Configuration.csproj index f8c75df..499aff8 100644 --- a/src/Etcd.Microsoft.Extensions.Configuration/Etcd.Microsoft.Extensions.Configuration.csproj +++ b/src/Etcd.Microsoft.Extensions.Configuration/Etcd.Microsoft.Extensions.Configuration.csproj @@ -8,7 +8,7 @@ snupkg true - 3.1-pre02 + 3.1 Etcd based configuration provider for Microsoft.Extensions.Configuration Simplify community