1818use super :: authenticator:: Authenticator ;
1919use super :: principal:: { Principal , SandboxIdentitySource , SandboxPrincipal } ;
2020use async_trait:: async_trait;
21+ #[ cfg( any( not( target_os = "windows" ) , test) ) ]
2122use k8s_openapi:: api:: {
2223 authentication:: v1:: { TokenReview , TokenReviewSpec , TokenReviewStatus , UserInfo } ,
2324 core:: v1:: Pod ,
2425} ;
26+ #[ cfg( any( not( target_os = "windows" ) , test) ) ]
2527use k8s_openapi:: apimachinery:: pkg:: apis:: meta:: v1:: ObjectMeta ;
28+ #[ cfg( any( not( target_os = "windows" ) , test) ) ]
2629use kube:: Error as KubeError ;
30+ #[ cfg( not( target_os = "windows" ) ) ]
2731use kube:: api:: { Api , ApiResource , PostParams } ;
28- use kube:: core:: { DynamicObject , gvk:: GroupVersionKind } ;
32+ #[ cfg( any( not( target_os = "windows" ) , test) ) ]
33+ use kube:: core:: DynamicObject ;
34+ #[ cfg( not( target_os = "windows" ) ) ]
35+ use kube:: core:: gvk:: GroupVersionKind ;
2936use std:: sync:: Arc ;
3037use tonic:: Status ;
31- use tracing:: { debug, info, warn} ;
38+ #[ cfg( not( target_os = "windows" ) ) ]
39+ use tracing:: info;
40+ use tracing:: { debug, warn} ;
3241
3342/// gRPC method path that this authenticator accepts. All other paths fall
3443/// through (return `Ok(None)`) so a gateway-minted JWT is required there.
@@ -39,15 +48,25 @@ pub const ISSUE_SANDBOX_TOKEN_PATH: &str = "/openshell.v1.OpenShell/IssueSandbox
3948/// annotation only after validating the pod's `TokenReview` binding, live UID,
4049/// and owning Sandbox CR. The K8s `Role` granted to the gateway must not
4150/// include `patch pods` (see plan §11.8).
51+ #[ cfg( any( not( target_os = "windows" ) , test) ) ]
4252pub const SANDBOX_ID_ANNOTATION : & str = "openshell.io/sandbox-id" ;
53+ #[ cfg( any( not( target_os = "windows" ) , test) ) ]
4354const SANDBOX_API_GROUP : & str = "agents.x-k8s.io" ;
55+ #[ cfg( any( not( target_os = "windows" ) , test) ) ]
4456const SANDBOX_API_VERSION_V1BETA1 : & str = "v1beta1" ;
57+ #[ cfg( not( target_os = "windows" ) ) ]
4558const SANDBOX_API_VERSION_V1ALPHA1 : & str = "v1alpha1" ;
59+ #[ cfg( any( not( target_os = "windows" ) , test) ) ]
4660const SANDBOX_API_VERSION_FULL_V1BETA1 : & str = "agents.x-k8s.io/v1beta1" ;
61+ #[ cfg( any( not( target_os = "windows" ) , test) ) ]
4762const SANDBOX_API_VERSION_FULL_V1ALPHA1 : & str = "agents.x-k8s.io/v1alpha1" ;
63+ #[ cfg( any( not( target_os = "windows" ) , test) ) ]
4864const SANDBOX_KIND : & str = "Sandbox" ;
65+ #[ cfg( any( not( target_os = "windows" ) , test) ) ]
4966const SANDBOX_ID_LABEL : & str = "openshell.ai/sandbox-id" ;
67+ #[ cfg( any( not( target_os = "windows" ) , test) ) ]
5068const POD_NAME_EXTRA : & str = "authentication.kubernetes.io/pod-name" ;
69+ #[ cfg( any( not( target_os = "windows" ) , test) ) ]
5170const POD_UID_EXTRA : & str = "authentication.kubernetes.io/pod-uid" ;
5271
5372/// Resolved identity extracted from a validated SA token + pod lookup.
@@ -136,12 +155,14 @@ impl Authenticator for K8sServiceAccountAuthenticator {
136155}
137156
138157#[ derive( Debug ) ]
158+ #[ cfg( any( not( target_os = "windows" ) , test) ) ]
139159struct TokenReviewIdentity {
140160 pod_name : String ,
141161 pod_uid : String ,
142162}
143163
144164#[ derive( Debug , Clone , PartialEq , Eq ) ]
165+ #[ cfg( any( not( target_os = "windows" ) , test) ) ]
145166struct SandboxOwnerReference {
146167 api_version : String ,
147168 name : String ,
@@ -150,6 +171,7 @@ struct SandboxOwnerReference {
150171
151172/// Resolver backed by the apiserver's `TokenReview` API and `kube::Client`
152173/// for the per-pod annotation lookup.
174+ #[ cfg( not( target_os = "windows" ) ) ]
153175pub struct LiveK8sResolver {
154176 token_reviews_api : Api < TokenReview > ,
155177 pods_api : Api < Pod > ,
@@ -160,6 +182,7 @@ pub struct LiveK8sResolver {
160182 expected_service_account : String ,
161183}
162184
185+ #[ cfg( not( target_os = "windows" ) ) ]
163186impl LiveK8sResolver {
164187 pub fn new (
165188 client : kube:: Client ,
@@ -217,6 +240,7 @@ impl LiveK8sResolver {
217240}
218241
219242#[ async_trait]
243+ #[ cfg( not( target_os = "windows" ) ) ]
220244impl K8sIdentityResolver for LiveK8sResolver {
221245 async fn resolve ( & self , token : & str ) -> Result < Option < ResolvedK8sIdentity > , Status > {
222246 let review = TokenReview {
@@ -324,6 +348,7 @@ impl K8sIdentityResolver for LiveK8sResolver {
324348}
325349
326350#[ allow( clippy:: result_large_err) ]
351+ #[ cfg( any( not( target_os = "windows" ) , test) ) ]
327352fn token_review_identity (
328353 status : & TokenReviewStatus ,
329354 expected_audience : & str ,
@@ -376,6 +401,7 @@ fn token_review_identity(
376401}
377402
378403#[ allow( clippy:: result_large_err) ]
404+ #[ cfg( any( not( target_os = "windows" ) , test) ) ]
379405fn user_extra_one ( user : & UserInfo , key : & str ) -> Result < String , Status > {
380406 let Some ( values) = user. extra . as_ref ( ) . and_then ( |extra| extra. get ( key) ) else {
381407 return Err ( Status :: permission_denied ( "SA token is not pod-bound" ) ) ;
@@ -389,6 +415,7 @@ fn user_extra_one(user: &UserInfo, key: &str) -> Result<String, Status> {
389415}
390416
391417#[ allow( clippy:: result_large_err) ]
418+ #[ cfg( any( not( target_os = "windows" ) , test) ) ]
392419fn pod_sandbox_id ( pod : & Pod ) -> Result < String , Status > {
393420 let sandbox_id = pod
394421 . metadata
@@ -406,6 +433,7 @@ fn pod_sandbox_id(pod: &Pod) -> Result<String, Status> {
406433}
407434
408435#[ allow( clippy:: result_large_err) ]
436+ #[ cfg( any( not( target_os = "windows" ) , test) ) ]
409437fn sandbox_owner_reference ( pod : & Pod ) -> Result < SandboxOwnerReference , Status > {
410438 let owner_refs = pod. metadata . owner_references . as_deref ( ) . unwrap_or_default ( ) ;
411439 let mut sandbox_refs = owner_refs
@@ -453,6 +481,7 @@ fn sandbox_owner_reference(pod: &Pod) -> Result<SandboxOwnerReference, Status> {
453481 } )
454482}
455483
484+ #[ cfg( any( not( target_os = "windows" ) , test) ) ]
456485fn is_supported_sandbox_owner_reference (
457486 owner : & k8s_openapi:: apimachinery:: pkg:: apis:: meta:: v1:: OwnerReference ,
458487) -> bool {
@@ -463,6 +492,7 @@ fn is_supported_sandbox_owner_reference(
463492 )
464493}
465494
495+ #[ cfg( any( not( target_os = "windows" ) , test) ) ]
466496fn should_try_next_sandbox_api_version ( err : & KubeError ) -> bool {
467497 // Kubernetes returns a structured 404 for some missing API resources and a
468498 // raw "404 page not found" body for others. Both mean the probed
@@ -472,6 +502,7 @@ fn should_try_next_sandbox_api_version(err: &KubeError) -> bool {
472502}
473503
474504#[ allow( clippy:: result_large_err) ]
505+ #[ cfg( any( not( target_os = "windows" ) , test) ) ]
475506fn validate_sandbox_owner_reference (
476507 owner : & SandboxOwnerReference ,
477508 sandbox_id : & str ,
0 commit comments