Skip to content

Commit 332a301

Browse files
committed
Merge branch origin/release-v2-dev
2 parents d0bb229 + b0ba08c commit 332a301

File tree

3 files changed

+33
-28
lines changed

3 files changed

+33
-28
lines changed

internal/controller/gateway_controller.go

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -277,20 +277,22 @@ func (r *GatewayReconciler) listGatewaysForHTTPRoute(_ context.Context, obj clie
277277

278278
func (r *GatewayReconciler) processInfrastructure(tctx *provider.TranslateContext, gateway *gatewayv1.Gateway, ns string) error {
279279
infra := gateway.Spec.Infrastructure
280-
if infra != nil && infra.ParametersRef != nil {
281-
paramRef := infra.ParametersRef
282-
if string(paramRef.Group) == v1alpha1.GroupVersion.Group && string(paramRef.Kind) == "GatewayProxy" {
283-
gatewayProxy := &v1alpha1.GatewayProxy{}
284-
if err := r.Get(context.Background(), client.ObjectKey{
285-
Namespace: ns,
286-
Name: paramRef.Name,
287-
}, gatewayProxy); err != nil {
288-
log.Error(err, "failed to get GatewayProxy", "namespace", ns, "name", paramRef.Name)
289-
return err
290-
} else {
291-
log.Info("found GatewayProxy for Gateway", "gateway", gateway.Name, "gatewayproxy", gatewayProxy.Name)
292-
tctx.GatewayProxy = gatewayProxy
293-
}
280+
if infra == nil || infra.ParametersRef == nil {
281+
return nil
282+
}
283+
284+
paramRef := infra.ParametersRef
285+
if string(paramRef.Group) == v1alpha1.GroupVersion.Group && string(paramRef.Kind) == "GatewayProxy" {
286+
gatewayProxy := &v1alpha1.GatewayProxy{}
287+
if err := r.Get(context.Background(), client.ObjectKey{
288+
Namespace: ns,
289+
Name: paramRef.Name,
290+
}, gatewayProxy); err != nil {
291+
log.Error(err, "failed to get GatewayProxy", "namespace", ns, "name", paramRef.Name)
292+
return err
293+
} else {
294+
log.Info("found GatewayProxy for Gateway", "gateway", gateway.Name, "gatewayproxy", gatewayProxy.Name)
295+
tctx.GatewayProxy = gatewayProxy
294296
}
295297
}
296298

internal/provider/adc/adc.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,7 @@ func (d *adcClient) sync(task Task, extraArgs ...string) error {
131131
"-f", tmpFile.Name(),
132132
"--tls-skip-verify",
133133
}
134-
135-
if len(extraArgs) > 0 {
136-
args = append(args, extraArgs...)
137-
}
134+
args = append(args, extraArgs...)
138135

139136
for k, v := range task.Labels {
140137
args = append(args, "--label-selector", k+"="+v)

test/e2e/gatewayapi/gatewayproxy.go

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ spec:
181181
})
182182

183183
Context("Test Gateway with enabled GatewayProxy plugin", func() {
184-
FIt("Should apply plugin configuration when enabled", func() {
184+
It("Should apply plugin configuration when enabled", func() {
185185
By("Create HTTPRoute for Gateway with GatewayProxy")
186186
ResourceApplied("HTTPRoute", "test-route", fmt.Sprintf(httpRouteForTest, "api7"), 1)
187187

@@ -193,11 +193,7 @@ spec:
193193
Status(200)
194194

195195
resp.Header("X-Proxy-Test").IsEqual("enabled")
196-
})
197-
})
198196

199-
Context("Test Gateway with disabled GatewayProxy plugin", func() {
200-
It("Should not apply plugin configuration when disabled", func() {
201197
By("Update GatewayProxy with disabled plugin")
202198
err := s.CreateResourceFromString(gatewayProxyWithDisabledPlugin)
203199
Expect(err).NotTo(HaveOccurred(), "updating GatewayProxy with disabled plugin")
@@ -207,18 +203,28 @@ spec:
207203
ResourceApplied("HTTPRoute", "test-route", fmt.Sprintf(httpRouteForTest, "api7"), 1)
208204

209205
By("Check if the plugin is not applied")
210-
resp := s.NewAPISIXClient().
206+
resp = s.NewAPISIXClient().
211207
GET("/get").
212208
WithHost("example.com").
213209
Expect().
214210
Status(200)
215211

216212
resp.Header("X-Proxy-Test").IsEmpty()
217213
})
218-
})
219214

220-
Context("Test Gateway without GatewayProxy", func() {
221215
It("Should work normally without GatewayProxy", func() {
216+
By("Create HTTPRoute for Gateway with GatewayProxy")
217+
ResourceApplied("HTTPRoute", "test-route", fmt.Sprintf(httpRouteForTest, "api7"), 1)
218+
219+
By("Check if the plugin is applied")
220+
resp := s.NewAPISIXClient().
221+
GET("/get").
222+
WithHost("example.com").
223+
Expect().
224+
Status(200)
225+
226+
resp.Header("X-Proxy-Test").IsEqual("enabled")
227+
222228
By("Update Gateway without GatewayProxy")
223229
err := s.CreateResourceFromString(fmt.Sprintf(gatewayWithoutProxy, gatewayClassName))
224230
Expect(err).NotTo(HaveOccurred(), "updating Gateway without GatewayProxy")
@@ -228,7 +234,7 @@ spec:
228234
ResourceApplied("HTTPRoute", "test-route", fmt.Sprintf(httpRouteForTest, "api7"), 1)
229235

230236
By("Check if the route works without plugin")
231-
resp := s.NewAPISIXClient().
237+
resp = s.NewAPISIXClient().
232238
GET("/get").
233239
WithHost("example.com").
234240
Expect().
@@ -243,7 +249,7 @@ spec:
243249
err error
244250
)
245251

246-
FIt("Should work OK with error-page", func() {
252+
It("Should work OK with error-page", func() {
247253
By("Update GatewayProxy with PluginMetadata")
248254
err = s.CreateResourceFromString(gatewayProxyWithPluginMetadata)
249255
Ω(err).ShouldNot(HaveOccurred())

0 commit comments

Comments
 (0)