Skip to content

Add AdmissionRequest::to_cel_request() for VAP CEL bridging#1991

Merged
clux merged 2 commits into
kube-rs:mainfrom
doxxx93:feat/admission-to-cel-request
May 27, 2026
Merged

Add AdmissionRequest::to_cel_request() for VAP CEL bridging#1991
clux merged 2 commits into
kube-rs:mainfrom
doxxx93:feat/admission-to-cel-request

Conversation

@doxxx93
Copy link
Copy Markdown
Member

@doxxx93 doxxx93 commented May 27, 2026

Motivation

kube-cel's vap::AdmissionRequest is a flat projection of the VAP request variable, intentionally distinct from kube_core::admission::AdmissionRequest<T> (the webhook wire type: generic over T: Resource, carrying TypeMeta, 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 the cel feature, projecting the wire type into kube_cel::vap::AdmissionRequest. Webhook-only fields (object, oldObject, requestKind, subResource, options) are dropped. The carried uid is the user uid (userInfo.uid), matching VAP's request.userInfo.uid, not the round-trip request uid.

Test plan

cargo test -p kube-core --all-features --lib to_cel_request covers all four Operation variants, the userInfo.uid mapping, and GVK/GVR plus dry_run pass-through.

doxxx93 added 2 commits May 27, 2026 21:57
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
Copy link
Copy Markdown

codecov Bot commented May 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.7%. Comparing base (6f8d9f6) to head (dac134a).

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     
Files with missing lines Coverage Δ
kube-core/src/admission.rs 80.9% <100.0%> (+19.8%) ⬆️

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Member

@clux clux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thank you.

@clux clux added the changelog-add changelog added category for prs label May 27, 2026
@clux clux added this to the 4.0.0 milestone May 27, 2026
@clux clux merged commit d291bd5 into kube-rs:main May 27, 2026
19 checks passed
@clux clux changed the title feat(core): add AdmissionRequest::to_cel_request() for VAP CEL bridging Add AdmissionRequest::to_cel_request() for VAP CEL bridging May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog-add changelog added category for prs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants