mirror of
https://github.com/projectcapsule/capsule.git
synced 2026-02-14 18:09:58 +00:00
fix: protectedHandler OnDelete get tenant using client
This commit is contained in:
committed by
Dario Tranchitella
parent
bf6760fbd0
commit
3c9228d1aa
@@ -18,7 +18,7 @@ import (
|
||||
var _ = Describe("Deleting a tenant with protected annotation", func() {
|
||||
tnt := &capsulev1beta1.Tenant{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "protected_tenant",
|
||||
Name: "protected-tenant",
|
||||
Annotations: map[string]string{
|
||||
capsulev1beta1.ProtectedTenantAnnotation: "",
|
||||
},
|
||||
|
||||
@@ -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"
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user