CLI: Add initial support for image tag command#14416
CLI: Add initial support for image tag command#14416AmelBawa-msft wants to merge 9 commits intofeature/wsl-for-appsfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds initial support for the wslc image tag command, which allows users to tag an existing container image with a new name/tag. It introduces a RepoTag::Parse utility for parsing image references (handling registry ports, slashes, and tags), wires up the CLI command through the existing command infrastructure, and calls the existing TagImage COM API on the session.
Changes:
- Added
RepoTagmodel withParsemethod to split image references into repo and tag components, and implementedImageService::Tagto call theIWSLASession::TagImageCOM API. - Added
ImageTagCommandCLI command with source/target positional arguments, registered in bothImageCommandandRootCommand. - Added comprehensive E2E tests and unit tests for the new tag functionality and
RepoTag::Parse.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/windows/wslc/services/ImageModel.h | Added RepoTag struct with Parse static method |
| src/windows/wslc/services/ImageModel.cpp | Implemented RepoTag::Parse for splitting image references |
| src/windows/wslc/services/ImageService.h | Changed Tag() from stub instance method to static with parameters |
| src/windows/wslc/services/ImageService.cpp | Implemented Tag using RepoTag::Parse and TagImage COM call |
| src/windows/wslc/commands/ImageCommand.h | Added ImageTagCommand struct |
| src/windows/wslc/commands/ImageCommand.cpp | Registered ImageTagCommand under ImageCommand |
| src/windows/wslc/commands/ImageTagCommand.cpp | Implemented ImageTagCommand execution logic |
| src/windows/wslc/commands/RootCommand.cpp | Registered ImageTagCommand as top-level shortcut |
| src/windows/wslc/tasks/ImageTasks.h | Declared TagImage task function |
| src/windows/wslc/tasks/ImageTasks.cpp | Implemented TagImage task |
| src/windows/wslc/arguments/ArgumentDefinitions.h | Added Source and Target positional arguments |
| test/windows/wslc/WSLCCLIRepoTagUnitTests.cpp | Unit tests for RepoTag::Parse |
| test/windows/wslc/e2e/WSLCE2EHelpers.h | Added AlpineTestImage, VerifyImageIsListed declarations |
| test/windows/wslc/e2e/WSLCE2EHelpers.cpp | Implemented AlpineTestImage and VerifyImageIsListed |
| test/windows/wslc/e2e/WSLCE2EImageTagTests.cpp | E2E tests for image tag command |
| std::vector<std::tuple<std::string, std::string, std::string>> testCases = { | ||
| { "", "", "" }, | ||
| { "repo:", "repo", "" }, | ||
| { ":latest", "", "latest" }, |
There was a problem hiding this comment.
@OneBlue, should the CLI be responsible for handling invalid target input, or should the service validate that the target options are present and valid? The REST API marks the Repo and Tag options as optional, so we might not see the same error behavior as the Docker CLI in WSL
Docker
PS C:\> docker images
IMAGE ID DISK USAGE CONTENT SIZE EXTRA
debian:latest 24fb189462d7 258MB 124MB
PS C:\src\wsl> docker tag debian:latest :mock
error parsing reference: ":mock" is not a valid repository/tag: invalid reference formatWSLC
PS C:\> wslc images
+---------------+-----------+
| NAME | SIZE (MB) |
+---------------+-----------+
| debian:latest | 114.30 |
+---------------+-----------+
PS C:\> wslc tag debian:latest :mock
# Exit code: 0There was a problem hiding this comment.
@AmelBawa-msft: The service validates all the inputs it receives. If the CLI doesn't need to parse an input, it should let the service do it and handle errors
Summary of the Pull Request
wslc image tagPR Checklist
Detailed Description of the Pull Request / Additional comments
Validation Steps Performed