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
Eval env variables in config values #171
Eval env variables in config values #171
Conversation
Hi @TravisTheTechie, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution! TTYL, DNFBOT; |
@TravisTheTechie, Thanks for signing the contribution license agreement so quickly! Actual humans will now validate the agreement and then evaluate the PR. |
|
||
private string ApplyEnvironmentTransform(string configValue) | ||
{ | ||
if (String.IsNullOrEmpty(configValue)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: use the string.IsNullOrEmpty casing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was matching the casing existing in the file, e.g. https://github.com/TravisTheTechie/NuGet.Client/blob/issue-1852-eval-env-variables-in-config-values/src/NuGet.Core/NuGet.Configuration/Settings/Settings.cs#L59, should I go ahead an update the other references to match or just leave it with my changes?
@TravisTheTechie looks pretty neat! I'm excited about this fix. I would add a functional test for this (add a test that uses the nuget command line to read a source location) and properly prints it out (or restores from it). You can use a local folder that you put in a config file and expand it. It will also be nice to create a PR in the docs repo (CC @csharpfritz) showing an example for this cool feature |
@emgarten @zhili1208 @deepakaravindr can you guys take a look? |
</configuration>"; | ||
|
||
[Fact] | ||
public void GetValueEvalutatesEnvironmentVariable() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: spelling error
And I can make a PR for docs once this is complete. |
Building fast is |
So I added a PowerShell script which should test this functionality. Though I can't figure out how to execute it correctly. Am I going down the right track for functional tests? |
This should be a simple unit test spinning nuget.exe look at the tests in the nuget.commandline.test |
Docs pr |
NuGet/NuGetDocs#431 covers the docs. Unless someone has other feedback for me, I think this is done. It doesn't look like you do it normally, but if you want I can squash my commits for cleaner history. |
We actually do squash it normally (some people missed it in the last few weeks). So yes Please! |
@deepakaravindr please have a final review and merge (just the code, we will merge the doc PR when we ship). @TravisTheTechie it is better that you squash so we don't accidentally remove you as the author |
* Added tests for `Settings.GetValue()` and `Settings.GetSettingValues()` * Added simple implementation for `Settings.GetValue()` * `Settings.GetSettingValues()` still needs an implementation, or an implementation that overlaps both.
Squashed. Will squash docs as well. |
@deepakaravindr ping |
Merged with 603907b |
Applies to NuGet/Home#1852
Takes environment variable references in config values, and evaluates those references to what's in the environment. Uses
Environment.ExpandEnvironmentVariables
, so it should be cross platform already.Execution
Settings.GetValue()
Settings.GetSettingValues()
Tested
Considerations
Environment.ExpandEnvironmentVariables
looks for%ENV_NAME%
and *nix-based systems use the format$ENV_NAME
. Both could be supported, but looking at a couple other projects, it seems the Windows-style naming is consistent on .NET-based cross platform projects.ConfigurationDefaults
, for example, uses bothGetValue
andGetSettingValues
. I didn't obviously see another location that taps into this different.