-
Notifications
You must be signed in to change notification settings - Fork 418
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
Introduce WithEnvironment overload for custom connection string keys #3002 #3239
Conversation
Allow custom env var names for connection strings Introduce a new WithEnvironment overload in ResourceBuilderExtensions that enables setting a connection string under a custom environment variable name. Fixes dotnet#3002.
@dotnet-policy-service agree |
This should have tests. Look at the existing WithEnvironment tests |
/backport to release/8.0 |
Started backporting to release/8.0: https://github.com/dotnet/aspire/actions/runs/8626583440 |
@mitchdenny backporting to release/8.0 failed, the patch most likely resulted in conflicts: $ git am --3way --ignore-whitespace --keep-non-patch changes.patch
Applying: Update ResourceBuilderExtensions.cs
Applying: Update ResourceBuilderExtensions.cs
Applying: Update ResourceBuilderExtensions.cs
Applying: Update src/Aspire.Hosting/ResourceBuilderExtensions.cs
Applying: Remove async keyword
error: sha1 information is lacking or useless (src/Aspire.Hosting/ResourceBuilderExtensions.cs).
error: could not build fake ancestor
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0005 Remove async keyword
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128 Please backport manually! |
@mitchdenny an error occurred while backporting to release/8.0, please check the run log for details! Error: git am failed, most likely due to a merge conflict. |
…3002 (#3239) * Update ResourceBuilderExtensions.cs Allow custom env var names for connection strings Introduce a new WithEnvironment overload in ResourceBuilderExtensions that enables setting a connection string under a custom environment variable name. Fixes #3002. * Update ResourceBuilderExtensions.cs * Update ResourceBuilderExtensions.cs * Update src/Aspire.Hosting/ResourceBuilderExtensions.cs * Remove async keyword * Added unit tests to verify the behavior of the WithEnvironment method * typo fix * verify the behavior of the WithEnvironment extension method in run mode * Apply suggestions from code review --------- Co-authored-by: David Fowler <[email protected]>
…r<IResourceWithConnectionString) (#3549) * Introduce WithEnvironment overload for custom connection string keys #3002 (#3239) * Update ResourceBuilderExtensions.cs Allow custom env var names for connection strings Introduce a new WithEnvironment overload in ResourceBuilderExtensions that enables setting a connection string under a custom environment variable name. Fixes #3002. * Update ResourceBuilderExtensions.cs * Update ResourceBuilderExtensions.cs * Update src/Aspire.Hosting/ResourceBuilderExtensions.cs * Remove async keyword * Added unit tests to verify the behavior of the WithEnvironment method * typo fix * verify the behavior of the WithEnvironment extension method in run mode * Apply suggestions from code review --------- Co-authored-by: David Fowler <[email protected]> * Fix test after merge. --------- Co-authored-by: danikishin <[email protected]> Co-authored-by: David Fowler <[email protected]>
This PR introduces a new overload for
WithEnvironment
method in theResourceBuilderExtensions
class, which allows setting the connection string of a resource under a custom environment variable name.Changes
WithEnvironment
overload to accept a custom environment variable name.Background
The issue #3002 describes a scenario where existing projects do not use the 'ConnectionStrings__' prefix for environment variables.
Example Usage