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. |
…melbawa/image-import-retarget
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
test/windows/wslc/e2e/WSLCE2EImageImportTests.cpp:84
- Test name/intent mismatch: WSLCE2E_Image_Import_WithoutTag() does not pass an image name at all (it exercises the missing-
case), so the name is misleading and the current Verify() expectation of success is unlikely to be correct with the current service contract (ImportImage requires a non-null image name with a tag). Either rename the test to reflect the missing-image case and assert the expected failure, or update the command invocation to pass an image name without a tag if that scenario is what needs coverage.
WSLC_TEST_METHOD(WSLCE2E_Image_Import_WithoutTag)
{
SKIP_TEST_UNSTABLE();
// Save image as a tarball
auto saveResult = RunWslc(std::format(L"image save --output \"{}\" {}", SavedArchivePath.wstring(), DebianImage.NameAndTag()));
saveResult.Verify({.Stdout = L"", .Stderr = L"", .ExitCode = 0});
// Import without specifying an image name
auto importResult = RunWslc(std::format(L"image import \"{}\"", SavedArchivePath.wstring()));
importResult.Verify({.Stderr = L"", .ExitCode = 0});
}
|
|
||
| struct InputSource | ||
| { | ||
| HANDLE Handle = nullptr; |
There was a problem hiding this comment.
nit: This could be simplified a bit by using wsl::windows::common::relay::HandleWrapper. It can either hold a "owned" handle in the form of a wil::unique_handle, or an "unowned" HANDLE.
| } | ||
|
|
||
| LARGE_INTEGER fileSize{}; | ||
| THROW_LAST_ERROR_IF(!GetFileSizeEx(result.Handle, &fileSize)); |
There was a problem hiding this comment.
It might be a good idea to return a specialized error code if this fails (because in the current implementation, this will fail if stdin is a pipe), just to make it clear that we don't support pipes
Summary of the Pull Request
Related issues:
-)PR Checklist
Detailed Description of the Pull Request / Additional comments
Validation Steps Performed