Add ConfigureEnvFile support to polyglot Docker app hosts#15819
Add ConfigureEnvFile support to polyglot Docker app hosts#15819sebastienros wants to merge 7 commits intomainfrom
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15819Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 15819" |
There was a problem hiding this comment.
Pull request overview
Adds ConfigureEnvFile support to Docker Compose polyglot AppHosts (TypeScript/Python/Java) by exporting the C# API to ATS, projecting CapturedEnvironmentVariable for mutation, and extending ATS collection plumbing so typed Dict/List handles work correctly through callback parameters.
Changes:
- Export
DockerComposeEnvironmentExtensions.ConfigureEnvFileto ATS and projectCapturedEnvironmentVariableas a mutable exported handle type (with limited ignored members). - Update ATS collection exports + capability scanning/analyzers/tests to support non-generic
IDictionary/IListand typed mutableDict/Listhandles. - Extend polyglot validation fixtures and add an E2E publish test asserting
.envoutput is modified by the callback.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/PolyglotAppHosts/Aspire.Hosting.Docker/TypeScript/apphost.ts | Exercises configureEnvFile in the TypeScript Docker Compose validation AppHost. |
| tests/PolyglotAppHosts/Aspire.Hosting.Docker/Python/apphost.py | Exercises configure_env_file in the Python Docker Compose validation AppHost. |
| tests/PolyglotAppHosts/Aspire.Hosting.Docker/Java/AppHost.java | Exercises configureEnvFile in the Java Docker Compose validation AppHost. |
| tests/Aspire.Hosting.RemoteHost.Tests/CapabilityDispatcherTests.cs | Adds coverage ensuring List.get / Dict.get work for typed mutable collections returned as handles. |
| tests/Aspire.Hosting.RemoteHost.Tests/AtsCapabilityScannerTests.cs | Validates ATS type mapping for non-generic IDictionary/IList. |
| tests/Aspire.Hosting.CodeGeneration.Java.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.java | Updates expected generated Java snapshot for new dict helpers. |
| tests/Aspire.Hosting.CodeGeneration.Java.Tests/Snapshots/AtsGeneratedAspire.verified.java | Updates expected generated Java snapshot for new dict helpers. |
| tests/Aspire.Hosting.Analyzers.Tests/AspireExportAnalyzerTests.cs | Ensures analyzer allows non-generic IDictionary/IList in exported signatures. |
| tests/Aspire.Cli.EndToEnd.Tests/TypeScriptPublishTests.cs | Adds E2E test asserting configureEnvFile mutates published artifacts/.env. |
| src/Aspire.Hosting/Ats/CollectionExports.cs | Switches intrinsic Dict/List capability exports to non-generic collection interfaces to support typed mutable collections. |
| src/Aspire.Hosting.RemoteHost/AtsCapabilityScanner.cs | Maps non-generic IDictionary/IList to ATS Dict/List and emits full AtsTypeRef metadata. |
| src/Aspire.Hosting.Integration.Analyzers/AspireExportAnalyzer.cs | Allows non-generic IDictionary/IList as ATS-compatible collection types. |
| src/Aspire.Hosting.Docker/DockerComposeEnvironmentExtensions.cs | Exports configureEnvFile to ATS for Docker Compose environments. |
| src/Aspire.Hosting.Docker/CapturedEnvironmentVariable.cs | Exposes env var metadata as an exported handle type with mutable properties for polyglot callbacks. |
| src/Aspire.Hosting.CodeGeneration.TypeScript/AtsTypeScriptCodeGenerator.cs | Ensures callback parameters that are mutable dictionaries are converted to AspireDict wrappers. |
| src/Aspire.Hosting.CodeGeneration.Java/Resources/Base.java | Adds mutable AspireDict accessors needed by the callback shape (get/put/remove/keys/etc.). |
3b9a3bd to
f34819b
Compare
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
d6d7790 to
83a6d12
Compare
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
🎬 CLI E2E Test Recordings — 57 recordings uploaded (commit View recordings
📹 Recordings uploaded automatically from CI run #23968629689 |
JamesNK
left a comment
There was a problem hiding this comment.
Two minor observations (1 empty catch block concern, 1 unintentional BOM in snapshots). Overall the changes look solid — the NormalizeDictionaryKey approach, the analyzer + scanner extensions for non-generic collections, and the TS code generator refactoring are all clean.
| return key switch | ||
| { | ||
| string enumName => Enum.Parse(normalizedKeyType, enumName, ignoreCase: true), | ||
| IConvertible convertible => Enum.ToObject(normalizedKeyType, Convert.ChangeType(convertible, Enum.GetUnderlyingType(normalizedKeyType), CultureInfo.InvariantCulture)!), |
There was a problem hiding this comment.
The empty catch body here means that when key-type conversion fails, the original unconverted key is silently returned. Downstream, IDictionary.Contains returns false for the type-mismatched key, so operations like get return null and remove returns false with no indication of why. While this "best-effort conversion" design is defensible, the empty catch makes it hard to diagnose issues when a polyglot host passes an unexpected key type. Consider adding at least a comment explaining the intent, or emitting a diagnostic trace.
| @@ -1,4 +1,4 @@ | |||
| // ===== Aspire.java ===== | |||
| // ===== Aspire.java ===== | |||
There was a problem hiding this comment.
Both Java snapshot files gained a UTF-8 BOM (EF BB BF) on the first line (the visible in the diff). The .editorconfig specifies charset = utf-8 (no BOM) for the default file set. If the BOM originates from the Java code generator rather than just a Verify accept artifact, actual generated Java files that users receive would also carry an unnecessary BOM.
Description
This adds
ConfigureEnvFileparity for Docker Compose polyglot AppHosts so generated TypeScript, Python, and Java SDKs can customize captured.enventries the same way the C# surface already can. The main goal is to unblock the TypeScript issue path without widening scope into broader Docker Compose projection work.The change exports
ConfigureEnvFileto ATS, projectsCapturedEnvironmentVariablejust enough for mutation, and updates the shared ATS/runtime pieces needed for typedDict/Listhandles to flow through callback parameters correctly. On top of that, the Docker polyglot validation AppHosts now exercise the env-file callback in TypeScript, Python, and Java, the Java shared runtime now exposes mutableAspireDictaccessors needed for that callback shape, and the focused TypeScript publish validation asserts that the generatedartifacts/.envoutput changes.Fixes #15704
Checklist
<remarks />and<code />elements on your triple slash comments?aspire.devissue: