forked from kubernetes-sigs/ingress2gateway
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathintermediate_representation.go
More file actions
133 lines (107 loc) · 4.2 KB
/
intermediate_representation.go
File metadata and controls
133 lines (107 loc) · 4.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*
Copyright 2025 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package emitterir
import (
"github.com/kubernetes-sigs/ingress2gateway/pkg/i2gw/emitter_intermediate/gce"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/types"
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"
gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"
)
// EmitterIR holds specifications of Gateway Objects for supporting Ingress extensions,
// annotations, and proprietary API features not supported as Gateway core
// features. An EmitterIR field can be mapped to core Gateway-API fields,
// or provider-specific Gateway extensions.
type EmitterIR struct {
Gateways map[types.NamespacedName]GatewayContext
HTTPRoutes map[types.NamespacedName]HTTPRouteContext
GatewayClasses map[types.NamespacedName]GatewayClassContext
TLSRoutes map[types.NamespacedName]TLSRouteContext
TCPRoutes map[types.NamespacedName]TCPRouteContext
UDPRoutes map[types.NamespacedName]UDPRouteContext
GRPCRoutes map[types.NamespacedName]GRPCRouteContext
BackendTLSPolicies map[types.NamespacedName]BackendTLSPolicyContext
ReferenceGrants map[types.NamespacedName]ReferenceGrantContext
GceServices map[types.NamespacedName]gce.ServiceIR
}
type GatewayContext struct {
gatewayv1.Gateway
// Emitter IR should be provider/emitter neutral,
// But we have GCE for backcompatibility.
Gce *gce.GatewayIR
}
type HTTPRouteContext struct {
gatewayv1.HTTPRoute
// TCPTimeoutsByRuleIdx holds provider TCP-level timeouts by HTTPRoute rule index.
TCPTimeoutsByRuleIdx map[int]*TCPTimeouts
// PathRewriteByRuleIdx maps HTTPRoute rule indices to path rewrite intent.
// This is provider-neutral and applied by the common emitter.
PathRewriteByRuleIdx map[int]*PathRewrite
// BodySizeByRuleIdx maps HTTPRoute rule indices to body size intent.
// This is provider-neutral and applied by each custom emitter.
BodySizeByRuleIdx map[int]*BodySize
// CorsPolicyByRuleIdx maps HTTPRoute rule indices to CORS policy intent.
// This map is populated by providers that support CORS (e.g., via annotations) and is
// applied by the CommonEmitter. This separation allows the CORS logic to be provider-neutral
// and consistently applied across different providers, subject to feature gating.
CorsPolicyByRuleIdx map[int]*gatewayv1.HTTPCORSFilter
// IPRangeControlByRuleIdx maps HTTPRoute rule indices to IP range control intent.
// This is provider-neutral and applied by each custom emitter.
IPRangeControlByRuleIdx map[int]*IPRangeControl
}
// TCPTimeouts holds TCP-level timeout configuration for a single HTTPRoute rule.
type TCPTimeouts struct {
Connect *gatewayv1.Duration
Read *gatewayv1.Duration
Write *gatewayv1.Duration
}
// PathRewrite represents provider-neutral path rewrite intent.
// For now it only supports full-path replacement; more fields may be added later.
type PathRewrite struct {
ReplaceFullPath string
// Headers to add on path rewrite.
Headers map[string]string
Regex bool
}
// BodySize represents provider-neutral body size intent.
type BodySize struct {
BufferSize *resource.Quantity
MaxSize *resource.Quantity
}
// IPRangeControl represents provider-neutral IP range control intent.
type IPRangeControl struct {
AllowList []string
DenyList []string
}
type GatewayClassContext struct {
gatewayv1.GatewayClass
}
type TLSRouteContext struct {
gatewayv1alpha2.TLSRoute
}
type TCPRouteContext struct {
gatewayv1alpha2.TCPRoute
}
type UDPRouteContext struct {
gatewayv1alpha2.UDPRoute
}
type GRPCRouteContext struct {
gatewayv1.GRPCRoute
}
type BackendTLSPolicyContext struct {
gatewayv1.BackendTLSPolicy
}
type ReferenceGrantContext struct {
gatewayv1beta1.ReferenceGrant
}