Skip to content

Commit

Permalink
refactor: better name variables in pkg/webhook/tenant
Browse files Browse the repository at this point in the history
  • Loading branch information
ludusrusso authored and prometherion committed May 4, 2021
1 parent e5f17d1 commit 34c9583
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pkg/webhook/tenant/validating.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,17 @@ func (h *handler) validateIngressHostnamesRegex(tenant *v1alpha1.Tenant) error {
func (h *handler) validateIngressHostnamesCollision(context context.Context, clt client.Client, tenant *v1alpha1.Tenant) error {
if h.checkIngressHostnamesExact && tenant.Spec.IngressHostnames != nil && len(tenant.Spec.IngressHostnames.Exact) > 0 {
for _, h := range tenant.Spec.IngressHostnames.Exact {
tl := &v1alpha1.TenantList{}
if err := clt.List(context, tl, client.MatchingFieldsSelector{
tntList := &v1alpha1.TenantList{}
if err := clt.List(context, tntList, client.MatchingFieldsSelector{
Selector: fields.OneTermEqualSelector(".spec.ingressHostnames", h),
}); err != nil {
return fmt.Errorf("cannot retrieve Tenant list using .spec.ingressHostnames field selector: %w", err)
}
switch {
case len(tl.Items) == 1 && tl.Items[0].GetName() == tenant.GetName():
case len(tntList.Items) == 1 && tntList.Items[0].GetName() == tenant.GetName():
continue
case len(tl.Items) > 0:
return fmt.Errorf("the allowed hostname %s is already used by the Tenant %s, cannot proceed", h, tl.Items[0].GetName())
case len(tntList.Items) > 0:
return fmt.Errorf("the allowed hostname %s is already used by the Tenant %s, cannot proceed", h, tntList.Items[0].GetName())
default:
continue
}
Expand Down

0 comments on commit 34c9583

Please sign in to comment.