Skip to content

CLI: Fix image import to output the image ID, allow untagged images, and support --no-trunc#40856

Merged
dkbennett merged 9 commits into
masterfrom
user/dkbennett/fixoptionalimageid
Jun 22, 2026
Merged

CLI: Fix image import to output the image ID, allow untagged images, and support --no-trunc#40856
dkbennett merged 9 commits into
masterfrom
user/dkbennett/fixoptionalimageid

Conversation

@dkbennett

@dkbennett dkbennett commented Jun 19, 2026

Copy link
Copy Markdown
Member

Summary of the Pull Request

This PR fixes three related bugs with wslc image import, all of which align it with the equivalent Docker command.

  1. Display image ID on stdout after import

Docker CLI outputs the imported image's ID to stdout. We now do the same — the server captures the ID from Docker's API response (via the status field) and returns it through a new [out] LPSTR* ImageId parameter on ImportImage. The CLI displays it truncated to 12 hex chars (matching Docker's default), with sha256: prefix stripped.

  1. Allow untagged image imports (empty/null image name)

Docker allows docker import file.tar without specifying a repository:tag, creating a : image. We now support the same — ImageName is [in, unique] (nullable) in the IDL, and the server passes empty repo/tag to the Docker API when no name is provided.

  1. Add --no-trunc support for import ID output

Added ArgType::NoTrunc to the import command's arguments. When passed, the full image ID is output instead of the 12-char truncated form.

PR Checklist

  • Closes: Link to issue #xxx
  • Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
  • Tests: Added/updated if needed and all pass
  • Localization: All end user facing strings can be localized
  • Dev docs: Added/updated if needed
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

  • Updated tests to verify image output trunc, and no trunc
  • Enabled the previously skipped untagged image to now work and improved it a bit to validate a few more things.

Copilot AI review requested due to automatic review settings June 19, 2026 16:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 aligns wslc image import behavior with Docker by returning/printing the imported image’s ID, allowing imports without a tag (creating an untagged image), and adding --no-trunc support for full-length ID output.

Changes:

  • Extended the service ImportImage COM API to accept a nullable image name and return the imported image ID.
  • Updated the CLI import task to print the (optionally truncated) image ID on success and added --no-trunc to image import.
  • Updated Windows unit/e2e tests for import output, --no-trunc, and untagged import behavior.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
test/windows/WSLCTests.cpp Updates COM test calls to pass the new ImageId out-parameter.
test/windows/wslc/e2e/WSLCE2EImageImportTests.cpp Adds e2e assertions for import ID output (trunc/no-trunc) and untagged import behavior.
src/windows/wslcsession/WSLCSession.h Updates WSLCSession ImportImage signatures and changes ImportImageImpl to return an ID string.
src/windows/wslcsession/WSLCSession.cpp Implements optional image name handling, captures/returns image ID from Docker progress, and plumbs it back via [out] LPSTR*.
src/windows/WslcSDK/wslcsdk.cpp Updates SDK wrapper to satisfy the new COM ImportImage signature by providing an out parameter.
src/windows/wslc/tasks/ImageTasks.cpp Prints the imported image ID and honors --no-trunc.
src/windows/wslc/services/ImageService.h Changes ImageService::Import to return the imported image ID.
src/windows/wslc/services/ImageService.cpp Plumbs through the ImportImage out-parameter and returns the ID to callers.
src/windows/wslc/commands/ImageImportCommand.cpp Adds ArgType::NoTrunc to the image import command arguments.
src/windows/service/inc/WSLCCompat.idl Extends compat ImportImage signature to return ImageId.
src/windows/service/inc/wslc.idl Extends IWSLCSession::ImportImage signature to return ImageId.

Comment thread src/windows/service/inc/wslc.idl
Comment thread src/windows/service/inc/WSLCCompat.idl
Comment thread src/windows/wslcsession/WSLCSession.cpp
Comment thread src/windows/wslc/commands/ImageImportCommand.cpp
Comment thread test/windows/wslc/e2e/WSLCE2EImageImportTests.cpp Outdated
Comment thread test/windows/wslc/e2e/WSLCE2EImageImportTests.cpp Outdated
Comment thread test/windows/wslc/e2e/WSLCE2EImageImportTests.cpp Outdated
Comment thread test/windows/wslc/e2e/WSLCE2EImageImportTests.cpp Outdated
Comment thread src/windows/wslcsession/WSLCSession.cpp
Copilot AI review requested due to automatic review settings June 19, 2026 18:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

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

Comment thread src/windows/service/inc/wslc.idl
Comment thread src/windows/service/inc/WSLCCompat.idl
Comment thread src/windows/wslcsession/WSLCSession.cpp
Comment thread test/windows/wslc/e2e/WSLCE2EImageImportTests.cpp Outdated
Comment thread test/windows/wslc/e2e/WSLCE2EImageImportTests.cpp Outdated
Comment thread test/windows/wslc/e2e/WSLCE2EImageImportTests.cpp
Comment thread test/windows/wslc/e2e/WSLCE2EImageImportTests.cpp Outdated
Copilot AI review requested due to automatic review settings June 19, 2026 18:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 5 comments.

Comment thread src/windows/service/inc/wslc.idl
Comment thread src/windows/service/inc/WSLCCompat.idl
Comment thread src/windows/wslcsession/WSLCSession.cpp Outdated
Comment thread test/windows/wslc/e2e/WSLCE2EImageImportTests.cpp Outdated
Comment thread test/windows/wslc/e2e/WSLCE2EImageImportTests.cpp
@dkbennett dkbennett marked this pull request as ready for review June 19, 2026 20:36
@dkbennett dkbennett requested a review from a team as a code owner June 19, 2026 20:36
Copilot AI review requested due to automatic review settings June 19, 2026 20:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Comment thread src/windows/service/inc/wslc.idl
Comment thread src/windows/service/inc/WSLCCompat.idl

@OneBlue OneBlue left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, minor comments

Comment thread test/windows/wslc/e2e/WSLCE2EImageImportTests.cpp Outdated
Comment thread src/windows/wslcsession/WSLCSession.cpp
Comment thread src/windows/wslcsession/WSLCSession.cpp Outdated
@dkbennett dkbennett requested a review from OneBlue June 22, 2026 18:51
OneBlue
OneBlue previously approved these changes Jun 22, 2026

@OneBlue OneBlue left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Minor comment

Comment thread src/windows/wslcsession/WSLCSession.cpp Outdated
Copilot AI review requested due to automatic review settings June 22, 2026 19:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.

Comment thread src/windows/wslcsession/WSLCSession.cpp
Comment thread src/windows/service/inc/wslc.idl
Comment thread src/windows/service/inc/WSLCCompat.idl
@dkbennett dkbennett enabled auto-merge (squash) June 22, 2026 20:04
@dkbennett dkbennett merged commit 146f24e into master Jun 22, 2026
12 checks passed
@dkbennett dkbennett deleted the user/dkbennett/fixoptionalimageid branch June 22, 2026 21:06
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.

3 participants