Merge remote-tracking branch 'origin/dev/v2.1' into refactor/canonical-path-classifiers - #478
Conversation
isNodeUpdatePath was defined identically in internal/filter and internal/ownership, and isLibpodPath was defined identically (modulo a prefix-slash convention difference) in internal/filter and internal/responsefilter. Neither package can host the canonical copy for the others without an import cycle, since internal/ownership and internal/responsefilter both already import internal/filter. A new leaf package, internal/apipath, has no sockguard-internal dependencies, so all three can import it. The old package-local names stay as one-line wrappers so call sites are unchanged.
…ractors containerIdentifier, execIdentifier, networkIdentifier, volumeIdentifier, serviceIdentifier, taskIdentifier, secretIdentifier, configIdentifier, and nodeIdentifier in internal/ownership/paths.go each repeated the same prefix-strip-and-cut shape, differing only in the resource prefix and which collection-action names (create, prune, json) are excluded from being read as an identifier. They now delegate to one parameterized resourceIdentifier helper; each of the nine keeps its name and signature as a one-line wrapper, so no call site changes. imageIdentifier is untouched: its suffix-trimming logic for slash-containing image references does not fit the shared shape.
…l-path-classifiers
|
Deployment failed for project sockguard-website with the following error: Learn More: https://vercel.com/codeswhat?upgradeToPro=build-rate-limit |
|
Deployment failed for project sockguard-website with the following error: Learn More: https://vercel.com/codeswhat?upgradeToPro=build-rate-limit |
biggest-littlest
left a comment
There was a problem hiding this comment.
Reviewed against the CHANGELOG entry and the diff; CI green outside the qlty/Vercel quota noise.
ALARGECOMPANY
left a comment
There was a problem hiding this comment.
Reviewed against the CHANGELOG entry and the diff; CI green outside the qlty/Vercel quota noise.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Team Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (7)
📝 WalkthroughWalkthroughThe change adds a leaf Suggested labels: ✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This is a behavior-preserving refactor, no functional change.
isNodeUpdatePath was defined identically in internal/filter and internal/ownership, and isLibpodPath was defined identically (just a different prefix-slash convention) in internal/filter and internal/responsefilter. Neither of those packages can host the shared copy for the others without an import cycle, since internal/ownership and internal/responsefilter both already import internal/filter. So this adds a new leaf package, internal/apipath, with no sockguard-internal imports, and moves both predicates there. The old package-local isNodeUpdatePath/isLibpodPath names stay as one-line wrappers, so every existing call site is unchanged. Separately, internal/ownership/paths.go had nine near-identical identifier extractors (containerIdentifier, execIdentifier, networkIdentifier, volumeIdentifier, serviceIdentifier, taskIdentifier, secretIdentifier, configIdentifier, nodeIdentifier) that all did the same prefix-strip-and-cut, differing only in the resource prefix and which collection-action names (create, prune, json) don't count as an identifier. Those now delegate to one parameterized resourceIdentifier helper, again with each of the nine kept as a one-line wrapper. imageIdentifier wasn't touched, its suffix-trimming for slash-containing image references doesn't fit the shared shape.
Tests: TestIsLibpodPath and TestIsNodeUpdatePath in the new internal/apipath package cover the moved predicates directly (TestIsLibpodPath moved over from internal/filter's libpod_normalize_test.go; TestIsNodeUpdatePath is new, since neither internal/filter nor internal/ownership had a standalone test for it before, only coverage through larger flows). The existing tests that exercised these predicates as part of broader behavior keep passing unchanged: internal/filter's TestLibpodMatchersNeverMatchDockerPathsAndViceVersa and TestLibpodPathAdversarial, internal/responsefilter's TestLibpodPathPredicates, and internal/ownership's TestDockerCollectionRoutesAreNotResourceIdentifiers, TestContainerIdentifierCollectionKeywordBoundaries, TestNetworkIdentifierCollectionKeywordBoundaries, TestVolumeIdentifierCollectionKeywordBoundaries, TestNodeIdentifierEmpty, and TestIdentifierHelpers. CHANGELOG entry is under Changed.
Changelog
internal/apipathwith sharedIsLibpodPathandIsNodeUpdatePathpredicates.resourceIdentifierhelper.imageIdentifier.Concerns
apipath.IsLibpodPathandapipath.IsNodeUpdatePath.TestIsLibpodPath.resourceIdentifierexcludes every collection action previously excluded by the nine dedicated implementations.