Support arbitrary IValueProvider sources in Docker Compose .env file generation#17471
Merged
davidfowl merged 4 commits intoMay 26, 2026
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 17471Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 17471" |
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
davidfowl
reviewed
May 25, 2026
Contributor
PR Testing ReportResult: Passed - PR #17471 verified successfully. Version Verified
Scenarios Tested
Overall ResultPR VERIFIED - no issues found in the targeted Docker Compose |
davidfowl
approved these changes
May 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When generating the
.envfile adjacent to the Docker Compose file,DockerComposeEnvironmentResource.PrepareAsyncresolved values for two specific source types:ParameterResourceandContainerImageReference. Any other type that implementsIValueProvider— including custom resource types defined in external repos — was silently ignored, leaving the env var with whatever static default was set (or blank).This change collapses the
ContainerImageReference-specific branch into a genericIValueProviderbranch, and adds a comment explaining the asymmetric treatment ofParameterResource.ContainerImageReferencealready implementsIValueProvider, so it is handled by the new branch without any change in behavior.ParameterResourceis kept as a separate leading branch because it skips resolution when a static default is already set — theelseensures it cannot fall through to theIValueProviderbranch.Alternatives considered
Keep
ContainerImageReferenceexplicit and add anIValueProviderfallback as a third branchThe natural first approach is to leave the two existing branches untouched and append a catch-all:
if (envVar.Source is ContainerImageReference cir) { defaultValue = await ((IValueProvider)cir).GetValueAsync(context.CancellationToken).ConfigureAwait(false); } + else if (envVar.Source is IValueProvider vp) + { + defaultValue = await vp.GetValueAsync(context.CancellationToken).ConfigureAwait(false); + }This works, but the
ContainerImageReferencebranch becomes dead weight — it does the same thing the fallback would do, and requires a comment explaining why theelseis there to prevent double-resolution. Collapsing it into the fallback is strictly simpler.Collapse both branches into a single
IValueProvidercheckRemoving the
ParameterResourcebranch entirely would produce the shortest code, but it loses the??=guard: the parameter would always be resolved even when a static default is already set. That is a behavioral regression for existing callers.Change
Sourcefromobject?toIValueProvider?A type-safe property would eliminate the runtime pattern-matching entirely, but
ContainerMountAnnotationandContainerPortReferenceare also validSourcevalues and do not implementIValueProvider. Moving them to a separate property would be a public API break with no benefit over the current fix.Make
ConfigureEnvFileasyncThe
ConfigureEnvFilecallback is synchronous, so callers cannot await their own value resolution. Changing its type would let any caller handle arbitrary sources asynchronously — but this pushes resolution responsibility out of the framework and onto every caller, and is a breaking change to the internal API.Checklist