-
Notifications
You must be signed in to change notification settings - Fork 118
Set individual formatters with key-value based environment variables #769
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 29 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
9167701
Initial commit.
clrudolphi 77593d8
First working example. Takes command line input as a --logger and con…
clrudolphi dca83fb
Merge branch 'main' into TestLogger
gasparnagy 35bf0a3
Modified per reveiw comments. The format string for the command line …
clrudolphi ac846fe
Fixed tests to be OS-path aware.
clrudolphi f99c7d3
Created two Formatter Loggers (one for each built-in formatter) that …
clrudolphi 0775dad
Corrected encoding of nuspec file
clrudolphi c611111
Renamed the built-in loggers to html-formatter and message-formatter
clrudolphi d52172c
Corrrecting file encoding (again - sorry)
clrudolphi 3393e7c
Documentation
clrudolphi 54dfa0b
Cleanup of Reqnroll.csproj project references
clrudolphi bef61cd
Changed name of Logger project Reqnroll.FormatterTestLogger.
clrudolphi 003a724
Merge remote-tracking branch 'origin/main' into TestLogger
gasparnagy a8a7839
code cleanup
gasparnagy 1a7a35c
more code cleanup
gasparnagy 4ddfe53
Cleanup Reqnroll.FormatterTestLogger
gasparnagy 7146af9
code cleanup
gasparnagy c591ddc
remove Reqnroll.FormatterTestLogger project
gasparnagy 47aaa63
remove docs
gasparnagy cc6ce8e
remove Reqnroll.FormatterTestLogger project 2
gasparnagy 25dcd03
Make IEnvironmentWrapper.GetEnvironmentVariableNames return a simple …
gasparnagy 4b5b347
replace GetEnvironmentVariableNames with GetEnvironmentVariables
gasparnagy f14e21c
remove IFormatterLoggerConfigurationProvider
gasparnagy 01e0d92
fix build
gasparnagy f784d02
Update FormattersConfigurationProvider.cs
gasparnagy ee182e3
Add KeyValueEnvironmentConfigurationResolver
gasparnagy badb809
rename EnvironmentConfigurationResolver to JsonEnvironmentConfigurati…
gasparnagy c35cddb
move FileBasedConfigurationResolver to specific interface resolved pr…
gasparnagy b256e83
fix docs
gasparnagy fea18de
Update Reqnroll/EnvironmentAccess/EnvironmentWrapper.cs
gasparnagy 5f28b28
Update Reqnroll/Formatters/Configuration/KeyValueEnvironmentConfigura…
gasparnagy e6847d2
the formatter name and the setting names should be treated case insen…
gasparnagy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
Reqnroll/Formatters/Configuration/IFileBasedConfigurationResolver.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| namespace Reqnroll.Formatters.Configuration; | ||
|
|
||
| public interface IFileBasedConfigurationResolver : IFormattersConfigurationResolverBase; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
Reqnroll/Formatters/Configuration/IJsonEnvironmentConfigurationResolver.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| namespace Reqnroll.Formatters.Configuration; | ||
|
|
||
| public interface IJsonEnvironmentConfigurationResolver : IFormattersConfigurationResolverBase; |
3 changes: 3 additions & 0 deletions
3
Reqnroll/Formatters/Configuration/IKeyValueEnvironmentConfigurationResolver.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| namespace Reqnroll.Formatters.Configuration; | ||
|
|
||
| public interface IKeyValueEnvironmentConfigurationResolver : IFormattersConfigurationResolverBase; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
Reqnroll/Formatters/Configuration/KeyValueEnvironmentConfigurationResolver.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| using System; | ||
| using Reqnroll.EnvironmentAccess; | ||
| using Reqnroll.Formatters.RuntimeSupport; | ||
| using System.Collections.Generic; | ||
|
|
||
| namespace Reqnroll.Formatters.Configuration; | ||
|
|
||
| internal class KeyValueEnvironmentConfigurationResolver(IEnvironmentWrapper environmentWrapper, IFormatterLog log = null) : IKeyValueEnvironmentConfigurationResolver | ||
| { | ||
| private readonly IEnvironmentWrapper _environmentWrapper = environmentWrapper ?? throw new ArgumentNullException(nameof(environmentWrapper)); | ||
|
|
||
| public IDictionary<string, IDictionary<string, object>> Resolve() | ||
| { | ||
| var result = new Dictionary<string, IDictionary<string, object>>(StringComparer.InvariantCultureIgnoreCase); | ||
|
gasparnagy marked this conversation as resolved.
Outdated
|
||
|
|
||
| var environmentVariables = _environmentWrapper.GetEnvironmentVariables(FormattersConfigurationConstants.REQNROLL_FORMATTERS_ENVIRONMENT_VARIABLE_PREFIX); | ||
| foreach (var formatterEnvironmentVariable in environmentVariables) | ||
| { | ||
| var formatterName = formatterEnvironmentVariable.Key.Substring(FormattersConfigurationConstants.REQNROLL_FORMATTERS_ENVIRONMENT_VARIABLE_PREFIX.Length); | ||
| var formatterConfiguration = formatterEnvironmentVariable.Value?.Trim(); | ||
| if (string.IsNullOrEmpty(formatterConfiguration)) | ||
| continue; | ||
|
|
||
| log?.WriteMessage($"Configuring formatter '{formatterName}' via environment variable {formatterEnvironmentVariable.Key}={formatterEnvironmentVariable.Value}"); | ||
|
|
||
| if (formatterConfiguration.Equals("true", StringComparison.InvariantCultureIgnoreCase)) | ||
| { | ||
| result[formatterName] = new Dictionary<string, object>(); | ||
| continue; | ||
| } | ||
|
|
||
| if (formatterConfiguration.Equals("false", StringComparison.InvariantCultureIgnoreCase)) | ||
| { | ||
| result[formatterName] = null; | ||
| continue; | ||
| } | ||
|
|
||
| var settings = formatterConfiguration.Split(';'); | ||
|
|
||
| var configValues = new Dictionary<string, object>(); | ||
| foreach (string setting in settings) | ||
| { | ||
| var keyValue = setting.Split(['='], 2); | ||
| if (keyValue.Length == 1) | ||
| throw new ReqnrollException($"Could not parse setting '{setting}' for formatter '{formatterName}' when processing the environment variable {formatterEnvironmentVariable.Key}. Please use semicolon separated list of 'key=value' settings or 'true'."); | ||
|
|
||
| configValues[keyValue[0].Trim()] = keyValue[1].Trim(); | ||
| } | ||
|
|
||
| result[formatterName] = configValues; | ||
| } | ||
|
|
||
| return result; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.