diff --git a/agent/structs/config_entry_routes.go b/agent/structs/config_entry_routes.go index 15160f0e05e7..2bcbf94d82c6 100644 --- a/agent/structs/config_entry_routes.go +++ b/agent/structs/config_entry_routes.go @@ -4,6 +4,7 @@ package structs import ( + "errors" "fmt" "strings" @@ -143,10 +144,16 @@ func (e *HTTPRouteConfigEntry) Validate() error { APIGateway: true, } + 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 {