Add --label support to wslc image build#40837
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds --label/-l support to wslc image build by plumbing label arguments from the CLI through the client service layer into the session’s docker build invocation, and adds E2E coverage to validate the behavior.
Changes:
- Add
--label(-l) argument to the image build command and pass collected labels throughImageTasks→ImageService→ COM options. - Extend
WSLCBuildImageOptionsandWSLCSession::BuildImageto forward labels as repeated--labelarguments todocker build. - Add E2E tests validating successful label application and CLI label override behavior.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/windows/wslc/e2e/WSLCE2EImageBuildTests.cpp | Adds E2E coverage for image build --label (including override behavior). |
| src/windows/wslcsession/WSLCSession.cpp | Validates and forwards labels as --label arguments to the in-VM docker build call. |
| src/windows/wslc/tasks/ImageTasks.cpp | Collects label args for image build and forwards them to the service layer. |
| src/windows/wslc/services/ImageService.h | Extends ImageService::Build signature to accept labels. |
| src/windows/wslc/services/ImageService.cpp | Marshals label strings and populates the new labels field in build options. |
| src/windows/wslc/commands/ImageBuildCommand.cpp | Registers --label/-l as a supported image build argument. |
| src/windows/service/inc/wslc.idl | Adds Labels field to WSLCBuildImageOptions IDL struct. |
| auto tags = context.Args.GetAll<ArgType::Tag>(); | ||
| auto buildArgs = context.Args.GetAll<ArgType::BuildArg>(); | ||
| auto labels = context.Args.GetAll<ArgType::Label>(); |
| auto cancelEvent = context.CreateCancelEvent(); | ||
| BuildImageCallback callback(cancelEvent, context.Args.Contains(ArgType::Verbose)); | ||
| services::ImageService::Build(session, contextPath, tags, buildArgs, dockerfilePath, target, flags, &callback, cancelEvent); | ||
| services::ImageService::Build(session, contextPath, tags, buildArgs, labels, dockerfilePath, target, flags, &callback, cancelEvent); |
There was a problem hiding this comment.
For image build, do we need to call ParseLabel before passing them to the service API?
Example from other commands:
WSL/src/windows/wslc/tasks/ContainerTasks.cpp
Line 584 in 8e3c0ad
There was a problem hiding this comment.
Moby will validate it of course, but it is a good call to do this, especially for consistency. Thanks!
No description provided.