From 6886c0977f9d9305d983669d524b967b1dd224be Mon Sep 17 00:00:00 2001 From: Robert Rose Date: Tue, 30 Apr 2024 17:41:07 +0200 Subject: [PATCH] Follow directory symlinks in auto deploying manifests (#9288) Signed-off-by: Robert Rose --- pkg/deploy/controller.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pkg/deploy/controller.go b/pkg/deploy/controller.go index 5fdc365032..af96e8fafa 100644 --- a/pkg/deploy/controller.go +++ b/pkg/deploy/controller.go @@ -119,6 +119,26 @@ func (w *watcher) listFilesIn(base string, force bool) error { if err != nil { return err } + // Descend into symlinked directories, however, only top-level links are followed + if info.Mode()&os.ModeSymlink != 0 { + linkInfo, err := os.Stat(path) + if err != nil { + return err + } + if linkInfo.IsDir() { + evalPath, err := filepath.EvalSymlinks(path) + if err != nil { + return err + } + filepath.Walk(evalPath, func(path string, info os.FileInfo, err error) error { + if err != nil { + return err + } + files[path] = info + return nil + }) + } + } files[path] = info return nil }); err != nil {