Skip to content

Commit cc72851

Browse files
committed
fix: review
Signed-off-by: ashing <[email protected]>
1 parent 4162324 commit cc72851

File tree

5 files changed

+16
-17
lines changed

5 files changed

+16
-17
lines changed

internal/controller/gateway_controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ type GatewayReconciler struct { //nolint:revive
3737

3838
func (r *GatewayReconciler) setupIndexer(mgr ctrl.Manager) error {
3939
if err := mgr.GetFieldIndexer().IndexField(
40-
context.TODO(),
40+
context.Background(),
4141
&gatewayv1.Gateway{},
4242
indexer.ParametersRef,
4343
indexer.GatewayParametersRefIndexFunc,
@@ -121,7 +121,7 @@ func (r *GatewayReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
121121
Secrets: make(map[types.NamespacedName]*corev1.Secret),
122122
}
123123
r.processListenerConfig(tctx, gateway, ns)
124-
if err := r.processGatewayProxy(tctx, gateway, ns); err != nil {
124+
if err := r.processInfrastructure(tctx, gateway, ns); err != nil {
125125
acceptStatus = status{
126126
status: false,
127127
msg: err.Error(),
@@ -275,7 +275,7 @@ func (r *GatewayReconciler) listGatewaysForHTTPRoute(_ context.Context, obj clie
275275
return recs
276276
}
277277

278-
func (r *GatewayReconciler) processGatewayProxy(tctx *provider.TranslateContext, gateway *gatewayv1.Gateway, ns string) error {
278+
func (r *GatewayReconciler) processInfrastructure(tctx *provider.TranslateContext, gateway *gatewayv1.Gateway, ns string) error {
279279
infra := gateway.Spec.Infrastructure
280280
if infra != nil && infra.ParametersRef != nil {
281281
paramRef := infra.ParametersRef

internal/controller/httproute_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,15 @@ func (r *HTTPRouteReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
140140
// SetupWithManager sets up the controller with the Manager.
141141
func (r *HTTPRouteReconciler) setupIndexer(mgr ctrl.Manager) error {
142142
if err := mgr.GetFieldIndexer().IndexField(
143-
context.TODO(),
143+
context.Background(),
144144
&gatewayv1.HTTPRoute{},
145145
indexer.ExtensionRef,
146146
indexer.HTTPRouteExtensionIndexFunc,
147147
); err != nil {
148148
return err
149149
}
150150
if err := mgr.GetFieldIndexer().IndexField(
151-
context.TODO(),
151+
context.Background(),
152152
&gatewayv1.HTTPRoute{},
153153
indexer.ServiceIndexRef,
154154
indexer.HTTPRouteServiceIndexFunc,

internal/controller/indexer/indexer.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ func HTTPRouteExtensionIndexFunc(rawObj client.Object) []string {
5454

5555
func GatewayParametersRefIndexFunc(rawObj client.Object) []string {
5656
gw := rawObj.(*gatewayv1.Gateway)
57-
var keys []string
5857
if gw.Spec.Infrastructure != nil && gw.Spec.Infrastructure.ParametersRef != nil {
5958
// now we only care about kind: GatewayProxy
6059
if gw.Spec.Infrastructure.ParametersRef.Kind == "GatewayProxy" {
61-
keys = append(keys, GenIndexKey(gw.GetNamespace(), gw.Spec.Infrastructure.ParametersRef.Name))
60+
name := gw.Spec.Infrastructure.ParametersRef.Name
61+
return []string{GenIndexKey(gw.GetNamespace(), name)}
6262
}
6363
}
64-
return keys
64+
return nil
6565
}

internal/provider/adc/translator/gateway.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import (
1111
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
1212
)
1313

14-
// FillPluginsFromGatewayProxy fill plugins from GatewayProxy to given plugins
15-
func (t *Translator) FillPluginsFromGatewayProxy(plugins adctypes.Plugins, gatewayProxy *v1alpha1.GatewayProxy) {
14+
// fillPluginsFromGatewayProxy fill plugins from GatewayProxy to given plugins
15+
func (t *Translator) fillPluginsFromGatewayProxy(plugins adctypes.Plugins, gatewayProxy *v1alpha1.GatewayProxy) {
1616
if gatewayProxy == nil {
1717
return
1818
}
@@ -43,7 +43,7 @@ func (t *Translator) TranslateGateway(tctx *provider.TranslateContext, gateway *
4343
if tctx.GatewayProxy != nil {
4444
globalRules := adctypes.Plugins{}
4545
// apply plugins from GatewayProxy to global rules
46-
t.FillPluginsFromGatewayProxy(globalRules, tctx.GatewayProxy)
46+
t.fillPluginsFromGatewayProxy(globalRules, tctx.GatewayProxy)
4747
result.GlobalRules = globalRules
4848
}
4949

test/e2e/gatewayapi/gatewayproxy.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,23 +101,22 @@ spec:
101101
port: 80
102102
`
103103

104-
var ResourceApplied = func(resourType, resourceName, resourceRaw string, observedGeneration int) {
104+
var ResourceApplied = func(resourceType, resourceName, resourceRaw string, observedGeneration int) {
105105
Expect(s.CreateResourceFromString(resourceRaw)).
106-
NotTo(HaveOccurred(), fmt.Sprintf("creating %s", resourType))
106+
NotTo(HaveOccurred(), fmt.Sprintf("creating %s", resourceType))
107107

108108
Eventually(func() string {
109-
hryaml, err := s.GetResourceYaml(resourType, resourceName)
110-
Expect(err).NotTo(HaveOccurred(), fmt.Sprintf("getting %s yaml", resourType))
109+
hryaml, err := s.GetResourceYaml(resourceType, resourceName)
110+
Expect(err).NotTo(HaveOccurred(), fmt.Sprintf("getting %s yaml", resourceType))
111111
return hryaml
112112
}, "8s", "2s").
113113
Should(
114114
SatisfyAll(
115115
ContainSubstring(`status: "True"`),
116116
ContainSubstring(fmt.Sprintf("observedGeneration: %d", observedGeneration)),
117117
),
118-
fmt.Sprintf("checking %s condition status", resourType),
118+
fmt.Sprintf("checking %s condition status", resourceType),
119119
)
120-
time.Sleep(1 * time.Second)
121120
}
122121

123122
var (

0 commit comments

Comments
 (0)