Skip to content

Commit

Permalink
fix: protectedHandler OnDelete get tenant using client
Browse files Browse the repository at this point in the history
  • Loading branch information
Maksim Fedotov committed May 17, 2022
1 parent 2a1f489 commit 91d00e1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/webhook/tenant/protected.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"context"
"fmt"

"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/tools/record"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
Expand All @@ -28,10 +29,11 @@ func (h *protectedHandler) OnCreate(client.Client, *admission.Decoder, record.Ev
}
}

func (h *protectedHandler) OnDelete(_ client.Client, decoder *admission.Decoder, _ record.EventRecorder) capsulewebhook.Func {
func (h *protectedHandler) OnDelete(clt client.Client, decoder *admission.Decoder, _ record.EventRecorder) capsulewebhook.Func {
return func(ctx context.Context, req admission.Request) *admission.Response {
tenant := &capsulev1beta1.Tenant{}
if err := decoder.Decode(req, tenant); err != nil {

if err := clt.Get(ctx, types.NamespacedName{Name: req.AdmissionRequest.Name}, tenant); err != nil {
return utils.ErroredResponse(err)
}

Expand Down

0 comments on commit 91d00e1

Please sign in to comment.