Add AdmissionRequest::to_cel_request() for VAP CEL bridging#1991
Merged
Conversation
Bridges kube_core::admission::AdmissionRequest<T> to kube_cel::vap::AdmissionRequest behind the `cel` feature, so webhook handlers can feed admission requests into client-side VAP evaluation. Refs kube-rs/kube-cel#4 Signed-off-by: doxxx93 <doxxx93@gmail.com>
The vap module that to_cel_request() projects into was added in kube-cel 0.5.1; the prior "0.5" requirement allowed 0.5.0 and broke the minimal-versions check. Refs kube-rs/kube-cel#4 Signed-off-by: doxxx93 <doxxx93@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1991 +/- ##
=======================================
+ Coverage 76.7% 76.7% +0.1%
=======================================
Files 89 89
Lines 8747 8784 +37
=======================================
+ Hits 6703 6736 +33
- Misses 2044 2048 +4
🚀 New features to boost your workflow:
|
AdmissionRequest::to_cel_request() for VAP CEL bridging
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.
Motivation
kube-cel'svap::AdmissionRequestis a flat projection of the VAPrequestvariable, intentionally distinct fromkube_core::admission::AdmissionRequest<T>(the webhook wire type: generic overT: Resource, carryingTypeMeta,object,oldObject, etc.). Webhook handlers that already hold the wire type had no ergonomic way to feed it into client-side VAP evaluation.Discussed in kube-rs/kube-cel#4, where we agreed on a bridge helper rather than lifting vap into kube-core (cel-rust is still 0.x and kube-cel absorbs that churn).
Solution
Add
AdmissionRequest::<T>::to_cel_request()behind thecelfeature, projecting the wire type intokube_cel::vap::AdmissionRequest. Webhook-only fields (object,oldObject,requestKind,subResource,options) are dropped. The carrieduidis the user uid (userInfo.uid), matching VAP'srequest.userInfo.uid, not the round-trip request uid.Test plan
cargo test -p kube-core --all-features --lib to_cel_requestcovers all fourOperationvariants, theuserInfo.uidmapping, and GVK/GVR plus dry_run pass-through.