Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
Signed-off-by: Mustafa Abdelrahman <mustafa.abdelrahman@zalando.de>
  • Loading branch information
MustafaSaber committed Nov 28, 2023
1 parent 1874366 commit 6df46c7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions dataclients/kubernetes/definitions/ingressvalidator.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func (igv *IngressV1Validator) Validate(item *IngressV1Item) error {
errs = append(errs, igv.validateFilterAnnotation(item.Metadata.Annotations))
errs = append(errs, igv.validatePredicateAnnotation(item.Metadata.Annotations))
errs = append(errs, igv.validateRoutesAnnotation(item.Metadata.Annotations))
errs = append(errs, igv.validateDuplicateHosts(item))
errs = append(errs, igv.validateHosts(item))

return errorsJoin(errs...)
}
Expand Down Expand Up @@ -52,7 +52,7 @@ func (igv *IngressV1Validator) validateRoutesAnnotation(annotations map[string]s
return nil
}

func (igv *IngressV1Validator) validateDuplicateHosts(item *IngressV1Item) error {
func (igv *IngressV1Validator) validateHosts(item *IngressV1Item) error {
var errs []error
uniqueHosts := make(map[string]struct{}, len(item.Spec.Rules))
for _, rule := range item.Spec.Rules {
Expand Down
12 changes: 6 additions & 6 deletions dataclients/kubernetes/definitions/routegroupvalidator.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (rgv *RouteGroupValidator) Validate(item *RouteGroupItem) error {
errs = append(errs, rgv.validateFilters(item))
errs = append(errs, rgv.validatePredicates(item))
errs = append(errs, rgv.validateBackends(item))
errs = append(errs, rgv.validateDuplicateHosts(item))
errs = append(errs, rgv.validateHosts(item))

return errorsJoin(errs...)
}
Expand Down Expand Up @@ -109,14 +109,14 @@ func (rgv *RouteGroupValidator) validateBackends(item *RouteGroupItem) error {
return errorsJoin(errs...)
}

func (rgv *RouteGroupValidator) validateDuplicateHosts(item *RouteGroupItem) error {
func (rgv *RouteGroupValidator) validateHosts(item *RouteGroupItem) error {
var errs []error
uniqueHosts := make(map[string]struct{}, len(item.Spec.Hosts))
for _, hosts := range item.Spec.Hosts {
if _, ok := uniqueHosts[hosts]; ok {
errs = append(errs, fmt.Errorf("duplicate host %q", hosts))
for _, host := range item.Spec.Hosts {
if _, ok := uniqueHosts[host]; ok {
errs = append(errs, fmt.Errorf("duplicate host %q", host))
}
uniqueHosts[hosts] = struct{}{}
uniqueHosts[host] = struct{}{}
}
return errorsJoin(errs...)
}
Expand Down

0 comments on commit 6df46c7

Please sign in to comment.