Skip to content

Commit 37391c9

Browse files
kd7lxldkostyrev
authored andcommitted
fix path in file changed detected message (kubernetes#11271)
* fix path in file changed detected message Signed-off-by: Tom Hayward <[email protected]> * fix typo in log message * explain code per review comments --------- Signed-off-by: Tom Hayward <[email protected]>
1 parent 99c1819 commit 37391c9

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
@@ -204,8 +204,11 @@ func NewNGINXController(config *Configuration, mc metric.Collector) *NGINXContro
204204
}
205205

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

0 commit comments

Comments
 (0)