-
Notifications
You must be signed in to change notification settings - Fork 543
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
Add GetEnvironmentVariableValuesAsync
method to ResourceExtensions
#4530
Conversation
GetEnvironmentVariableValuesAsync
#4464GetEnvironmentVariableValuesAsync
method to ResourceExtensions
/// </summary> | ||
/// <param name="resource">The resource to get the environment variables from.</param> | ||
/// <param name="applicationOperation">The context in which the AppHost is being executed</param> | ||
/// <returns>The environment variables retrieved from the resource.</returns> |
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.
Can we get some <remarks>
added which cover off where this method is useful and considerations around the sync nature. As well as one or two <example>
sections which cover off its usage.
I'm not sure this needs its own conceptual document, but the following could be expanded:
https://learn.microsoft.com/en-us/dotnet/aspire/fundamentals/testing
Could you create a docs issue to capture that?
@Alirexaa this is looking good. Just want to make sure we capture the doc requirement and make sure we expand the XML docs a bit for this change. We need some covering tests as well. |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
@Alirexaa just to be clear we want the XML doc comments in this PR :) |
sure 😄
@mitchdenny, what did you mean by that? |
Just that can you please log an issue in dotnet/docs-aspire to ensure the new documentation requirement is captured. |
Co-authored-by: Damian Edwards <damian@damianedwards.com>
Co-authored-by: Ankit Jain <radical@gmail.com>
Co-authored-by: Ankit Jain <radical@gmail.com>
This comment was marked as outdated.
This comment was marked as outdated.
@Alirexaa We have a deadline for 8.1 coming in a couple of weeks and we'd like to include this feature. Do you have time to look at the changes soon? If not, I can help out by addressing some feedback on your branch. |
Yes, I have time, but I need some examples to write tests for the following cases : |
env => | ||
{ | ||
Assert.Equal("{ElasticPassword.value}", env.Value); | ||
Assert.False(string.IsNullOrEmpty(env.Value)); |
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.
We should verify the Value is the correct parameter reference in publish mode, not just that it isn't null or empty.
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.
Reactivating. This hasn't been resolved yet.
.WithEnvironment("xpack.security.enabled", "true") | ||
.WithEnvironment(context => | ||
{ | ||
context.EnvironmentVariables["ELASTIC_PASSWORD"] = "123456"; |
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.
To avoid credscan failure:
context.EnvironmentVariables["ELASTIC_PASSWORD"] = "123456"; | |
context.EnvironmentVariables["ELASTIC_PASSWORD"] = "p@ssw0rd1"; |
Co-authored-by: Ankit Jain <radical@gmail.com>
Co-authored-by: Ankit Jain <radical@gmail.com>
Co-authored-by: Ankit Jain <radical@gmail.com>
@joperezr we are going to want to get this one in for 8.1 |
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.
LGTM
.WithEnvironment("xpack.security.enabled", "true") | ||
.WithEnvironment(context => | ||
{ | ||
context.EnvironmentVariables["ELASTIC_PASSWORD"] = "p@ssw0rd1"; |
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 think we are still going to get cred scan failures here, but we can try it.
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.
Will see. @radical was saying that they were in a suppression list.
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.
There are 2 cred scan checks, and my understanding is that only one of them respects the suppression list.
/backport to release/8.1 |
Started backporting to release/8.1: https://github.com/dotnet/aspire/actions/runs/10032596995 |
@mitchdenny backporting to release/8.1 failed, the patch most likely resulted in conflicts: $ git am --3way --ignore-whitespace --keep-non-patch changes.patch
Applying: Add to ResourceExtensions ```GetEnvironmentVariableValuesAsync``` #4464
Using index info to reconstruct a base tree...
M src/Aspire.Hosting/PublicAPI.Unshipped.txt
Falling back to patching base and 3-way merge...
Auto-merging src/Aspire.Hosting/PublicAPI.Unshipped.txt
CONFLICT (content): Merge conflict in src/Aspire.Hosting/PublicAPI.Unshipped.txt
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config advice.mergeConflict false"
Patch failed at 0001 Add to ResourceExtensions ```GetEnvironmentVariableValuesAsync``` #4464
Error: The process '/usr/bin/git' failed with exit code 128 Please backport manually! |
@mitchdenny an error occurred while backporting to release/8.1, please check the run log for details! Error: git am failed, most likely due to a merge conflict. |
…ons (#4530) * Add to ResourceExtensions ```GetEnvironmentVariableValuesAsync``` #4464 * add example and remarks * add test * Update src/Aspire.Hosting/ApplicationModel/ResourceExtensions.cs Co-authored-by: Damian Edwards <damian@damianedwards.com> * Update src/Aspire.Hosting/ApplicationModel/ResourceExtensions.cs Co-authored-by: Ankit Jain <radical@gmail.com> * Update src/Aspire.Hosting/ApplicationModel/ResourceExtensions.cs Co-authored-by: Ankit Jain <radical@gmail.com> * add more tests,add suggested code * Tweak API based on Eric's feedback. * Use a different example. * Update src/Aspire.Hosting/ApplicationModel/ResourceExtensions.cs Co-authored-by: Ankit Jain <radical@gmail.com> * Remove password from example. * Indentation fixes. * Update tests/Aspire.Hosting.Tests/ResourceExtensionsTests.cs Co-authored-by: Ankit Jain <radical@gmail.com> * Update tests/Aspire.Hosting.Tests/ResourceExtensionsTests.cs Co-authored-by: Ankit Jain <radical@gmail.com> * PR feedback. * Namespace fix. --------- Co-authored-by: Mitch Denny <midenn@microsoft.com> Co-authored-by: Damian Edwards <damian@damianedwards.com> Co-authored-by: Ankit Jain <radical@gmail.com> Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com> Co-authored-by: Mitch Denny <mitchdenny@outlook.com>
…ons (#4530) (#5005) * Add to ResourceExtensions ```GetEnvironmentVariableValuesAsync``` #4464 * add example and remarks * add test * Update src/Aspire.Hosting/ApplicationModel/ResourceExtensions.cs * Update src/Aspire.Hosting/ApplicationModel/ResourceExtensions.cs * Update src/Aspire.Hosting/ApplicationModel/ResourceExtensions.cs * add more tests,add suggested code * Tweak API based on Eric's feedback. * Use a different example. * Update src/Aspire.Hosting/ApplicationModel/ResourceExtensions.cs * Remove password from example. * Indentation fixes. * Update tests/Aspire.Hosting.Tests/ResourceExtensionsTests.cs * Update tests/Aspire.Hosting.Tests/ResourceExtensionsTests.cs * PR feedback. * Namespace fix. --------- Co-authored-by: Alireza Baloochi <alireza.baloochi1380@gmail.com> Co-authored-by: Damian Edwards <damian@damianedwards.com> Co-authored-by: Ankit Jain <radical@gmail.com> Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
close: #4464
This change is based on this EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync method
with little change.
the difference between the issue Proposed API and this commit:
The issue Proposed API :
The commit Proposed API :
Microsoft Reviewers: Open in CodeFlow