Skip to content

Add --label support to wslc image build#40837

Open
johnstep wants to merge 1 commit into
masterfrom
user/johnstep/wslc-build-label
Open

Add --label support to wslc image build#40837
johnstep wants to merge 1 commit into
masterfrom
user/johnstep/wslc-build-label

Conversation

@johnstep

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings June 17, 2026 20:47
@johnstep johnstep requested a review from a team as a code owner June 17, 2026 20:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 --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 through ImageTasksImageService → COM options.
  • Extend WSLCBuildImageOptions and WSLCSession::BuildImage to forward labels as repeated --label arguments to docker 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.

Comment on lines 64 to +66
auto tags = context.Args.GetAll<ArgType::Tag>();
auto buildArgs = context.Args.GetAll<ArgType::BuildArg>();
auto labels = context.Args.GetAll<ArgType::Label>();
Comment thread src/windows/service/inc/wslc.idl
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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For image build, do we need to call ParseLabel before passing them to the service API?

Example from other commands:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Moby will validate it of course, but it is a good call to do this, especially for consistency. Thanks!

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