Duplicated code, can be easily removed (#119)

This commit is contained in:
Dario Tranchitella
2020-10-31 12:50:51 +01:00
committed by GitHub
parent 2af568f0ed
commit 39d6638669
-7
View File
@@ -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)
}