Add new event for finalizing resource annotations and use to configure installer certificate trust#13200
Add new event for finalizing resource annotations and use to configure installer certificate trust#13200danegsta wants to merge 12 commits intodotnet:mainfrom
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 13200Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 13200" |
There was a problem hiding this comment.
Pull request overview
This PR introduces a new WithConfigurationFinalizer API that enables resource configuration callbacks to be invoked after the BeforeStartEvent completes. This provides a reliable mechanism for resources to finalize their configuration based on all previously applied annotations. The implementation includes converting Python and JavaScript installer setup to use this new finalizer pattern, along with adding certificate trust configuration inheritance from parent resources to their installer resources.
Key changes:
- New public API
WithConfigurationFinalizerfor registering finalization callbacks that execute in LIFO order - Finalizers are invoked after
BeforeStartEventhandlers inDistributedApplication.ExecuteBeforeStartHooksAsync - Python and JavaScript installers now use finalizers instead of
BeforeStartEventsubscriptions for configuration - Certificate trust settings are inherited from parent resources to installer resources
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Aspire.Hosting/ResourceBuilderExtensions.cs | Adds the new public API WithConfigurationFinalizer extension method |
| src/Aspire.Hosting/ApplicationModel/FinalizeResourceConfigurationCallbackAnnotation.cs | New annotation types for the finalizer callback and its context |
| src/Aspire.Hosting/DistributedApplication.cs | Implements finalizer execution logic after BeforeStartEvent completes |
| src/Aspire.Hosting/ApplicationModel/CertificateAuthorityCollectionAnnotation.cs | Adds static From method to merge certificate authority annotations |
| src/Aspire.Hosting.Python/PythonAppResourceBuilderExtensions.cs | Converts installer configuration to use finalizer pattern and adds certificate trust inheritance |
| src/Aspire.Hosting.JavaScript/JavaScriptHostingExtensions.cs | Converts installer configuration to use finalizer pattern and adds certificate trust inheritance |
| tests/Aspire.Hosting.Python.Tests/AddPythonAppTests.cs | Updates test helper to invoke finalizers after BeforeStartEvent (includes whitespace cleanup) |
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
src/Aspire.Hosting/ApplicationModel/FinalizeResourceConfigurationCallbackAnnotation.cs
Show resolved
Hide resolved
src/Aspire.Hosting/ApplicationModel/FinalizeResourceConfigurationCallbackAnnotation.cs
Show resolved
Hide resolved
src/Aspire.Hosting/ApplicationModel/CertificateAuthorityCollectionAnnotation.cs
Outdated
Show resolved
Hide resolved
…tionAnnotation.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Do we want to make this annotation/API experimental for 13.1? |
Good call, I've updated the PR to make it experimental. |
|
@danegsta where did we end up with this? Is this PR still the path forward? |
Description
Adds a new
WithConfigurationFinalizerAPI that takes a configuration callback to be invoked afterBeforeStartEvent. Callbacks are called in LIFO order, so the last registered callback will be called first, allowing resources to provide a reliable final callback that will run after all other annotation processing is complete.I've converted the Python And JS
AddInstallermethods to use this new callback to finalize the installer configuration and added certificate trust overrides based on the parent resource certificate trust configuration.Fixes #13195
Checklist
<remarks />and<code />elements on your triple slash comments?doc-ideatemplatebreaking-changetemplatediagnostictemplate