@@ -36,7 +36,7 @@ func WithAuthorization(handler, failed http.Handler, restMapper meta.RESTMapper,
36
36
37
37
matchingRules := (* matcher ).Match (input .Request )
38
38
if len (matchingRules ) == 0 {
39
- klog .V (3 ).InfoSDepth ( 1 ,
39
+ klog .FromContext ( ctx ). V (3 ).Info (
40
40
"request did not match any authorization rule" ,
41
41
"verb" , input .Request .Verb ,
42
42
"APIGroup" , input .Request .APIGroup ,
@@ -49,13 +49,13 @@ func WithAuthorization(handler, failed http.Handler, restMapper meta.RESTMapper,
49
49
// Apply CEL condition filtering
50
50
filteredRules , err := rules .FilterRulesWithCELConditions (matchingRules , input )
51
51
if err != nil {
52
- klog .V (2 ).ErrorS (err , "error evaluating CEL conditions" , "input" , input )
52
+ klog .FromContext ( ctx ). V (2 ).Error (err , "error evaluating CEL conditions" , "input" , input )
53
53
handleError (w , failed , req , err )
54
54
return
55
55
}
56
56
57
57
if len (filteredRules ) == 0 {
58
- klog .V (3 ).InfoSDepth ( 1 ,
58
+ klog .FromContext ( ctx ). V (3 ).Info (
59
59
"request matched authorization rule/s but failed CEL conditions" ,
60
60
"verb" , input .Request .Verb ,
61
61
"APIGroup" , input .Request .APIGroup ,
@@ -65,40 +65,40 @@ func WithAuthorization(handler, failed http.Handler, restMapper meta.RESTMapper,
65
65
return
66
66
}
67
67
68
- klog .V (3 ).InfoSDepth ( 1 ,
68
+ klog .FromContext ( ctx ). V (3 ).Info (
69
69
"request matched authorization rule/s and passed CEL conditions" ,
70
70
"verb" , input .Request .Verb ,
71
71
"APIGroup" , input .Request .APIGroup ,
72
72
"APIVersion" , input .Request .APIVersion ,
73
73
"Resource" , input .Request .Resource )
74
- klog .V (4 ).InfoSDepth ( 1 , "authorization input details" , "input" , input )
74
+ klog .FromContext ( ctx ). V (4 ).Info ( "authorization input details" , "input" , input )
75
75
76
76
// run all checks for this request
77
77
if err := runAllMatchingChecks (ctx , filteredRules , input , permissionsClient ); err != nil {
78
- klog .V (2 ).ErrorS (err , "input failed authorization checks" , "input" , input )
78
+ klog .FromContext ( ctx ). V (2 ).Error (err , "input failed authorization checks" , "input" , input )
79
79
handleError (w , failed , req , err )
80
80
return
81
81
}
82
- klog .V (3 ).InfoSDepth ( 1 , "input passed all authorization checks" , "input" , input )
82
+ klog .FromContext ( ctx ). V (3 ).Info ( "input passed all authorization checks" , "input" , input )
83
83
84
84
// if this request is a write, perform the dual write and return
85
85
rule , err := getSingleUpdateRule (filteredRules )
86
86
if err != nil {
87
- klog .V (2 ).ErrorS (err , "unable to get single update rule" , "input" , input )
87
+ klog .FromContext ( ctx ). V (2 ).Error (err , "unable to get single update rule" , "input" , input )
88
88
handleError (w , failed , req , err )
89
89
return
90
90
}
91
91
92
92
if rule != nil {
93
- klog .V (4 ).InfoSDepth ( 1 , "single update rule" , "rule" , rule )
93
+ klog .FromContext ( ctx ). V (4 ).Info ( "single update rule" , "rule" , rule )
94
94
if err := performUpdate (ctx , w , rule , input , req .RequestURI , workflowClient ); err != nil {
95
- klog .V (2 ).ErrorS (err , "failed to perform update" , "input" , input )
95
+ klog .FromContext ( ctx ). V (2 ).Error (err , "failed to perform update" , "input" , input )
96
96
handleError (w , failed , req , err )
97
97
return
98
98
}
99
99
return
100
100
} else {
101
- klog .V (4 ).InfoSDepth ( 1 , "no update rule found for request" )
101
+ klog .FromContext ( ctx ). V (4 ).Info ( "no update rule found for request" )
102
102
}
103
103
104
104
// all other requests are filtered by matching rules
@@ -186,12 +186,12 @@ func createPostCheckHandler(handler, failed http.Handler, ctx context.Context, f
186
186
if recorder .statusCode >= 200 && recorder .statusCode < 300 {
187
187
// Run PostChecks
188
188
if err := runAllMatchingPostChecks (ctx , filteredRules , input , permissionsClient ); err != nil {
189
- klog .V (2 ).ErrorS (err , "input failed post-authorization checks" , "input" , input )
189
+ klog .FromContext ( ctx ). V (2 ).Error (err , "input failed post-authorization checks" , "input" , input )
190
190
// Return the original error handler instead of the successful response
191
191
failed .ServeHTTP (w , req )
192
192
return
193
193
}
194
- klog .V (3 ).InfoSDepth ( 1 , "input passed all post-authorization checks" , "input" , input )
194
+ klog .FromContext ( ctx ). V (3 ).Info ( "input passed all post-authorization checks" , "input" , input )
195
195
196
196
// Only write the successful response if PostChecks passed
197
197
recorder .emitResponseToWriter (w )
@@ -216,7 +216,7 @@ func createPostFilterHandler(handler, failed http.Handler, ctx context.Context,
216
216
if input .Request .Verb == "list" {
217
217
// Handle list operations
218
218
if err := filterListResponse (ctx , recorder , filteredRules , input , permissionsClient ); err != nil {
219
- klog .V (2 ).ErrorS (err , "failed to filter list response" , "input" , input )
219
+ klog .FromContext ( ctx ). V (2 ).Error (err , "failed to filter list response" , "input" , input )
220
220
failed .ServeHTTP (w , req )
221
221
return
222
222
}
@@ -288,7 +288,7 @@ func (r *responseRecorder) emitResponseToWriter(w http.ResponseWriter) {
288
288
// Write body
289
289
if len (r .body ) > 0 {
290
290
if _ , err := w .Write (r .body ); err != nil {
291
- klog .ErrorS (err , "failed to write response body" , "status_code" , statusCode , "body_length" , len (r .body ))
291
+ klog .Error (err , "failed to write response body" , "status_code" , statusCode , "body_length" , len (r .body ))
292
292
}
293
293
}
294
294
}
0 commit comments