feat(Config): Add env-var prefix factory + Argu.MSConfig companion#308
Open
dimension-zero wants to merge 3 commits into
Open
feat(Config): Add env-var prefix factory + Argu.MSConfig companion#308dimension-zero wants to merge 3 commits into
dimension-zero wants to merge 3 commits into
Conversation
* ConfigReaders.fs: New static member ConfigurationReader.FromEnvironmentVariables(prefix : string) that reads env vars with a fixed prefix prepended to the key. Composed from the existing EnvironmentVariableConfigurationReader via the existing FunctionConfigurationReader, so no new types in core. Existing FromEnvironmentVariables() is untouched. * New project src/Argu.MSConfig: thin adapter exposing any Microsoft.Extensions.Configuration.IConfiguration as an Argu IConfigurationReader. Lives in its own NuGet package so the core stays zero-dep on Microsoft.Extensions.*. * Directory.Packages.props: centrally-managed pin for Microsoft.Extensions.Configuration.Abstractions 8.0.0. * Argu.sln: register the new project under the existing F# tooling configuration.
4 new tests:
* FromEnvironmentVariables(prefix) prepends the prefix to the requested
key, so reader.GetValue('HOST') reads env var MYAPP_HOST.
* Missing keys come back as null (Argu's standard contract).
* Round-trip through ArgumentParser.ParseConfiguration: a schema using
CustomAppSettings keys is populated correctly when only the prefixed
env vars are set.
* No-arg FromEnvironmentVariables() is still functional (the new
overload doesn't shadow the legacy one).
Net suite size on this branch: 112 -> 116.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
feat(Config): Add env-var prefix factory + Argu.MSConfig companion
ConfigurationReader.FromEnvironmentVariables(prefix : string) that
reads env vars with a fixed prefix prepended to the key. Composed
from the existing EnvironmentVariableConfigurationReader via the
existing FunctionConfigurationReader, so no new types in core.
Existing FromEnvironmentVariables() is untouched.
Microsoft.Extensions.Configuration.IConfiguration as an Argu
IConfigurationReader. Lives in its own NuGet package so the core
stays zero-dep on Microsoft.Extensions.*.
Microsoft.Extensions.Configuration.Abstractions 8.0.0.
configuration.
test(EnvVarPrefix): Add coverage for FromEnvironmentVariables(prefix)
4 new tests:
key, so reader.GetValue('HOST') reads env var MYAPP_HOST.
CustomAppSettings keys is populated correctly when only the prefixed
env vars are set.
overload doesn't shadow the legacy one).
Net suite size on this branch: 112 -> 116.