Skip to content

Commit 48fbdfe

Browse files
authored
fix path in file changed detected message (#11271)
* fix path in file changed detected message Signed-off-by: Tom Hayward <thayward@infoblox.com> * fix typo in log message * explain code per review comments --------- Signed-off-by: Tom Hayward <thayward@infoblox.com>
1 parent af5cfbd commit 48fbdfe

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

internal/ingress/controller/nginx.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,11 @@ func NewNGINXController(config *Configuration, mc metric.Collector) *NGINXContro
202202
}
203203

204204
for _, f := range filesToWatch {
205+
// This redeclaration is necessary for the closure to get the correct value for the iteration in go versions <1.22
206+
// See https://go.dev/blog/loopvar-preview
207+
f := f
205208
_, err = file.NewFileWatcher(f, func() {
206-
klog.InfoS("File changed detected. Reloading NGINX", "path", f)
209+
klog.InfoS("File change detected. Reloading NGINX", "path", f)
207210
n.syncQueue.EnqueueTask(task.GetDummyObject("file-change"))
208211
})
209212
if err != nil {

0 commit comments

Comments
 (0)