Skip to content

Commit 4fe4c63

Browse files
committed
fix target ref
Signed-off-by: omar <omar.hammami@solo.io>
1 parent b73a1f6 commit 4fe4c63

6 files changed

Lines changed: 54 additions & 138 deletions

File tree

pkg/i2gw/implementations/kgateway/emitter.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,9 @@ func (e *Emitter) Emit(ir *intermediate.IR) ([]client.Object, error) {
177177
// Full coverage via targetRefs.
178178
t.Spec.TargetRefs = []shared.LocalPolicyTargetReferenceWithSectionName{{
179179
LocalPolicyTargetReference: shared.LocalPolicyTargetReference{
180-
Name: gwv1.ObjectName(httpRouteKey.Name),
180+
Group: gwv1.Group("gateway.networking.k8s.io"),
181+
Kind: gwv1.Kind("HTTPRoute"),
182+
Name: gwv1.ObjectName(httpRouteKey.Name),
181183
},
182184
}}
183185
} else {

pkg/i2gw/implementations/kgateway/testing/testdata/input/external_auth.yaml

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -68,27 +68,3 @@ spec:
6868
path: /
6969
pathType: Prefix
7070
---
71-
apiVersion: networking.k8s.io/v1
72-
kind: Ingress
73-
metadata:
74-
annotations:
75-
ingress2gateway.kubernetes.io/implementation: kgateway
76-
# Auth URL with root path explicitly specified
77-
nginx.ingress.kubernetes.io/auth-url: "http://auth.default.svc.cluster.local/"
78-
nginx.ingress.kubernetes.io/auth-response-headers: "X-Auth-Token"
79-
name: ingress-auth-root-path
80-
namespace: default
81-
spec:
82-
ingressClassName: nginx
83-
rules:
84-
- host: app11.example.org
85-
http:
86-
paths:
87-
- backend:
88-
service:
89-
name: app11
90-
port:
91-
number: 80
92-
path: /
93-
pathType: Prefix
94-
---

pkg/i2gw/implementations/kgateway/testing/testdata/output/cors.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,17 @@ metadata:
9090
namespace: default
9191
spec:
9292
cors:
93-
allowOrigins:
94-
- https://example.com
95-
- https://another.com
9693
allowCredentials: false
94+
allowHeaders:
95+
- X-Requested-With
96+
- Content-Type
9797
allowMethods:
9898
- GET
9999
- POST
100100
- OPTIONS
101-
allowHeaders:
102-
- X-Requested-With
103-
- Content-Type
101+
allowOrigins:
102+
- https://example.com
103+
- https://another.com
104104
exposeHeaders:
105105
- X-Expose-One
106106
- X-Expose-Two
@@ -132,11 +132,11 @@ spec:
132132
- https://example.com
133133
- https://another.com
134134
exposeHeaders:
135-
- "*"
135+
- '*'
136136
- X-CustomResponseHeader
137137
targetRefs:
138-
- group: ""
139-
kind: ""
138+
- group: gateway.networking.k8s.io
139+
kind: HTTPRoute
140140
name: ingress-myserviceb-myserviceb-foo-org
141141
status:
142142
ancestors: null

pkg/i2gw/implementations/kgateway/testing/testdata/output/external_auth.yaml

Lines changed: 13 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ spec:
1212
name: app1-example-org-http
1313
port: 80
1414
protocol: HTTP
15-
- hostname: app11.example.org
16-
name: app11-example-org-http
17-
port: 80
18-
protocol: HTTP
1915
- hostname: app3.example.org
2016
name: app3-example-org-http
2117
port: 80
@@ -51,29 +47,6 @@ status:
5147
---
5248
apiVersion: gateway.networking.k8s.io/v1
5349
kind: HTTPRoute
54-
metadata:
55-
annotations:
56-
gateway.networking.k8s.io/generator: ingress2gateway-dev
57-
name: ingress-auth-root-path-app11-example-org
58-
namespace: default
59-
spec:
60-
hostnames:
61-
- app11.example.org
62-
parentRefs:
63-
- name: nginx
64-
rules:
65-
- backendRefs:
66-
- name: app11
67-
port: 80
68-
matches:
69-
- path:
70-
type: PathPrefix
71-
value: /
72-
status:
73-
parents: []
74-
---
75-
apiVersion: gateway.networking.k8s.io/v1
76-
kind: HTTPRoute
7750
metadata:
7851
annotations:
7952
gateway.networking.k8s.io/generator: ingress2gateway-dev
@@ -126,10 +99,6 @@ metadata:
12699
spec:
127100
extAuth:
128101
httpService:
129-
authorizationResponse:
130-
headersToBackend:
131-
- X-Auth-Token
132-
- X-User-ID
133102
backendRef:
134103
name: auth
135104
namespace: default
@@ -145,14 +114,11 @@ metadata:
145114
spec:
146115
extAuth:
147116
httpService:
148-
authorizationResponse:
149-
headersToBackend:
150-
- X-Auth-Token
151117
backendRef:
152118
name: auth
153-
namespace: default
154-
port: 80
155-
pathPrefix: /
119+
namespace: production
120+
port: 8080
121+
pathPrefix: /authz
156122
status: {}
157123
---
158124
apiVersion: gateway.kgateway.dev/v1alpha1
@@ -163,6 +129,10 @@ metadata:
163129
spec:
164130
extAuth:
165131
httpService:
132+
authorizationResponse:
133+
headersToBackend:
134+
- X-Auth-Token
135+
- X-User-ID
166136
backendRef:
167137
name: auth
168138
namespace: default
@@ -171,21 +141,6 @@ spec:
171141
status: {}
172142
---
173143
apiVersion: gateway.kgateway.dev/v1alpha1
174-
kind: GatewayExtension
175-
metadata:
176-
name: auth-extauth
177-
namespace: default
178-
spec:
179-
extAuth:
180-
httpService:
181-
backendRef:
182-
name: auth
183-
namespace: production
184-
port: 8080
185-
pathPrefix: /authz
186-
status: {}
187-
---
188-
apiVersion: gateway.kgateway.dev/v1alpha1
189144
kind: TrafficPolicy
190145
metadata:
191146
name: ingress-auth-different-ns
@@ -196,8 +151,8 @@ spec:
196151
name: auth-extauth
197152
namespace: default
198153
targetRefs:
199-
- group: ""
200-
kind: ""
154+
- group: gateway.networking.k8s.io
155+
kind: HTTPRoute
201156
name: ingress-auth-different-ns-app4-example-org
202157
status:
203158
ancestors: null
@@ -213,31 +168,14 @@ spec:
213168
name: auth-extauth
214169
namespace: default
215170
targetRefs:
216-
- group: ""
217-
kind: ""
171+
- group: gateway.networking.k8s.io
172+
kind: HTTPRoute
218173
name: ingress-auth-full-fqdn-app1-example-org
219174
status:
220175
ancestors: null
221176
---
222177
apiVersion: gateway.kgateway.dev/v1alpha1
223178
kind: TrafficPolicy
224-
metadata:
225-
name: ingress-auth-root-path
226-
namespace: default
227-
spec:
228-
extAuth:
229-
extensionRef:
230-
name: auth-extauth
231-
namespace: default
232-
targetRefs:
233-
- group: ""
234-
kind: ""
235-
name: ingress-auth-root-path-app11-example-org
236-
status:
237-
ancestors: null
238-
---
239-
apiVersion: gateway.kgateway.dev/v1alpha1
240-
kind: TrafficPolicy
241179
metadata:
242180
name: ingress-auth-same-ns
243181
namespace: default
@@ -247,8 +185,8 @@ spec:
247185
name: auth-extauth
248186
namespace: default
249187
targetRefs:
250-
- group: ""
251-
kind: ""
188+
- group: gateway.networking.k8s.io
189+
kind: HTTPRoute
252190
name: ingress-auth-same-ns-app3-example-org
253191
status:
254192
ancestors: null

pkg/i2gw/implementations/kgateway/testing/testdata/output/golden.yaml

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,29 @@ status: {}
2424
---
2525
apiVersion: gateway.networking.k8s.io/v1
2626
kind: HTTPRoute
27+
metadata:
28+
annotations:
29+
gateway.networking.k8s.io/generator: ingress2gateway-dev
30+
name: ingress-sessionaffinity-sessionaffinity-example-org
31+
namespace: default
32+
spec:
33+
hostnames:
34+
- sessionaffinity.example.org
35+
parentRefs:
36+
- name: nginx
37+
rules:
38+
- backendRefs:
39+
- name: httpbin
40+
port: 80
41+
matches:
42+
- path:
43+
type: PathPrefix
44+
value: /
45+
status:
46+
parents: []
47+
---
48+
apiVersion: gateway.networking.k8s.io/v1
49+
kind: HTTPRoute
2750
metadata:
2851
annotations:
2952
gateway.networking.k8s.io/generator: ingress2gateway-dev
@@ -87,29 +110,6 @@ spec:
87110
status:
88111
parents: []
89112
---
90-
apiVersion: gateway.networking.k8s.io/v1
91-
kind: HTTPRoute
92-
metadata:
93-
annotations:
94-
gateway.networking.k8s.io/generator: ingress2gateway-dev
95-
name: ingress-sessionaffinity-sessionaffinity-example-org
96-
namespace: default
97-
spec:
98-
hostnames:
99-
- sessionaffinity.example.org
100-
parentRefs:
101-
- name: nginx
102-
rules:
103-
- backendRefs:
104-
- name: httpbin
105-
port: 80
106-
matches:
107-
- path:
108-
type: PathPrefix
109-
value: /
110-
status:
111-
parents: []
112-
---
113113
apiVersion: gateway.kgateway.dev/v1alpha1
114114
kind: BackendConfigPolicy
115115
metadata:
@@ -238,8 +238,8 @@ spec:
238238
maxTokens: 250
239239
tokensPerFill: 50
240240
targetRefs:
241-
- group: ""
242-
kind: ""
241+
- group: gateway.networking.k8s.io
242+
kind: HTTPRoute
243243
name: ingress-myserviceb-myserviceb-foo-org
244244
timeouts:
245245
request: 1m30s

pkg/i2gw/implementations/kgateway/testing/testdata/output/load_balance.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ metadata:
7777
name: myservicea-backend-config
7878
namespace: default
7979
spec:
80+
loadBalancer:
81+
roundRobin: {}
8082
targetRefs:
8183
- group: ""
8284
kind: Service
8385
name: myservicea
84-
loadBalancer:
85-
roundRobin: {}
8686
status:
8787
ancestors: null
8888
---
@@ -92,11 +92,11 @@ metadata:
9292
name: myserviceb-backend-config
9393
namespace: default
9494
spec:
95+
loadBalancer:
96+
roundRobin: {}
9597
targetRefs:
9698
- group: ""
9799
kind: Service
98100
name: myserviceb
99-
loadBalancer:
100-
roundRobin: {}
101101
status:
102102
ancestors: null

0 commit comments

Comments
 (0)