Refactor IsContainerNetworkMode into ParseContainerNetworkMode#40606
Merged
beena352 merged 3 commits intoMay 21, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Refactors container network mode handling by replacing a boolean IsContainerNetworkMode helper with ParseContainerNetworkMode, which parses and returns the container target identifier as an std::optional<std::string>.
Changes:
- Added
ParseContainerNetworkModeoverloads forLPCSTRandstd::string_view. - Updated call sites to use the new parser and removed manual prefix/substr parsing.
- Switched container-mode checks in a few places from boolean helper usage to optional presence checks.
kvega005
reviewed
May 20, 2026
kvega005
reviewed
May 20, 2026
kvega005
reviewed
May 20, 2026
Contributor
|
LGTM |
kvega005
approved these changes
May 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of the Pull Request
Replaces the IsContainerNetworkMode boolean helper with ParseContainerNetworkMode which returns the parsed target name directly. This eliminates duplicated prefix+substr+validate logic that was hand-rolled in multiple places.
PR Checklist
Detailed Description of the Pull Request / Additional comments
This is a followup PR to #40601 addressing review comment to consolidate the container network mode parsing logic.
The container:<name|id> prefix parsing was done in two different ways:
ParseContainerNetworkMode consolidates both patterns into a single function that returns std::optionalstd::string - the target name if the mode matches, std::nullopt otherwise. Two overloads are provided: one for LPCSTR (user-input paths) and one for std::string_view (Docker inspect recovery path).
Validation Steps Performed