From 39d663866970acd74862d17cdcc22824cf102f9b Mon Sep 17 00:00:00 2001 From: Dario Tranchitella Date: Sat, 31 Oct 2020 12:50:51 +0100 Subject: [PATCH] Duplicated code, can be easily removed (#119) --- pkg/webhook/tenant_prefix/patching.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/pkg/webhook/tenant_prefix/patching.go b/pkg/webhook/tenant_prefix/patching.go index 2cf5788d..9547eaee 100644 --- a/pkg/webhook/tenant_prefix/patching.go +++ b/pkg/webhook/tenant_prefix/patching.go @@ -89,13 +89,6 @@ func (r *handler) OnCreate(clt client.Client, decoder *admission.Decoder) capsul if err := clt.Get(ctx, types.NamespacedName{Name: or.Name}, t); err != nil { return admission.Errored(http.StatusBadRequest, err) } - t := &v1alpha1.Tenant{} - for _, or := range ns.ObjectMeta.OwnerReferences { - // retrieving the selected Tenant - if err := clt.Get(ctx, types.NamespacedName{Name: or.Name}, t); err != nil { - return admission.Errored(http.StatusBadRequest, err) - } - } if e := t.GetName() + "-" + ns.GetName(); !strings.HasPrefix(ns.GetName(), t.GetName()+"-") { return admission.Denied("The namespace doesn't match the tenant prefix, expected " + e) }