From 9f33c8dbd4dec9f5a730cd444ed03b76970e9425 Mon Sep 17 00:00:00 2001 From: Stefan Bueringer Date: Wed, 6 Jul 2022 08:57:02 +0200 Subject: [PATCH] address review finding --- pkg/webhook/admission/defaulter_custom.go | 2 +- pkg/webhook/admission/validator_custom.go | 2 +- pkg/webhook/admission/webhook.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/webhook/admission/defaulter_custom.go b/pkg/webhook/admission/defaulter_custom.go index efb5f0b6e4..56c262988f 100644 --- a/pkg/webhook/admission/defaulter_custom.go +++ b/pkg/webhook/admission/defaulter_custom.go @@ -60,7 +60,7 @@ func (h *defaulterForType) Handle(ctx context.Context, req Request) Response { panic("object should never be nil") } - ctx = newContext(ctx, req) + ctx = newContextWithRequest(ctx, req) // Get the object in the request obj := h.object.DeepCopyObject() diff --git a/pkg/webhook/admission/validator_custom.go b/pkg/webhook/admission/validator_custom.go index 9ff9f9f3b6..978b2bcbf3 100644 --- a/pkg/webhook/admission/validator_custom.go +++ b/pkg/webhook/admission/validator_custom.go @@ -64,7 +64,7 @@ func (h *validatorForType) Handle(ctx context.Context, req Request) Response { panic("object should never be nil") } - ctx = newContext(ctx, req) + ctx = newContextWithRequest(ctx, req) // Get the object in the request obj := h.object.DeepCopyObject() diff --git a/pkg/webhook/admission/webhook.go b/pkg/webhook/admission/webhook.go index 166131684e..baa83d66f1 100644 --- a/pkg/webhook/admission/webhook.go +++ b/pkg/webhook/admission/webhook.go @@ -266,8 +266,8 @@ func RequestFromContext(ctx context.Context) (Request, error) { return Request{}, errors.New("admission.Request not found in context") } -// newContext returns a new Context, derived from ctx, which carries the +// newContextWithRequest returns a new Context, derived from ctx, which carries the // provided admission.Request. -func newContext(ctx context.Context, req Request) context.Context { +func newContextWithRequest(ctx context.Context, req Request) context.Context { return context.WithValue(ctx, requestContextKey{}, req) }