File tree 3 files changed +13
-0
lines changed
3 files changed +13
-0
lines changed Original file line number Diff line number Diff line change 1
1
use anyhow:: Result ;
2
+ use core:: fmt;
2
3
use policy_evaluator:: admission_response:: AdmissionResponse ;
3
4
use policy_evaluator:: policy_evaluator:: ValidateRequest ;
4
5
use std:: collections:: HashMap ;
@@ -13,6 +14,15 @@ pub(crate) enum RequestOrigin {
13
14
Audit ,
14
15
}
15
16
17
+ impl fmt:: Display for RequestOrigin {
18
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
19
+ match self {
20
+ RequestOrigin :: Validate => write ! ( f, "validate" ) ,
21
+ RequestOrigin :: Audit => write ! ( f, "audit" ) ,
22
+ }
23
+ }
24
+ }
25
+
16
26
#[ derive( Debug ) ]
17
27
pub ( crate ) struct EvalRequest {
18
28
pub policy_id : String ,
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ pub struct PolicyEvaluation {
32
32
pub ( crate ) resource_request_operation : String ,
33
33
pub ( crate ) accepted : bool ,
34
34
pub ( crate ) mutated : bool ,
35
+ pub ( crate ) request_origin : String ,
35
36
pub ( crate ) error_code : Option < u16 > ,
36
37
}
37
38
@@ -50,6 +51,7 @@ impl Into<Vec<KeyValue>> for &PolicyEvaluation {
50
51
) ,
51
52
KeyValue :: new( "accepted" , self . accepted) ,
52
53
KeyValue :: new( "mutated" , self . mutated) ,
54
+ KeyValue :: new( "request_origin" , self . request_origin. clone( ) ) ,
53
55
] ;
54
56
if let Some ( resource_namespace) = & self . resource_namespace {
55
57
baggage. append ( & mut vec ! [ KeyValue :: new(
Original file line number Diff line number Diff line change @@ -227,6 +227,7 @@ impl Worker {
227
227
resource_request_operation : adm_req. clone ( ) . operation ,
228
228
accepted,
229
229
mutated,
230
+ request_origin : req. request_origin . to_string ( ) ,
230
231
error_code,
231
232
} ;
232
233
metrics:: record_policy_latency ( policy_evaluation_duration, & policy_evaluation) ;
You can’t perform that action at this time.
0 commit comments