@@ -56,9 +56,20 @@ type GatewayContext struct {
5656
5757type HTTPRouteContext struct {
5858 gatewayv1.HTTPRoute
59- // IngressNginx contains ingress-nginx-specific IR data for kgateway emitter
60- IngressNginx * IngressNginxHTTPRouteIR
61- // RuleBackendSources tracks the source Ingress resources for each backend
59+
60+ // PoliciesBySourceIngressName stores feature policy data keyed by source Ingress name.
61+ PoliciesBySourceIngressName map [string ]Policy
62+
63+ // RegexLocationForHost is true when regex location matching should be used for the route host.
64+ RegexLocationForHost * bool
65+
66+ // RegexForcedByUseRegex is true when RegexLocationForHost is driven by use-regex annotation.
67+ RegexForcedByUseRegex bool
68+
69+ // RegexForcedByRewrite is true when RegexLocationForHost is driven by rewrite-target annotation.
70+ RegexForcedByRewrite bool
71+
72+ // RuleBackendSources tracks the source Ingress resources for each backend.
6273 RuleBackendSources [][]BackendSource
6374}
6475
@@ -104,38 +115,14 @@ type ReferenceGrantContext struct {
104115 gatewayv1beta1.ReferenceGrant
105116}
106117
107- // IngressNginxGatewayIR is the emitter-side ingress-nginx gateway IR.
108- type IngressNginxGatewayIR struct {}
109-
110- // IngressNginxServiceIR is the emitter-side ingress-nginx service IR.
111- type IngressNginxServiceIR struct {}
112-
113- // IngressNginxHTTPRouteIR contains ingress-nginx-specific fields for HTTPRoute.
114- type IngressNginxHTTPRouteIR struct {
115- // Policies keyed by source Ingress name.
116- Policies map [string ]IngressNginxPolicy
117-
118- // RegexLocationForHost is true when ingress-nginx would enforce the "~*" (case-insensitive)
119- // regex location modifier for all paths under a host.
120- RegexLocationForHost * bool
121-
122- // RegexForcedByUseRegex is true when RegexLocationForHost is true specifically
123- // because of the nginx.ingress.kubernetes.io/use-regex annotation.
124- RegexForcedByUseRegex bool
125-
126- // RegexForcedByRewrite is true when RegexLocationForHost is true specifically
127- // because of the nginx.ingress.kubernetes.io/rewrite-target annotation.
128- RegexForcedByRewrite bool
129- }
130-
131- // IngressNginxPolicyIndex identifies a (rule, backend) pair within a merged HTTPRoute.
132- type IngressNginxPolicyIndex struct {
118+ // PolicyIndex identifies a (rule, backend) pair within a merged HTTPRoute.
119+ type PolicyIndex struct {
133120 Rule int
134121 Backend int
135122}
136123
137- // IngressNginxCorsPolicy defines a CORS policy extracted from ingress-nginx annotations.
138- type IngressNginxCorsPolicy struct {
124+ // CorsPolicy defines a CORS policy extracted from annotations.
125+ type CorsPolicy struct {
139126 Enable bool
140127 AllowOrigin []string
141128 AllowCredentials * bool
@@ -145,20 +132,20 @@ type IngressNginxCorsPolicy struct {
145132 MaxAge * int32
146133}
147134
148- // IngressNginxExtAuthPolicy defines an external auth policy extracted from ingress-nginx annotations.
149- type IngressNginxExtAuthPolicy struct {
135+ // ExtAuthPolicy defines an external auth policy extracted from annotations.
136+ type ExtAuthPolicy struct {
150137 AuthURL string
151138 ResponseHeaders []string
152139}
153140
154- // IngressNginxBasicAuthPolicy defines a basic auth policy extracted from ingress-nginx annotations.
155- type IngressNginxBasicAuthPolicy struct {
141+ // BasicAuthPolicy defines a basic auth policy extracted from annotations.
142+ type BasicAuthPolicy struct {
156143 SecretName string
157144 AuthType string
158145}
159146
160- // IngressNginxSessionAffinityPolicy defines a session affinity policy extracted from ingress-nginx annotations.
161- type IngressNginxSessionAffinityPolicy struct {
147+ // SessionAffinityPolicy defines a session affinity policy extracted from annotations.
148+ type SessionAffinityPolicy struct {
162149 CookieName string
163150 CookiePath string
164151 CookieDomain string
@@ -167,99 +154,99 @@ type IngressNginxSessionAffinityPolicy struct {
167154 CookieSecure * bool
168155}
169156
170- // IngressNginxBackendTLSPolicy defines a backend TLS policy extracted from ingress-nginx annotations.
171- type IngressNginxBackendTLSPolicy struct {
157+ // BackendTLSPolicy defines a backend TLS policy extracted from annotations.
158+ type BackendTLSPolicy struct {
172159 SecretName string
173160 Verify bool
174161 Hostname string
175162}
176163
177- // IngressNginxPolicy describes per-Ingress policy knobs projected from ingress-nginx .
178- type IngressNginxPolicy struct {
164+ // Policy describes per-Ingress policy knobs projected by providers .
165+ type Policy struct {
179166 ClientBodyBufferSize * resource.Quantity
180167 ProxyBodySize * resource.Quantity
181- Cors * IngressNginxCorsPolicy
182- RateLimit * IngressNginxRateLimitPolicy
168+ Cors * CorsPolicy
169+ RateLimit * RateLimitPolicy
183170 ProxySendTimeout * metav1.Duration
184171 ProxyReadTimeout * metav1.Duration
185172 ProxyConnectTimeout * metav1.Duration
186173 EnableAccessLog * bool
187- ExtAuth * IngressNginxExtAuthPolicy
188- BasicAuth * IngressNginxBasicAuthPolicy
189- SessionAffinity * IngressNginxSessionAffinityPolicy
190- LoadBalancing * IngressNginxBackendLoadBalancingPolicy
191- BackendTLS * IngressNginxBackendTLSPolicy
192- BackendProtocol * IngressNginxBackendProtocol
174+ ExtAuth * ExtAuthPolicy
175+ BasicAuth * BasicAuthPolicy
176+ SessionAffinity * SessionAffinityPolicy
177+ LoadBalancing * BackendLoadBalancingPolicy
178+ BackendTLS * BackendTLSPolicy
179+ BackendProtocol * BackendProtocol
193180 SSLRedirect * bool
194181 RewriteTarget * string
195182 UseRegexPaths * bool
196183
197184 // RuleBackendSources lists covered (rule, backend) pairs in the merged HTTPRoute.
198- RuleBackendSources []IngressNginxPolicyIndex
185+ RuleBackendSources []PolicyIndex
199186
200187 // Backends holds all proxied backends that cannot be rendered as a standard k8s service.
201- Backends map [types.NamespacedName ]IngressNginxBackend
188+ Backends map [types.NamespacedName ]Backend
202189
203190 // ruleBackendIndexSet is an internal helper used to deduplicate RuleBackendSources entries.
204- ruleBackendIndexSet map [IngressNginxPolicyIndex ]struct {}
191+ ruleBackendIndexSet map [PolicyIndex ]struct {}
205192}
206193
207- // IngressNginxBackendProtocol defines the L7 protocol used to talk to a Backend.
208- type IngressNginxBackendProtocol string
194+ // BackendProtocol defines the L7 protocol used to talk to a Backend.
195+ type BackendProtocol string
209196
210- // IngressNginxBackendProtocolGRPC is the gRPC protocol.
211- const IngressNginxBackendProtocolGRPC IngressNginxBackendProtocol = "grpc"
197+ // BackendProtocolGRPC is the gRPC protocol.
198+ const BackendProtocolGRPC BackendProtocol = "grpc"
212199
213- // IngressNginxBackend defines a proxied backend that cannot be rendered as a standard k8s Service.
214- type IngressNginxBackend struct {
200+ // Backend defines a proxied backend that cannot be rendered as a standard k8s Service.
201+ type Backend struct {
215202 Namespace string
216203 Name string
217204 Port int32
218205 Host string
219- Protocol * IngressNginxBackendProtocol
206+ Protocol * BackendProtocol
220207}
221208
222- // IngressNginxRateLimitUnit defines the unit of rate limiting.
223- type IngressNginxRateLimitUnit string
209+ // RateLimitUnit defines the unit of rate limiting.
210+ type RateLimitUnit string
224211
225212const (
226- // IngressNginxRateLimitUnitRPS defines rate limit in requests per second.
227- IngressNginxRateLimitUnitRPS IngressNginxRateLimitUnit = "rps"
228- // IngressNginxRateLimitUnitRPM defines rate limit in requests per minute.
229- IngressNginxRateLimitUnitRPM IngressNginxRateLimitUnit = "rpm"
213+ // RateLimitUnitRPS defines rate limit in requests per second.
214+ RateLimitUnitRPS RateLimitUnit = "rps"
215+ // RateLimitUnitRPM defines rate limit in requests per minute.
216+ RateLimitUnitRPM RateLimitUnit = "rpm"
230217)
231218
232- // IngressNginxRateLimitPolicy defines a rate limiting policy derived from ingress-nginx annotations.
233- type IngressNginxRateLimitPolicy struct {
219+ // RateLimitPolicy defines a rate limiting policy derived from annotations.
220+ type RateLimitPolicy struct {
234221 Limit int32
235- Unit IngressNginxRateLimitUnit
222+ Unit RateLimitUnit
236223 BurstMultiplier int32
237224}
238225
239- // IngressNginxLoadBalancingStrategy represents upstream load-balancing mode.
240- type IngressNginxLoadBalancingStrategy string
226+ // LoadBalancingStrategy represents upstream load-balancing mode.
227+ type LoadBalancingStrategy string
241228
242- // IngressNginxLoadBalancingStrategyRoundRobin is the supported round_robin strategy.
243- const IngressNginxLoadBalancingStrategyRoundRobin IngressNginxLoadBalancingStrategy = "round_robin"
229+ // LoadBalancingStrategyRoundRobin is the supported round_robin strategy.
230+ const LoadBalancingStrategyRoundRobin LoadBalancingStrategy = "round_robin"
244231
245- // IngressNginxBackendLoadBalancingPolicy defines backend load-balancing policy.
246- type IngressNginxBackendLoadBalancingPolicy struct {
247- Strategy IngressNginxLoadBalancingStrategy
232+ // BackendLoadBalancingPolicy defines backend load-balancing policy.
233+ type BackendLoadBalancingPolicy struct {
234+ Strategy LoadBalancingStrategy
248235}
249236
250237// AddRuleBackendSources returns a copy of p with idxs added to RuleBackendSources,
251238// ensuring each (rule, backend) pair is unique.
252- func (p IngressNginxPolicy ) AddRuleBackendSources (idxs []IngressNginxPolicyIndex ) IngressNginxPolicy {
239+ func (p Policy ) AddRuleBackendSources (idxs []PolicyIndex ) Policy {
253240 pCopy := p
254241
255242 if len (pCopy .RuleBackendSources ) > 0 && pCopy .ruleBackendIndexSet == nil {
256- pCopy .ruleBackendIndexSet = make (map [IngressNginxPolicyIndex ]struct {}, len (pCopy .RuleBackendSources ))
243+ pCopy .ruleBackendIndexSet = make (map [PolicyIndex ]struct {}, len (pCopy .RuleBackendSources ))
257244 for _ , existing := range pCopy .RuleBackendSources {
258245 pCopy .ruleBackendIndexSet [existing ] = struct {}{}
259246 }
260247 }
261248 if pCopy .ruleBackendIndexSet == nil {
262- pCopy .ruleBackendIndexSet = make (map [IngressNginxPolicyIndex ]struct {})
249+ pCopy .ruleBackendIndexSet = make (map [PolicyIndex ]struct {})
263250 }
264251
265252 for _ , idx := range idxs {
@@ -273,38 +260,38 @@ func (p IngressNginxPolicy) AddRuleBackendSources(idxs []IngressNginxPolicyIndex
273260 return pCopy
274261}
275262
276- // Type aliases for emitter code ergonomics .
263+ // Backward-compatibility aliases for older ingress-nginx-prefixed names .
277264
278- type Policy = IngressNginxPolicy
265+ type IngressNginxPolicy = Policy
279266
280- type PolicyIndex = IngressNginxPolicyIndex
267+ type IngressNginxPolicyIndex = PolicyIndex
281268
282- type CorsPolicy = IngressNginxCorsPolicy
269+ type IngressNginxCorsPolicy = CorsPolicy
283270
284- type ExtAuthPolicy = IngressNginxExtAuthPolicy
271+ type IngressNginxExtAuthPolicy = ExtAuthPolicy
285272
286- type BasicAuthPolicy = IngressNginxBasicAuthPolicy
273+ type IngressNginxBasicAuthPolicy = BasicAuthPolicy
287274
288- type SessionAffinityPolicy = IngressNginxSessionAffinityPolicy
275+ type IngressNginxSessionAffinityPolicy = SessionAffinityPolicy
289276
290- type BackendTLSPolicy = IngressNginxBackendTLSPolicy
277+ type IngressNginxBackendTLSPolicy = BackendTLSPolicy
291278
292- type BackendProtocol = IngressNginxBackendProtocol
279+ type IngressNginxBackendProtocol = BackendProtocol
293280
294- const BackendProtocolGRPC = IngressNginxBackendProtocolGRPC
281+ const IngressNginxBackendProtocolGRPC = BackendProtocolGRPC
295282
296- type Backend = IngressNginxBackend
283+ type IngressNginxBackend = Backend
297284
298- type RateLimitUnit = IngressNginxRateLimitUnit
285+ type IngressNginxRateLimitUnit = RateLimitUnit
299286
300- const RateLimitUnitRPS = IngressNginxRateLimitUnitRPS
287+ const IngressNginxRateLimitUnitRPS = RateLimitUnitRPS
301288
302- const RateLimitUnitRPM = IngressNginxRateLimitUnitRPM
289+ const IngressNginxRateLimitUnitRPM = RateLimitUnitRPM
303290
304- type RateLimitPolicy = IngressNginxRateLimitPolicy
291+ type IngressNginxRateLimitPolicy = RateLimitPolicy
305292
306- type LoadBalancingStrategy = IngressNginxLoadBalancingStrategy
293+ type IngressNginxLoadBalancingStrategy = LoadBalancingStrategy
307294
308- const LoadBalancingStrategyRoundRobin = IngressNginxLoadBalancingStrategyRoundRobin
295+ const IngressNginxLoadBalancingStrategyRoundRobin = LoadBalancingStrategyRoundRobin
309296
310- type BackendLoadBalancingPolicy = IngressNginxBackendLoadBalancingPolicy
297+ type IngressNginxBackendLoadBalancingPolicy = BackendLoadBalancingPolicy
0 commit comments