CLI: Add image import command#40473
Conversation
There was a problem hiding this comment.
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
ImageImportCommandwired throughImageTasks::ImportImageandImageService::Import, and registers the command under bothimage importand root-levelimport. - 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. |
|
|
||
| void ImageService::Import(wsl::windows::wslc::models::Session& session, const std::wstring& input, const std::string& imageName) | ||
| { | ||
| HANDLE imageHandle = nullptr; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
I'd recommend adding test coverage from importing an image from stdin
Summary of the Pull Request
PR Checklist
Detailed Description of the Pull Request / Additional comments
Validation Steps Performed