Skip to content

Conversation

@danegsta
Copy link
Member

@danegsta danegsta commented Nov 27, 2025

Description

Adds a builder pattern for resolving resource configuration (command line arguments and environment variables) with the ability to optionally resolve additional configuration sources (certificate trust, server authentication certificates) in a consistent API. The idea is to create something that can be consistent and allow extending with new contributors to configuration as execution contexts support them.

Fixes #13219

@github-actions
Copy link
Contributor

github-actions bot commented Nov 27, 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 -- 13221

Or

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

@danegsta danegsta marked this pull request as ready for review December 1, 2025 18:31
@danegsta danegsta requested a review from mitchdenny as a code owner December 1, 2025 18:31
Copilot AI review requested due to automatic review settings December 1, 2025 18: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 builder pattern for resolving resource configuration (command line arguments and environment variables) with optional support for additional configuration sources like certificate trust and server authentication certificates. The goal is to create a consistent, extensible API that can accommodate new configuration contributors as execution contexts evolve.

Key changes:

  • Introduces ResourceConfigurationBuilder with a fluent API for configuring resources
  • Adds configuration gatherers for arguments, environment variables, certificate trust, and server authentication certificates
  • Refactors DcpExecutor to use the new builder pattern instead of the legacy ProcessConfigurationValuesAsync method
  • Removes WasResolved tracking from ReferenceExpression and moves it to metadata-specific tracking

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
DcpExecutor.cs Refactored to use new ResourceConfigurationBuilder API instead of ProcessConfigurationValuesAsync
DcpExecutorTests.cs Added missing resourceLoggerService to test service provider
ResourceConfigurationBuilder.cs New builder class implementing the builder pattern for resource configuration
ResourceConfigurationBuilderExtensions.cs Extension methods for fluent API (WithArguments, WithEnvironmentVariables, etc.)
IResourceConfigurationBuilder.cs Public interface for the builder pattern
IResourceConfiguration.cs Public interface representing resolved configuration
ResourceConfiguration.cs Internal implementation of IResourceConfiguration
IResourceConfigurationGatherer.cs Public interface for configuration gatherers
IResourceConfigurationGathererContext.cs Public interface for gatherer context
ResourceConfigurationGathererContext.cs Internal implementation of gatherer context
ResourceArgumentsConfigurationGatherer.cs Gatherer for command line arguments
ResourceEnvironmentVariablesConfigurationGatherer.cs Gatherer for environment variables
ResourceCertificateTrustConfigurationGatherer.cs Gatherer for certificate trust configuration
ResourceServerAuthenticationCertificateConfigurationGatherer.cs Gatherer for server authentication certificates
IResourceConfigurationMetadata.cs Marker interface for configuration metadata
ResourceConfigurationExtensions.cs Extension methods for querying metadata
ReferenceExpression.cs Removed WasResolved tracking (moved to metadata-specific implementation)
ExpressionResolver.cs Removed WasResolved tracking assignment

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 karolz-ms December 1, 2025 18:53
@karolz-ms
Copy link
Member

This PR adds a lot of new public API surface. How confident are we in the shape of these types?

@danegsta
Copy link
Member Author

danegsta commented Dec 1, 2025

This PR adds a lot of new public API surface. How confident are we in the shape of these types?

Much more confident that the horrible aggregation function this replaces. We may want to polish up the method names and comments, but I don't think there's a more straightforward pattern to accomplish the goal of making it easier to re-use and extend the configuration resolution logic as more features are added that need to contribute.

@danegsta
Copy link
Member Author

danegsta commented Dec 1, 2025

The existing resolution methods in ResourceExtensions.cs are also public out of necessity; they need to be consume by publish environments and integrations that don't ship as part of Aspire.Hosting. The long term goal would be for these APIs to replace the existing GetArgumentValuesAsync, ProcessArgumentValuesAsync, etc.

@danegsta danegsta requested a review from jfversluis as a code owner December 2, 2025 21:22
@davidfowl
Copy link
Member

Help me understand why we need this?

@danegsta
Copy link
Member Author

danegsta commented Dec 3, 2025

Help me understand why we need this?

The recent certificates features have been needing to plug into argument and environment variable configuration in a way that meshes with the existing argument and environment configuration; the initial implementations were various kinds of ugly hacks, but that already started causing headaches in making sure everything was processed in a consistent way. I wanted to replace the ugly hacks I added onto the old environment and argument processing methods with something that worked the same way, but would give a consistent way to onboard the certificates features in publish and deployment scenarios in the future.

This effectively replaces the giant function of doom from #12995 with a more holistic API for evaluating config that works everywhere (and maintains the same behavior the old one did).

@danegsta danegsta merged commit d087d8c into dotnet:main Dec 4, 2025
286 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the 13.1 milestone Dec 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SSL_CERT_DIR is overwritten and not propagated from AppHost

3 participants