Ensure tcp route parents are unique

pull/16926/head
jm96441n 2023-04-07 15:01:54 -04:00
parent 7a3d2d8669
commit ec3bcfe2bf
1 changed files with 10 additions and 0 deletions

View File

@ -150,6 +150,7 @@ func (e *HTTPRouteConfigEntry) Validate() error {
if !validParentKinds[parent.Kind] {
return fmt.Errorf("unsupported parent kind: %q, must be 'api-gateway'", parent.Kind)
}
if _, ok := uniques[parent]; ok {
return errors.New("route parents must be unique")
}
@ -541,10 +542,19 @@ func (e *TCPRouteConfigEntry) Validate() error {
if len(e.Services) > 1 {
return fmt.Errorf("tcp-route currently only supports one service")
}
uniques := make(map[ResourceReference]struct{}, len(e.Parents))
for _, parent := range e.Parents {
if !validParentKinds[parent.Kind] {
return fmt.Errorf("unsupported parent kind: %q, must be 'api-gateway'", parent.Kind)
}
if _, ok := uniques[parent]; ok {
return errors.New("route parents must be unique")
}
uniques[parent] = struct{}{}
}
if err := validateConfigEntryMeta(e.Meta); err != nil {