Skip to content

CLI: Add initial support for image tag command#14416

Open
AmelBawa-msft wants to merge 9 commits intofeature/wsl-for-appsfrom
user/amelbawa/image-tag
Open

CLI: Add initial support for image tag command#14416
AmelBawa-msft wants to merge 9 commits intofeature/wsl-for-appsfrom
user/amelbawa/image-tag

Conversation

@AmelBawa-msft
Copy link

@AmelBawa-msft AmelBawa-msft commented Mar 11, 2026

Summary of the Pull Request

  • Added support for wslc image tag

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

@AmelBawa-msft AmelBawa-msft marked this pull request as ready for review March 12, 2026 21:14
@AmelBawa-msft AmelBawa-msft requested a review from a team as a code owner March 12, 2026 21:14
Copilot AI review requested due to automatic review settings March 12, 2026 21:14
Copy link
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

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 RepoTag model with Parse method to split image references into repo and tag components, and implemented ImageService::Tag to call the IWSLASession::TagImage COM API.
  • Added ImageTagCommand CLI command with source/target positional arguments, registered in both ImageCommand and RootCommand.
  • 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" },
Copy link
Author

@AmelBawa-msft AmelBawa-msft Mar 12, 2026

Choose a reason for hiding this comment

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

@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 format

WSLC

PS C:\> wslc images
+---------------+-----------+
| NAME          | SIZE (MB) |
+---------------+-----------+
| debian:latest | 114.30    |
+---------------+-----------+
PS C:\> wslc tag debian:latest :mock
# Exit code: 0

Copy link
Collaborator

Choose a reason for hiding this comment

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

@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

Copilot AI review requested due to automatic review settings March 12, 2026 21:28
Copy link
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

Copilot reviewed 15 out of 15 changed files in this pull request and generated no new comments.

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