Skip to content

Add new event for finalizing resource annotations and use to configure installer certificate trust#13200

Open
danegsta wants to merge 12 commits intodotnet:mainfrom
danegsta:danegsta/installerCertConfig
Open

Add new event for finalizing resource annotations and use to configure installer certificate trust#13200
danegsta wants to merge 12 commits intodotnet:mainfrom
danegsta:danegsta/installerCertConfig

Conversation

@danegsta
Copy link
Member

@danegsta danegsta commented Nov 25, 2025

Description

Adds a new WithConfigurationFinalizer API that takes a configuration callback to be invoked after BeforeStartEvent. 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 AddInstaller methods 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

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

@github-actions
Copy link
Contributor

github-actions bot commented Nov 25, 2025

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 13200

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 13200"

@danegsta danegsta marked this pull request as ready for review December 2, 2025 00:31
Copilot AI review requested due to automatic review settings December 2, 2025 00:31
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 WithConfigurationFinalizer for registering finalization callbacks that execute in LIFO order
  • Finalizers are invoked after BeforeStartEvent handlers in DistributedApplication.ExecuteBeforeStartHooksAsync
  • Python and JavaScript installers now use finalizers instead of BeforeStartEvent subscriptions 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.

@danegsta danegsta requested a review from mitchdenny as a code owner December 2, 2025 01:08
…tionAnnotation.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@mitchdenny
Copy link
Member

Do we want to make this annotation/API experimental for 13.1?

@danegsta
Copy link
Member Author

danegsta commented Dec 8, 2025

Do we want to make this annotation/API experimental for 13.1?

Good call, I've updated the PR to make it experimental.

@mitchdenny
Copy link
Member

@danegsta where did we end up with this? Is this PR still the path forward?

@danegsta
Copy link
Member Author

@danegsta where did we end up with this? Is this PR still the path forward?

@eerhardt was working on an alternate approach in #13780; I think this PR is redundant to that approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants