Skip to content

Commit 4dddfe9

Browse files
committed
Add namespace and name field
1 parent 551eca3 commit 4dddfe9

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

pkg/webhook/admission/webhook.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ func (wh *Webhook) getLogger(req *Request) logr.Logger {
200200
func DefaultLogConstructor(base logr.Logger, req *Request) logr.Logger {
201201
if req != nil {
202202
return base.WithValues("object", klog.KRef(req.Namespace, req.Name),
203+
"namespace", req.Namespace, "name", req.Name,
203204
"resource", req.Resource, "user", req.UserInfo.Username,
204205
)
205206
}

pkg/webhook/admission/webhook_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ var _ = Describe("Admission Webhooks", func() {
172172
Expect(resp.Allowed).To(BeTrue())
173173

174174
By("checking that the log message contains the request fields")
175-
Eventually(logBuffer).Should(gbytes.Say(`"msg":"Received request","object":{"name":"foo","namespace":"bar"},"resource":{"group":"apps","version":"v1","resource":"deployments"},"user":"tim","requestID":"test123"}`))
175+
Eventually(logBuffer).Should(gbytes.Say(`"msg":"Received request","object":{"name":"foo","namespace":"bar"},"namespace":"bar","name":"foo","resource":{"group":"apps","version":"v1","resource":"deployments"},"user":"tim","requestID":"test123"}`))
176176
})
177177

178178
It("should pass a request logger created by LogConstructor via the context", func() {

0 commit comments

Comments
 (0)