Skip to content

Commit e8d9463

Browse files
committed
Code review
1 parent 9c677a9 commit e8d9463

File tree

4 files changed

+6
-13
lines changed

4 files changed

+6
-13
lines changed

internal/events/handler.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"github.com/go-logr/logr"
88
apiv1 "k8s.io/api/core/v1"
99
discoveryV1 "k8s.io/api/discovery/v1"
10-
"sigs.k8s.io/controller-runtime/pkg/client"
1110
"sigs.k8s.io/gateway-api/apis/v1beta1"
1211

1312
"github.com/nginxinc/nginx-kubernetes-gateway/internal/nginx/config"
@@ -49,8 +48,6 @@ type EventHandlerConfig struct {
4948
StatusUpdater status.Updater
5049
// Logger is the logger to be used by the EventHandler.
5150
Logger logr.Logger
52-
// ControllerName is the name of this controller.
53-
ControllerName string
5451
}
5552

5653
// EventHandlerImpl implements EventHandler.
@@ -124,11 +121,7 @@ func (h *EventHandlerImpl) updateNginx(ctx context.Context, conf dataplane.Confi
124121
func (h *EventHandlerImpl) propagateUpsert(e *UpsertEvent) {
125122
switch r := e.Resource.(type) {
126123
case *v1beta1.GatewayClass:
127-
if string(r.Spec.ControllerName) != h.cfg.ControllerName {
128-
h.cfg.Processor.CaptureDeleteChange(r, client.ObjectKeyFromObject(r))
129-
} else {
130-
h.cfg.Processor.CaptureUpsertChange(r)
131-
}
124+
h.cfg.Processor.CaptureUpsertChange(r)
132125
case *v1beta1.Gateway:
133126
h.cfg.Processor.CaptureUpsertChange(r)
134127
case *v1beta1.HTTPRoute:

internal/manager/manager.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ func Start(cfg config.Config) error {
175175
NginxFileMgr: nginxFileMgr,
176176
NginxRuntimeMgr: nginxRuntimeMgr,
177177
StatusUpdater: statusUpdater,
178-
ControllerName: cfg.GatewayCtlrName,
179178
})
180179

181180
objects, objectLists := prepareFirstEventBatchPreparerArgs(cfg.GatewayClassName, cfg.GatewayNsName)

internal/manager/predicate/gatewayclass.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ func (gcp GatewayClassPredicate) Create(e event.CreateEvent) bool {
3131
func (gcp GatewayClassPredicate) Update(e event.UpdateEvent) bool {
3232
if e.ObjectOld != nil {
3333
gcOld, ok := e.ObjectOld.(*v1beta1.GatewayClass)
34-
if ok {
35-
return string(gcOld.Spec.ControllerName) == gcp.ControllerName
34+
if ok && string(gcOld.Spec.ControllerName) == gcp.ControllerName {
35+
return true
3636
}
3737
}
3838

3939
if e.ObjectNew != nil {
4040
gcNew, ok := e.ObjectNew.(*v1beta1.GatewayClass)
41-
if ok {
42-
return string(gcNew.Spec.ControllerName) == gcp.ControllerName
41+
if ok && string(gcNew.Spec.ControllerName) == gcp.ControllerName {
42+
return true
4343
}
4444
}
4545

internal/manager/predicate/gatewayclass_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ func TestGatewayClassPredicate(t *testing.T) {
2929
}
3030
g.Expect(p.Create(event.CreateEvent{Object: gc2})).To(BeFalse())
3131
g.Expect(p.Update(event.UpdateEvent{ObjectOld: gc, ObjectNew: gc2})).To(BeTrue())
32+
g.Expect(p.Update(event.UpdateEvent{ObjectOld: gc2, ObjectNew: gc})).To(BeTrue())
3233
}

0 commit comments

Comments
 (0)