diff --git a/agent/structs/config_entry_routes.go b/agent/structs/config_entry_routes.go index 2bcbf94d82..4d90833151 100644 --- a/agent/structs/config_entry_routes.go +++ b/agent/structs/config_entry_routes.go @@ -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 {