Skip to content

Add polyglot withImagePushOptions support#15809

Open
sebastienros wants to merge 3 commits intomainfrom
sebros/ts-apphost-withimagepushoptions
Open

Add polyglot withImagePushOptions support#15809
sebastienros wants to merge 3 commits intomainfrom
sebros/ts-apphost-withimagepushoptions

Conversation

@sebastienros
Copy link
Copy Markdown
Contributor

Description

Issue #15705 asks for TypeScript AppHost parity for WithImagePushOptions so polyglot app hosts can customize image push settings without falling back to narrower helpers. This keeps the change scoped to the existing generated callback model rather than introducing a new TypeScript-specific API shape.

This PR exports a single withImagePushOptions overload for polyglot hosts, marks ContainerImagePushOptionsCallbackContext and ContainerImagePushOptions for ATS property exposure, and updates the generated snapshots that prove the surface across TypeScript, Java, and Python. It also moves coverage to the shared polyglot apphost fixtures in those languages and removes stale comments that said the API was unavailable in polyglot hosts.

Dependencies: N/A

Fixes #15705

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?

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 2, 2026 20:02
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 2, 2026

🚀 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/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15809

Or

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

Copy link
Copy Markdown
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

Adds polyglot AppHost parity for WithImagePushOptions (issue #15705) by exporting the capability to ATS/polyglot SDKs and updating polyglot fixtures + generated snapshots to validate the new surface area across TypeScript, Python, and Java.

Changes:

  • Export withImagePushOptions for polyglot hosts and adjust export/ignore annotations accordingly.
  • Expose ContainerImagePushOptionsCallbackContext and ContainerImagePushOptions properties to ATS so polyglot callbacks can read/modify options.
  • Update polyglot AppHost fixtures and codegen snapshots (TS/Java/Python) to cover the new API.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/Aspire.Hosting/ResourceBuilderExtensions.cs Exports withImagePushOptions and removes stale remarks about polyglot unavailability.
src/Aspire.Hosting/ApplicationModel/ContainerImagePushOptionsCallbackContext.cs Marks callback context for ATS property exposure.
src/Aspire.Hosting/ApplicationModel/ContainerImagePushOptions.cs Marks options type for ATS property exposure.
tests/PolyglotAppHosts/Aspire.Hosting/TypeScript/apphost.ts Adds fixture usage of withImagePushOptions in TypeScript.
tests/PolyglotAppHosts/Aspire.Hosting/Python/apphost.py Adds fixture usage of with_image_push_options in Python.
tests/PolyglotAppHosts/Aspire.Hosting/Java/AppHost.java Adds fixture usage of withImagePushOptions in Java.
tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.ts Updates generated TS SDK snapshot with new types/capabilities.
tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/HostingContainerResourceCapabilities.verified.txt Updates TS capability snapshot to include withImagePushOptions.
tests/Aspire.Hosting.CodeGeneration.Python.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.py Updates generated Python SDK snapshot with new types/capabilities.
tests/Aspire.Hosting.CodeGeneration.Java.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.java Updates generated Java SDK snapshot with new types/capabilities.
Comments suppressed due to low confidence (2)

src/Aspire.Hosting/ResourceBuilderExtensions.cs:3676

  • For polyglot callbacks, this repo typically exports the async Func<..., Task> overload and ignores the Action overload (e.g., WithEnvironment exports withEnvironmentCallback and ignores the Action overload) to avoid sync-blocking remote callback invocation. Here, withImagePushOptions is exported on the Action overload, which will invoke the polyglot callback via a synchronous wait; consider exporting the Func<ContainerImagePushOptionsCallbackContext, Task> overload instead (and ignoring Action) for consistency and better scalability.
    [Experimental("ASPIREPIPELINES003", UrlFormat = "https://aka.ms/aspire/diagnostics#{0}")]
    [AspireExport("withImagePushOptions", Description = "Sets image push options via callback")]
    public static IResourceBuilder<T> WithImagePushOptions<T>(
        this IResourceBuilder<T> builder,
        Action<ContainerImagePushOptionsCallbackContext> callback)
        where T : IComputeResource

src/Aspire.Hosting/ResourceBuilderExtensions.cs:3716

  • The async WithImagePushOptions(Func<..., Task>) overload is currently ignored for polyglot even though polyglot callback plumbing supports async delegates and other APIs in this file prefer exporting the async overload. If you switch the export to the async overload, update/remove this AspireExportIgnore reason accordingly to match the established pattern.
    [Experimental("ASPIREPIPELINES003", UrlFormat = "https://aka.ms/aspire/diagnostics#{0}")]
    [AspireExportIgnore(Reason = "Polyglot app hosts use the synchronous Action<> overload via withImagePushOptions.")]
    public static IResourceBuilder<T> WithImagePushOptions<T>(
        this IResourceBuilder<T> builder,
        Func<ContainerImagePushOptionsCallbackContext, Task> callback)
        where T : IComputeResource

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 2, 2026

🎬 CLI E2E Test Recordings — 55 recordings uploaded (commit 69ab545)

View recordings
Test Recording
AddPackageInteractiveWhileAppHostRunningDetached ▶️ View Recording
AddPackageWhileAppHostRunningDetached ▶️ View Recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View Recording
AgentInitCommand_DefaultSelection_InstallsSkillOnly ▶️ View Recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View Recording
AspireAddPackageVersionToDirectoryPackagesProps ▶️ View Recording
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ▶️ View Recording
Banner_DisplayedOnFirstRun ▶️ View Recording
Banner_DisplayedWithExplicitFlag ▶️ View Recording
Banner_NotDisplayedWithNoLogoFlag ▶️ View Recording
CertificatesClean_RemovesCertificates ▶️ View Recording
CertificatesTrust_WithNoCert_CreatesAndTrustsCertificate ▶️ View Recording
CertificatesTrust_WithUntrustedCert_TrustsCertificate ▶️ View Recording
ConfigSetGet_CreatesNestedJsonFormat ▶️ View Recording
CreateAndRunAspireStarterProject ▶️ View Recording
CreateAndRunAspireStarterProjectWithBundle ▶️ View Recording
CreateAndRunEmptyAppHostProject ▶️ View Recording
CreateAndRunJavaEmptyAppHostProject ▶️ View Recording
CreateAndRunJsReactProject ▶️ View Recording
CreateAndRunPythonReactProject ▶️ View Recording
CreateAndRunTypeScriptEmptyAppHostProject ▶️ View Recording
CreateAndRunTypeScriptStarterProject ▶️ View Recording
CreateJavaAppHostWithViteApp ▶️ View Recording
CreateStartAndStopAspireProject ▶️ View Recording
CreateTypeScriptAppHostWithViteApp ▶️ View Recording
DescribeCommandResolvesReplicaNames ▶️ View Recording
DescribeCommandShowsRunningResources ▶️ View Recording
DetachFormatJsonProducesValidJson ▶️ View Recording
DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View Recording
DoctorCommand_WithSslCertDir_ShowsTrusted ▶️ View Recording
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ▶️ View Recording
GlobalMigration_HandlesCommentsAndTrailingCommas ▶️ View Recording
GlobalMigration_HandlesMalformedLegacyJson ▶️ View Recording
GlobalMigration_PreservesAllValueTypes ▶️ View Recording
GlobalMigration_SkipsWhenNewConfigExists ▶️ View Recording
GlobalSettings_MigratedFromLegacyFormat ▶️ View Recording
InvalidAppHostPathWithComments_IsHealedOnRun ▶️ View Recording
LegacySettingsMigration_AdjustsRelativeAppHostPath ▶️ View Recording
LogsCommandShowsResourceLogs ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording
PsFormatJsonOutputsOnlyJsonToStdout ▶️ View Recording
PublishWithDockerComposeServiceCallbackSucceeds ▶️ View Recording
RestoreGeneratesSdkFiles ▶️ View Recording
RestoreSupportsConfigOnlyHelperPackageAndCrossPackageTypes ▶️ View Recording
RunFromParentDirectory_UsesExistingConfigNearAppHost ▶️ View Recording
RunWithMissingAwaitShowsHelpfulError ▶️ View Recording
SecretCrudOnDotNetAppHost ▶️ View Recording
SecretCrudOnTypeScriptAppHost ▶️ View Recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View Recording
StopAllAppHostsFromAppHostDirectory ▶️ View Recording
StopAllAppHostsFromUnrelatedDirectory ▶️ View Recording
StopNonInteractiveMultipleAppHostsShowsError ▶️ View Recording
StopNonInteractiveSingleAppHost ▶️ View Recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View Recording
TypeScriptAppHostWithProjectReferenceIntegration ▶️ View Recording

📹 Recordings uploaded automatically from CI run #23919961297

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.

TypeScript AppHost: Add WithImagePushOptions API

2 participants