You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: NpgsqlRestClient/Arguments.cs
+46-10Lines changed: 46 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,6 @@
3
3
usingNpgsqlRest;
4
4
usingNpgsqlRest.HttpFiles;
5
5
usingNpgsqlRest.TsClient;
6
-
7
6
usingstaticNpgsqlRestClient.Config;
8
7
9
8
namespaceNpgsqlRestClient;
@@ -25,14 +24,18 @@ public static bool Parse(string[] args)
25
24
("npgsqlrest [files...]","Run with the custom configuration files. All configuration files are required."),
26
25
("npgsqlrest [file1 -o file2...]","Use the -o switch to mark the next configuration file as optional. The first file after the -o switch is optional."),
27
26
("npgsqlrest [file1 --optional file2...]","Use --optional switch to mark the next configuration file as optional. The first file after the --optional switch is optional."),
27
+
("Note:","Values in the later file will override the values in the previous one."),
28
+
("npgsqlrest [--key=value]","Override the configuration with this key with a new value (case insensitive, use : to separate sections). "),
28
29
(" "," "),
29
30
("npgsqlrest -v, --version","Show version information."),
30
31
("npgsqlrest -h, --help","Show command line help."),
31
32
(" "," "),
32
-
("Note:","Values in the later file will override the values in the previous one."),
Copy file name to clipboardExpand all lines: NpgsqlRestClient/appsettings.json
+47-21Lines changed: 47 additions & 21 deletions
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,8 @@
21
21
//
22
22
// Expose current configuration to the endpoint for debugging and inspection. Note, the password in the connection string is not exposed.
23
23
//
24
-
"ExposeAsEndpoint": "/config",
24
+
//"ExposeAsEndpoint": "/config",
25
+
"ExposeAsEndpoint": null,
25
26
//
26
27
// Add the environment variables to configuration first.
27
28
//
@@ -35,6 +36,51 @@
35
36
"Default": ""
36
37
},
37
38
39
+
"ConnectionSettings": {
40
+
//
41
+
// Use the environment variables to set the connection string parameters. Default environment variables are defined below.
42
+
// Connection parameter will be set from the environment variables this option is enabled and the environment variables are set.
43
+
// Note: When this option is enabled and these environment variables are set, connection string doesn't have to be defined at all and it will be created from the environment variables.
44
+
//
45
+
"UseEnvironmentConnection": true,
46
+
//
47
+
// Use the environment variables to set the connection string parameters when the connection string section is missing.
48
+
// Set to true to use the environment variablesto override the connection string parameters.
49
+
//
50
+
"UseEnvironmentConnectionWhenMissing": false,
51
+
//
52
+
// Name of the host environment variable.
53
+
//
54
+
"HostEnvVar": "PGHOST",
55
+
//
56
+
// Name of the port environment variable.
57
+
//
58
+
"PortEnvVar": "PGPORT",
59
+
//
60
+
// Name of the database environment variable.
61
+
//
62
+
"DatabaseEnvVar": "PGDATABASE",
63
+
//
64
+
// The user name to use for the connection string parameters.
65
+
//
66
+
"UserEnvVar": "PGUSER",
67
+
//
68
+
// Name of the password environment variable.
69
+
//
70
+
"PasswordEnvVar": "PGPASSWORD",
71
+
//
72
+
// Sets the ApplicationName connection property in the connection string to the value of the ApplicationName configuration.
73
+
// Note: This option is ignored if the UseJsonApplicationName option is enabled.
74
+
//
75
+
"SetApplicationNameInConnection": true,
76
+
//
77
+
// Sets the ApplicationName connection property dynamically on every request in the following format:
78
+
// {"app": [Application Name], "uid": [User Id for authenticated users or NULL], "id": [Valud of X-Execution-Id request header or NULL]}
79
+
// Note: ApplicationName connection property is limited to 64 characters.
80
+
//
81
+
"UseJsonApplicationName": false
82
+
},
83
+
38
84
//
39
85
// Specify the urls the web host will listen on. See https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.hosting.hostingabstractionswebhostbuilderextensions.useurls?view=aspnetcore-8.0
40
86
//
@@ -265,26 +311,6 @@
265
311
//
266
312
"ConnectionName": null,
267
313
//
268
-
// If the connection string is not found, empty, or missing host, port or database, the connection string is created from the environment variables.
269
-
// See https://www.postgresql.org/docs/current/libpq-envars.html for the list of the environment variables.
270
-
//
271
-
// Note: Npgsql will use the environment variables by default but only for the small set of the connection string parameters like username and password (see https://www.npgsql.org/doc/connection-string-parameters.html#environment-variables).
272
-
// Set this option to true to use environment variables for host, port and database as well.
273
-
// When this option is enabled and these environment variables are set, connection string doesn't have to be defined at all and it will be created from the environment variables.
274
-
//
275
-
"UseEnvironmentConnection": true,
276
-
//
277
-
// Sets the ApplicationName connection property in the connection string to the value of the ApplicationName configuration.
278
-
// Note: This option is ignored if the UseJsonApplicationName option is enabled.
279
-
//
280
-
"SetApplicationNameInConnection": true,
281
-
//
282
-
// Sets the ApplicationName connection property dynamically on every request in the following format:
283
-
// {"app": [Application Name], "uid": [User Id for authenticated users or NULL], "id": [Valud of X-Execution-Id request header or NULL]}
284
-
// Note: ApplicationName connection property is limited to 64 characters.
285
-
//
286
-
"UseJsonApplicationName": true,
287
-
//
288
314
// See https://vb-consulting.github.io/npgsqlrest/options/#schemasimilarto
Copy file name to clipboardExpand all lines: client.md
+30-11Lines changed: 30 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -62,21 +62,40 @@ See the [default configuration file](https://vb-consulting.github.io/npgsqlrest/
62
62
```console
63
63
❯ npgsqlrest --help
64
64
Usage:
65
-
npgsqlrest Run with the default configuration files: appsettings.json (required) and appsettings.Development.json (optional).
66
-
npgsqlrest [files...] Run with the custom configuration files. All configuration files are required.
67
-
npgsqlrest [file1 -o file2...] Use the -o switch to mark the next configuration file as optional. The first file after the -o switch is optional.
68
-
npgsqlrest [file1 --optional file2...] Use --optional switch to mark the next configuration file as optional. The first file after the --optional switch is optional.
65
+
npgsqlrest Run with the default configuration files: appsettings.json (required) and
66
+
appsettings.Development.json (optional).
67
+
npgsqlrest [files...] Run with the custom configuration files. All configuration files are required.
68
+
npgsqlrest [file1 -o file2...] Use the -o switch to mark the next configuration file as optional. The first
69
+
file after the -o switch is optional.
70
+
npgsqlrest [file1 --optional file2...] Use --optional switch to mark the next configuration file as optional. The
71
+
first file after the --optional switch is optional.
72
+
Note: Values in the later file will override the values in the previous one.
73
+
npgsqlrest [--key=value] Override the configuration with this key with a new value (case insensitive,
74
+
use : to separate sections).
75
+
76
+
npgsqlrest -v, --version Show version information.
77
+
npgsqlrest -h, --help Show command line help.
78
+
79
+
80
+
Examples:
81
+
Example: use two config files npgsqlrest appsettings.json appsettings.Development.json
82
+
Example: second config file optional npgsqlrest appsettings.json -o appsettings.Development.json
See the [full diff here](https://github.com/vb-consulting/NpgsqlRest/compare/client-1.3.0...client-1.4.0)
78
92
79
-
## Changelog
93
+
- Added new configuration section: `ConnectionSettings` and moved `UseEnvironmentConnection`, `SetApplicationNameInConnection`, and `UseJsonApplicationName` from `NpgsqlRest` to `ConnectionSettings`.
94
+
- Added connections settings for customize connection parameters environment variable names (`HostEnvVar`, `PortEnvVar`, `DatabaseEnvVar`, `UserEnvVar` and `PasswordEnvVar`). Some Docker environments have different environment variable names.
95
+
- Added connections settings `"UseEnvironmentConnectionWhenMissing": false` to be able to override connection string with environment variable names and vice versa.
96
+
- Added support for overriding configuration settings from the command line. Command line configuration has to have this format: `--key=value`. See updated help for more info.
97
+
- Configuration value `ExposeAsEndpoint` is now set to NULL (disabled) as the default configuration. This may be enabled in the development environment.
98
+
- Fix: Default configuration files `appsettings.json` and optional `appsettings.Development.json` are now loaded from the same directory as all others (current directory as opposed to the exe location dir).
0 commit comments