mirror of
https://github.com/projectcapsule/capsule.git
synced 2026-08-25 16:07:24 +00:00
refactor: better name variables in pkg/webhook/tenantprefix
This commit is contained in:
committed by
Dario Tranchitella
parent
34c958371b
commit
36c90d485e
@@ -84,13 +84,13 @@ func (r *handler) OnCreate(clt client.Client, decoder *admission.Decoder) capsul
|
||||
return admission.Allowed("")
|
||||
}
|
||||
|
||||
t := &v1alpha1.Tenant{}
|
||||
tnt := &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 {
|
||||
if err := clt.Get(ctx, types.NamespacedName{Name: or.Name}, tnt); err != nil {
|
||||
return admission.Errored(http.StatusBadRequest, err)
|
||||
}
|
||||
if e := fmt.Sprintf("%s-%s", t.GetName(), ns.GetName()); !strings.HasPrefix(ns.GetName(), fmt.Sprintf("%s-", t.GetName())) {
|
||||
if e := fmt.Sprintf("%s-%s", tnt.GetName(), ns.GetName()); !strings.HasPrefix(ns.GetName(), fmt.Sprintf("%s-", tnt.GetName())) {
|
||||
return admission.Denied("The namespace doesn't match the tenant prefix, expected " + e)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user