1package api 2 3// IngressGatewayConfigEntry manages the configuration for an ingress service 4// with the given name. 5type IngressGatewayConfigEntry struct { 6 // Kind of the config entry. This should be set to api.IngressGateway. 7 Kind string 8 9 // Name is used to match the config entry with its associated ingress gateway 10 // service. This should match the name provided in the service definition. 11 Name string 12 13 // Namespace is the namespace the IngressGateway is associated with 14 // Namespacing is a Consul Enterprise feature. 15 Namespace string `json:",omitempty"` 16 17 // TLS holds the TLS configuration for this gateway. 18 TLS GatewayTLSConfig 19 20 // Listeners declares what ports the ingress gateway should listen on, and 21 // what services to associated to those ports. 22 Listeners []IngressListener 23 24 Meta map[string]string `json:",omitempty"` 25 26 // CreateIndex is the Raft index this entry was created at. This is a 27 // read-only field. 28 CreateIndex uint64 29 30 // ModifyIndex is used for the Check-And-Set operations and can also be fed 31 // back into the WaitIndex of the QueryOptions in order to perform blocking 32 // queries. 33 ModifyIndex uint64 34} 35 36type GatewayTLSConfig struct { 37 // Indicates that TLS should be enabled for this gateway service 38 Enabled bool 39} 40 41// IngressListener manages the configuration for a listener on a specific port. 42type IngressListener struct { 43 // Port declares the port on which the ingress gateway should listen for traffic. 44 Port int 45 46 // Protocol declares what type of traffic this listener is expected to 47 // receive. Depending on the protocol, a listener might support multiplexing 48 // services over a single port, or additional discovery chain features. The 49 // current supported values are: (tcp | http | http2 | grpc). 50 Protocol string 51 52 // Services declares the set of services to which the listener forwards 53 // traffic. 54 // 55 // For "tcp" protocol listeners, only a single service is allowed. 56 // For "http" listeners, multiple services can be declared. 57 Services []IngressService 58} 59 60// IngressService manages configuration for services that are exposed to 61// ingress traffic. 62type IngressService struct { 63 // Name declares the service to which traffic should be forwarded. 64 // 65 // This can either be a specific service, or the wildcard specifier, 66 // "*". If the wildcard specifier is provided, the listener must be of "http" 67 // protocol and means that the listener will forward traffic to all services. 68 // 69 // A name can be specified on multiple listeners, and will be exposed on both 70 // of the listeners 71 Name string 72 73 // Hosts is a list of hostnames which should be associated to this service on 74 // the defined listener. Only allowed on layer 7 protocols, this will be used 75 // to route traffic to the service by matching the Host header of the HTTP 76 // request. 77 // 78 // If a host is provided for a service that also has a wildcard specifier 79 // defined, the host will override the wildcard-specifier-provided 80 // "<service-name>.*" domain for that listener. 81 // 82 // This cannot be specified when using the wildcard specifier, "*", or when 83 // using a "tcp" listener. 84 Hosts []string 85 86 // Namespace is the namespace where the service is located. 87 // Namespacing is a Consul Enterprise feature. 88 Namespace string `json:",omitempty"` 89} 90 91func (i *IngressGatewayConfigEntry) GetKind() string { 92 return i.Kind 93} 94 95func (i *IngressGatewayConfigEntry) GetName() string { 96 return i.Name 97} 98 99func (i *IngressGatewayConfigEntry) GetNamespace() string { 100 return i.Namespace 101} 102 103func (i *IngressGatewayConfigEntry) GetMeta() map[string]string { 104 return i.Meta 105} 106 107func (i *IngressGatewayConfigEntry) GetCreateIndex() uint64 { 108 return i.CreateIndex 109} 110 111func (i *IngressGatewayConfigEntry) GetModifyIndex() uint64 { 112 return i.ModifyIndex 113} 114 115// TerminatingGatewayConfigEntry manages the configuration for a terminating gateway 116// with the given name. 117type TerminatingGatewayConfigEntry struct { 118 // Kind of the config entry. This should be set to api.TerminatingGateway. 119 Kind string 120 121 // Name is used to match the config entry with its associated terminating gateway 122 // service. This should match the name provided in the service definition. 123 Name string 124 125 // Services is a list of service names represented by the terminating gateway. 126 Services []LinkedService `json:",omitempty"` 127 128 Meta map[string]string `json:",omitempty"` 129 130 // CreateIndex is the Raft index this entry was created at. This is a 131 // read-only field. 132 CreateIndex uint64 133 134 // ModifyIndex is used for the Check-And-Set operations and can also be fed 135 // back into the WaitIndex of the QueryOptions in order to perform blocking 136 // queries. 137 ModifyIndex uint64 138 139 // Namespace is the namespace the config entry is associated with 140 // Namespacing is a Consul Enterprise feature. 141 Namespace string `json:",omitempty"` 142} 143 144// A LinkedService is a service represented by a terminating gateway 145type LinkedService struct { 146 // The namespace the service is registered in 147 Namespace string `json:",omitempty"` 148 149 // Name is the name of the service, as defined in Consul's catalog 150 Name string `json:",omitempty"` 151 152 // CAFile is the optional path to a CA certificate to use for TLS connections 153 // from the gateway to the linked service 154 CAFile string `json:",omitempty" alias:"ca_file"` 155 156 // CertFile is the optional path to a client certificate to use for TLS connections 157 // from the gateway to the linked service 158 CertFile string `json:",omitempty" alias:"cert_file"` 159 160 // KeyFile is the optional path to a private key to use for TLS connections 161 // from the gateway to the linked service 162 KeyFile string `json:",omitempty" alias:"key_file"` 163 164 // SNI is the optional name to specify during the TLS handshake with a linked service 165 SNI string `json:",omitempty"` 166} 167 168func (g *TerminatingGatewayConfigEntry) GetKind() string { 169 return g.Kind 170} 171 172func (g *TerminatingGatewayConfigEntry) GetName() string { 173 return g.Name 174} 175 176func (g *TerminatingGatewayConfigEntry) GetNamespace() string { 177 return g.Namespace 178} 179 180func (g *TerminatingGatewayConfigEntry) GetMeta() map[string]string { 181 return g.Meta 182} 183 184func (g *TerminatingGatewayConfigEntry) GetCreateIndex() uint64 { 185 return g.CreateIndex 186} 187 188func (g *TerminatingGatewayConfigEntry) GetModifyIndex() uint64 { 189 return g.ModifyIndex 190} 191