Repository navigation
Add ATS support for Kubernetes PVC configuration callbacks - #21124
Conversation
Co-authored-by: Copilot App <[email protected]> Copilot-Session: a26931a2-c0da-4434-adff-bf912b86dbe6
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 21124Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 21124" |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🟡 Changes recommended
Exported getters promise strings but return null for unset claim fields, allowing type-checked callbacks to fail during publishing.
1 open issue
What changed in this PR
Enables TypeScript AppHosts to customize Kubernetes persistent volume claims through the existing configuration callback.
Changes:
- Exports a bounded claim model through ATS.
- Documents supported customization and limitations.
- Adds generated declarations, publish tests, and manifest snapshots.
| File | Description |
|---|---|
| tests/PolyglotAppHosts/Aspire.Hosting.Kubernetes/TypeScript/apphost.mts | Exercises callback customization. |
| tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/AtsTypeScriptCodeGeneratorTests.Generate_KubernetesPersistentVolume_WithConfigurationExposesBoundedClaimModel.verified.ts | Records exported declarations. |
| tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/AtsTypeScriptCodeGeneratorTests.cs | Checks bounded capabilities and declarations. |
| tests/Aspire.Cli.EndToEnd.Tests/TypeScriptPublishTests.cs | Tests publishing and callback failures. |
| tests/Aspire.Cli.EndToEnd.Tests/Snapshots/TypeScriptPublishTests.PublishWithKubernetesPersistentVolumeConfigurationCustomizesClaims#04.verified.yaml | Verifies StatefulSet volume bindings. |
| tests/Aspire.Cli.EndToEnd.Tests/Snapshots/TypeScriptPublishTests.PublishWithKubernetesPersistentVolumeConfigurationCustomizesClaims#03.verified.yaml | Records Helm values. |
| tests/Aspire.Cli.EndToEnd.Tests/Snapshots/TypeScriptPublishTests.PublishWithKubernetesPersistentVolumeConfigurationCustomizesClaims#02.verified.yaml | Verifies preserved Helm expressions. |
| tests/Aspire.Cli.EndToEnd.Tests/Snapshots/TypeScriptPublishTests.PublishWithKubernetesPersistentVolumeConfigurationCustomizesClaims#01.verified.yaml | Verifies omitted storage class. |
| tests/Aspire.Cli.EndToEnd.Tests/Snapshots/TypeScriptPublishTests.PublishWithKubernetesPersistentVolumeConfigurationCustomizesClaims#00.verified.yaml | Verifies ordered callback mutations. |
| tests/Aspire.Cli.EndToEnd.Tests/Aspire.Cli.EndToEnd.Tests.csproj | Enables snapshot testing. |
| src/Aspire.Hosting.Kubernetes/Resources/VolumeResourceRequirementsV1.cs | Exports resource requests. |
| src/Aspire.Hosting.Kubernetes/Resources/PersistentVolumeClaimV1.cs | Exports the claim and specification. |
| src/Aspire.Hosting.Kubernetes/Resources/PersistentVolumeClaimSpecV1.cs | Exports selected claim settings. |
| src/Aspire.Hosting.Kubernetes/Resources/ObjectMetaV1.cs | Exports labels and annotations. |
| src/Aspire.Hosting.Kubernetes/Resources/BaseKubernetesResource.cs | Exports metadata access. |
| src/Aspire.Hosting.Kubernetes/README.md | Documents examples and limitations. |
| src/Aspire.Hosting.Kubernetes/KubernetesPersistentVolumeExtensions.cs | Exports the configuration callback. |
Review effort: Balanced
…-pvc-customization Co-authored-by: Copilot App <[email protected]> Copilot-Session: a26931a2-c0da-4434-adff-bf912b86dbe6 # Conflicts: # src/Aspire.Hosting.Kubernetes/README.md # tests/Aspire.Cli.EndToEnd.Tests/Aspire.Cli.EndToEnd.Tests.csproj
This comment has been minimized.
This comment has been minimized.
PR Testing ReportPR Information
Artifact Version Verification
Changes Analyzed
Test Scenarios ExecutedFresh 1. Claim customization via callbacks - ✅ Passed (happy path)
2.
|
| Scenario | Status |
|---|---|
| 1 Claim customization | ✅ |
| 2 null storage class omits field | ✅ |
| 3 Parameterized + callback | ✅ |
| 4 Callback throws | ✅ |
| 5 Unsupported/invalid usage | ✅ |
Notes
- Not run locally: the PR's Docker-based
TypeScriptPublishTests(Docker daemon unavailable); its scenario was reproduced manually and matched its snapshots. PR CI at head was green. values.yamlparameter values are empty in publish output (pre-existing; matches snapshot).
Overall Result
✅ PR VERIFIED
Co-authored-by: Copilot App <[email protected]> Copilot-Session: a26931a2-c0da-4434-adff-bf912b86dbe6
…-pvc-customization Co-authored-by: Copilot App <[email protected]> Copilot-Session: a26931a2-c0da-4434-adff-bf912b86dbe6 # Conflicts: # tests/Aspire.Cli.EndToEnd.Tests/Aspire.Cli.EndToEnd.Tests.csproj
Tests selector7 / 100 PR test projects · 2 PR jobs, from 16 changed files. Selected PR test projects (7 / 100)
Selected PR jobs (2)
How these were chosen — grouped by what changed🔧 📦 affected project 🔧 🔧 🔧 🔧 🔧 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 Job reasons
Selection computed for commit |
|
Pull request created: #1963
|
|
📝 Documentation has been drafted in microsoft/aspire.dev#1963 targeting Documented the new Note This draft PR needs human review before merging. |
…tion) (#1963) Documents changes from microsoft/aspire#21124 Author: ``@mitchdenny`` Targeting `release/17.0` based on the source PR milestone `17.0` (exact match). ## Why The source PR exports the Kubernetes persistent volume `WithConfiguration` callback through ATS, so TypeScript AppHosts can customize generated PVCs. The docs didn't cover this. ## Changes Updated (no new pages): `src/frontend/src/content/docs/deployment/kubernetes/persistent-volumes.mdx` - Added `WithConfiguration` / `withConfiguration` to the configuration methods table. - Added a "Customize the generated claim" section with C# and TypeScript examples, storage class empty vs. null semantics, callback ordering, bounded TypeScript model, and C#-only features. Triggered signals: `integration_readme_changed`, `pr_body_has_user_facing_section`, `pr_body_has_cli_flag_mention`. > Generated by [PR Documentation Check](https://github.com/microsoft/aspire/actions/runs/40609189241) for #21124 · copilot · auto · 26.5 AIC · ⌖ 1.14 AIC · ⊞ 7.1K · [◷](https://github.com/search?q=repo%3Amicrosoft%2Faspire.dev+%22gh-aw-workflow-id%3A+pr-docs-check%22&type=pullrequests) <!-- gh-aw-agentic-workflow: PR Documentation Check, engine: copilot, model: auto, id: 40609189241, workflow_id: pr-docs-check, run: https://github.com/microsoft/aspire/actions/runs/40609189241 --> <!-- gh-aw-workflow-id: pr-docs-check --> <!-- gh-aw-workflow-call-id: microsoft/aspire/pr-docs-check -->

Description
TypeScript AppHosts currently cannot customize generated Kubernetes persistent volume claims beyond the dedicated fluent methods. This exports the existing
WithConfigurationcallback through ATS so TypeScript can customize labels, annotations, storage class, volume name/mode, access modes, and resource requests.The exported model is deliberately bounded to the scenarios exercised by the existing PVC tests, rather than exposing the entire Kubernetes manifest hierarchy. Callbacks use the existing remote-object infrastructure and run in registration order after fluent settings and environment defaults have been applied. C# behavior is unchanged.
Selectors, data sources, volume attributes classes, resource limits, and claim identity customization remain C#-only. Raw-block workload bindings are not introduced.
Fixes #20530
User-facing usage
C# AppHost (existing API):
TypeScript AppHost:
An empty storage class requests a classless volume;
nullomits the field so Kubernetes can assign its default StorageClass. Existing parameterized fluent methods continue to produce Helm expressions.Coverage and validation
Adds bounded capability/code-generation assertions, a TypeScript declaration snapshot, polyglot fixture usage, and a live TypeScript publish scenario. Generated-manifest snapshots cover ordered callback mutations, empty versus omitted storage classes, preserved Helm expressions, and unchanged StatefulSet volume bindings. The live scenario also verifies that callback exceptions fail publishing and surface the error.
Commands run successfully:
The E2E archive used self-contained managed Dashboard/TerminalHost payloads because the macOS host could not cross-compile Linux Native AOT. Native AOT payload behavior was not validated. No new package version or production dependency is required; the E2E test project adds the existing centrally managed Verify dependency for manifest snapshots.
Checklist
<remarks />and<code />elements on your triple slash comments?