Report each blocking dependent once on delete#108
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe webhook validator now deduplicates blocking dependents before denying deletes, and the rule registry now avoids repeating the same rule key for one target GVR. Tests cover target indexing, blocker formatting, and blocker deduplication. ChangesDeletion deduplication
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/webhook/deletion_validator.go`:
- Around line 132-135: The blocker deduplication in dedupeBlockers is using the
rendered Kind/name string as the identity key, which can merge distinct
dependents that share a name across namespaces. Update listDependents and the
dedupeBlockers helper to deduplicate by a stable canonical object identity that
includes namespace and ideally GVR/UID, then format the human-readable Kind/name
message afterward. Keep the one-mention-per-dependent behavior intact while
avoiding collisions for cluster-scoped deletes and namespaced resources.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: cdfca272-3b26-48f8-862b-a99e8c08972d
📒 Files selected for processing (4)
internal/webhook/deletion_validator.gointernal/webhook/deletion_validator_test.gointernal/webhook/rule_registry.gointernal/webhook/rule_registry_test.go
Signed-off-by: Cyrill Berg <cyrill.berg@opendefense.cloud>
Summary
Currently the webhook reports the same resource multiple times depending on the registry and the existing dependencyRules.
This PR fixes both issues by deduping entries in the registry as well as in the webhook validator response.
Related issue
Fixes #106
Summary by CodeRabbit
FindByTargetGVRresults.