Accept partition for ingress services

This commit is contained in:
freddygv 2021-11-08 10:40:09 -07:00
parent c05df587e5
commit dc7ea2ef1e
3 changed files with 8 additions and 7 deletions

View File

@ -266,10 +266,7 @@ func (e *IngressGatewayConfigEntry) Validate() error {
declaredHosts := make(map[string]bool) declaredHosts := make(map[string]bool)
serviceNames := make(map[ServiceID]struct{}) serviceNames := make(map[ServiceID]struct{})
for i, s := range listener.Services { for _, s := range listener.Services {
if err := validateInnerEnterpriseMeta(&s.EnterpriseMeta, &e.EnterpriseMeta); err != nil {
return fmt.Errorf("services[%d]: %w", i, err)
}
sn := NewServiceName(s.Name, &s.EnterpriseMeta) sn := NewServiceName(s.Name, &s.EnterpriseMeta)
if err := s.RequestHeaders.Validate(listener.Protocol); err != nil { if err := s.RequestHeaders.Validate(listener.Protocol); err != nil {
return fmt.Errorf("request headers %s (service %q on listener on port %d)", err, sn.String(), listener.Port) return fmt.Errorf("request headers %s (service %q on listener on port %d)", err, sn.String(), listener.Port)

View File

@ -103,12 +103,14 @@ type IngressService struct {
// using a "tcp" listener. // using a "tcp" listener.
Hosts []string Hosts []string
// Referencing other partitions is not supported.
// Namespace is the namespace where the service is located. // Namespace is the namespace where the service is located.
// Namespacing is a Consul Enterprise feature. // Namespacing is a Consul Enterprise feature.
Namespace string `json:",omitempty"` Namespace string `json:",omitempty"`
// Partition is the partition where the service is located.
// Partitioning is a Consul Enterprise feature.
Partition string `json:",omitempty"`
// TLS allows specifying some TLS configuration per listener. // TLS allows specifying some TLS configuration per listener.
TLS *GatewayServiceTLSConfig `json:",omitempty"` TLS *GatewayServiceTLSConfig `json:",omitempty"`

View File

@ -964,7 +964,8 @@ func TestDecodeConfigEntry(t *testing.T) {
"Services": [ "Services": [
{ {
"Name": "web", "Name": "web",
"Namespace": "foo" "Namespace": "foo",
"Partition": "bar"
}, },
{ {
"Name": "db" "Name": "db"
@ -1001,6 +1002,7 @@ func TestDecodeConfigEntry(t *testing.T) {
{ {
Name: "web", Name: "web",
Namespace: "foo", Namespace: "foo",
Partition: "bar",
}, },
{ {
Name: "db", Name: "db",