@@ -7,26 +7,90 @@ namespace Etcd.Microsoft.Extensions.Configuration;
77/// </summary>
88public static class EtcdApplicationEnvironment
99{
10+ private static string _connectionStringEnvironmentVariableName = "ETCD_CLIENT_CONNECTION_STRING" ;
11+ private static string _userNameEnvironmentVariableName = "ETCD_CLIENT_USER_NAME" ;
12+ private static string _passwordEnvironmentVariableName = "ETCD_CLIENT_PASSWORD" ;
13+ private static string ? _connectionString ;
14+
1015 /// <summary>
1116 /// The connection string environment variable name
1217 /// </summary>
13- public const string ConnectionStringEnvironmentVariableName = "ETCD_CLIENT_CONNECTION_STRING" ;
18+ public static string ConnectionStringEnvironmentVariableName
19+ {
20+ get => _connectionStringEnvironmentVariableName ;
21+ set
22+ {
23+ if ( string . IsNullOrEmpty ( value ) )
24+ throw new ArgumentNullException ( nameof ( value ) ) ;
1425
15- private static string ? _connectionString ;
26+ _connectionStringEnvironmentVariableName = value ;
27+ }
28+ }
29+
30+ /// <summary>
31+ /// The client user name environment variable name
32+ /// </summary>
33+ public static string UserNameEnvironmentVariableName
34+ {
35+ get => _userNameEnvironmentVariableName ;
36+ set
37+ {
38+ if ( string . IsNullOrEmpty ( value ) )
39+ throw new ArgumentNullException ( nameof ( value ) ) ;
40+
41+ _userNameEnvironmentVariableName = value ;
42+ }
43+ }
44+
45+ /// <summary>
46+ /// The client password environment variable name
47+ /// </summary>
48+ public static string PasswordEnvironmentVariableName
49+ {
50+ get => _passwordEnvironmentVariableName ;
51+ set
52+ {
53+ if ( string . IsNullOrEmpty ( value ) )
54+ throw new ArgumentNullException ( nameof ( value ) ) ;
55+
56+ _passwordEnvironmentVariableName = value ;
57+ }
58+ }
1659
1760 /// <summary>
1861 /// Gets or sets the connection string.
1962 /// </summary>
2063 /// <value>
2164 /// The connection string.
2265 /// </value>
23- /// <exception cref="System. ArgumentNullException">value</exception>
66+ /// <exception cref="ArgumentNullException">value</exception>
2467 public static string ? ConnectionString
2568 {
26- get
69+ get => _connectionString ??= Environment . GetEnvironmentVariable ( ConnectionStringEnvironmentVariableName ) ;
70+ set
2771 {
28- return _connectionString ??= Environment . GetEnvironmentVariable ( ConnectionStringEnvironmentVariableName ) ;
72+ if ( string . IsNullOrEmpty ( value ) )
73+ throw new ArgumentNullException ( nameof ( value ) ) ;
74+
75+ _connectionString = value ;
2976 }
30- set => _connectionString = value ?? throw new ArgumentNullException ( nameof ( value ) ) ;
3177 }
78+
79+ /// <summary>
80+ /// Gets or sets the user name.
81+ /// </summary>
82+ /// <value>
83+ /// The user name.
84+ /// </value>
85+ /// <exception cref="ArgumentNullException">value</exception>
86+ public static string ? UserName => Environment . GetEnvironmentVariable ( UserNameEnvironmentVariableName ) ;
87+
88+ /// <summary>
89+ /// Gets or sets the password.
90+ /// </summary>
91+ /// <value>
92+ /// The password.
93+ /// </value>
94+ /// <exception cref="ArgumentNullException">value</exception>
95+ public static string ? Password => Environment . GetEnvironmentVariable ( PasswordEnvironmentVariableName ) ;
3296}
0 commit comments