wslc: add --size to inspect for docker parity - #41489
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds Docker parity support for --size / -s on wslc inspect and wslc container inspect, plumbing the flag through CLI parsing → service/COM → Docker Engine API, and ensuring the size fields are omitted (not null) when --size isn’t provided.
Changes:
- Introduces
ArgType::Sizeand wires--size/-sinto rootinspectandcontainer inspect, including Docker-like warnings when used on non-container types viawslc inspect. - Extends container inspect schema (
SizeRw,SizeRootFs) asstd::optional<int64_t>and addswslc_schema::ToInspectJson()to omit keys when absent. - Updates internal container inspect plumbing (IDL + session/container + HTTP client query param) and adds/updates unit + E2E coverage.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/windows/WSLCTests.cpp | Updates COM Inspect call site for new Size parameter. |
| test/windows/wslc/WSLCCLICommandUnitTests.cpp | Adds unit coverage ensuring --size/-s is present only on the intended inspect commands. |
| test/windows/wslc/e2e/WSLCE2EInspectTests.cpp | Adds E2E coverage for --size warning behavior on non-container types. |
| test/windows/wslc/e2e/WSLCE2EContainerInspectTests.cpp | Adds E2E coverage for presence/absence of SizeRw/SizeRootFs and help text. |
| test/windows/wslc/CommandLineTestCases.h | Adds parser test cases for --size support and rejection on type-specific inspect subcommands. |
| src/windows/wslcsession/WSLCContainer.h | Extends container inspect APIs to accept a Size flag and adds compat overload. |
| src/windows/wslcsession/WSLCContainer.cpp | Plumbs Size through to Docker inspect and maps returned size fields into WSLC schema. |
| src/windows/wslcsession/DockerHTTPClient.h | Extends InspectContainer signature to accept Size. |
| src/windows/wslcsession/DockerHTTPClient.cpp | Adds size query parameter forwarding to Docker Engine API. |
| src/windows/wslc/tasks/InspectTasks.cpp | Adds --size handling, warning behavior, and JSON emission with omitted size keys when absent. |
| src/windows/wslc/tasks/ContainerTasks.cpp | Adds --size handling for container inspect and emits JSON via ToInspectJson. |
| src/windows/wslc/services/ContainerService.h | Extends Inspect service API to accept size. |
| src/windows/wslc/services/ContainerService.cpp | Passes size to COM IWSLCContainer::Inspect. |
| src/windows/wslc/commands/InspectCommand.cpp | Registers --size on root inspect. |
| src/windows/wslc/commands/ContainerInspectCommand.cpp | Registers --size on container inspect. |
| src/windows/wslc/arguments/ArgumentDefinitions.h | Adds ArgType::Size (--size, alias -s) with localized description. |
| src/windows/service/inc/wslc.idl | Updates internal IWSLCContainer::Inspect to include [in] BOOL Size. |
| src/windows/inc/wslc_schema.h | Adds optional size fields and ToInspectJson() helper to omit absent size keys. |
| src/windows/inc/docker_schema.h | Extends Docker inspect schema to deserialize optional size fields. |
| src/windows/common/WSLCContainerLauncher.cpp | Updates internal inspect call site to pass FALSE for Size. |
| localization/strings/en-US/Resources.resw | Adds localized strings for --size description and ignored warning. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 20 out of 20 changed files in this pull request and generated no new comments.
Suppressed comments (1)
localization/strings/en-US/Resources.resw:3319
- The RESW for this new string does not follow the required token order/content produced by tools/devops/validate-localization.py (it expects {FixedPlaceholder="{}"} first, then {Locked="..."}, then the canonical sentence). As written, localization validation is likely to flag this entry.
<comment>{Locked="--size"}{FixedPlaceholder="{}"}Command line arguments and string inserts should not be translated</comment>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
The Docker Engine size query parameter is currently sent even when false, which is unnecessary and slightly undermines the PR’s stated Docker parity goal.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 20/20 changed files
- Comments generated: 1
- Review effort level: Lite
Summary of the Pull Request
Adds the
--size/-sflag towslc inspectandwslc container inspectfor Docker CLI parity. When specified, the container inspect output gains theSizeRwandSizeRootFsfields reported by the Docker Engine API.Docker also prints
WARNING: --size ignored for <type>to stderr when--sizeis used against a non-container object and still inspects the object. That behavior is mirrored here forimage,network, andvolumeinspect via the rootwslc inspectcommand. The type-specificwslc image inspect/network inspect/volume inspectsubcommands do not register--sizeat all, so passing it there is a parse error.PR Checklist
Detailed Description of the Pull Request / Additional comments
Fields are omitted, not null, when
--sizeis absentDocker only emits
SizeRw/SizeRootFswhen--sizeis passed. To match that — and to avoid changing the shape of the defaultwslc inspectoutput — the schema fields arestd::optional<std::int64_t>and a newwslc_schema::ToInspectJson(const InspectContainer&)helper erases the keys when they arenullopt.NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULTserializes an empty optional asnullrather than omitting it, hence the explicit helper.Plumbing
ArgumentDefinitions.h— newArgType::Size(--size, aliass).docker_schema.h/wslc_schema.h—InspectContainergains the two optional fields.DockerHTTPClient::InspectContainer(Id, Size)— forwardssizeas a query parameter to the Engine API.wslc.idl—IWSLCContainer::Inspectgains an[in] BOOL Sizeparameter. This is an internal, non-stable interface rebuilt in lockstep with its clients. The ABI-frozenIWSLCCompatContainer::Inspectis unchanged;WSLCContainernow provides a separate compat overload that forwards withSize = FALSE.ContainerService::Inspect(session, id, size)and theinspect/container inspecttasks read the flag.Tests
image inspect --size,network inspect --size, andvolume inspect --sizeare rejected.InspectCommands_HaveSizeArgumentWithDockerAliasunit test covering all five inspect commands.WSLCE2E_Container_Inspect_SizeOption,WSLCE2E_Container_Inspect_SizeListedInHelp,WSLCE2E_Inspect_SizeIgnoredForNonContainerTypes.Validation Steps Performed
Full
cmake --build .succeeds. Automated coverage above; CI runs the test suite.