Skip to content

CLI: Add image import command#40473

Open
AmelBawa-msft wants to merge 3 commits intomasterfrom
user/amelbawa/image-import-retarget
Open

CLI: Add image import command#40473
AmelBawa-msft wants to merge 3 commits intomasterfrom
user/amelbawa/image-import-retarget

Conversation

@AmelBawa-msft
Copy link
Copy Markdown
Contributor

Summary of the Pull Request

  • Added wslc image import command to create an image from a tarball, with an optional image name/tag argument. Also registered as a top-level wslc import alias.
  • Supports file path or stdin (-) as input
  • E2E tests covering import with/without tag, invalid path, stdin-style usage, and the root-level import alias.

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

Copilot AI review requested due to automatic review settings May 8, 2026 20:57
@AmelBawa-msft AmelBawa-msft requested a review from a team as a code owner May 8, 2026 20:57
@AmelBawa-msft AmelBawa-msft mentioned this pull request May 8, 2026
6 tasks
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 a new wslc image import CLI command (and a top-level wslc import alias) intended to create an image from a tarball, along with localization strings and E2E coverage updates.

Changes:

  • Adds ImageImportCommand wired through ImageTasks::ImportImage and ImageService::Import, and registers the command under both image import and root-level import.
  • Introduces a new positional CLI argument (ImportFile / file) and updates help/command listings in existing E2E tests.
  • Adds new localization strings and a new E2E test suite for image import.

Reviewed changes

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

Show a summary per file
File Description
test/windows/wslc/e2e/WSLCE2EImageTests.cpp Updates expected wslc image subcommand list to include import.
test/windows/wslc/e2e/WSLCE2EImageImportTests.cpp Adds E2E tests for wslc image import help/error/success cases.
test/windows/wslc/e2e/WSLCE2EGlobalTests.cpp Updates expected top-level command list to include import.
src/windows/wslc/tasks/ImageTasks.h Declares new ImportImage task entry point.
src/windows/wslc/tasks/ImageTasks.cpp Implements CLI task plumbing for image import.
src/windows/wslc/services/ImageService.h Adds ImageService::Import API.
src/windows/wslc/services/ImageService.cpp Implements import via session->ImportImage(...), including - stdin path.
src/windows/wslc/commands/RootCommand.cpp Registers root-level import alias.
src/windows/wslc/commands/ImageImportCommand.cpp Implements the new image import command.
src/windows/wslc/commands/ImageCommand.h Declares ImageImportCommand.
src/windows/wslc/commands/ImageCommand.cpp Registers image import under the image command group.
src/windows/wslc/arguments/ArgumentDefinitions.h Adds new positional argument definition ImportFile (file).
localization/strings/en-US/Resources.resw Adds localized strings for import command + file argument description.

Comment thread src/windows/wslc/tasks/ImageTasks.cpp
Comment thread src/windows/wslc/services/ImageService.cpp
Comment thread test/windows/wslc/e2e/WSLCE2EImageImportTests.cpp
Comment thread test/windows/wslc/e2e/WSLCE2EImageImportTests.cpp
Comment thread localization/strings/en-US/Resources.resw

void ImageService::Import(wsl::windows::wslc::models::Session& session, const std::wstring& input, const std::string& imageName)
{
HANDLE imageHandle = nullptr;
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.

nit: Could we factor this block with Load() ? Those two methods essentially do the same (open a file or stdin based on path, and then get the file size


if (input == L"-")
{
imageHandle = GetStdHandle(STD_INPUT_HANDLE);
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.

If we take this branch, contentLength will be set to zero, which will most likely fail in the service.

For now, I would recommend calling GetFileSizeEx() on stdin, and returning an error if it fails (for the case where stdin is just a file handle)


Abstract:

This file contains end-to-end tests for WSLC image import.
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.

I'd recommend adding test coverage from importing an image from stdin

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