Skip to content

Commit

Permalink
Follow directory symlinks in auto deploying manifests (k3s-io#9288)
Browse files Browse the repository at this point in the history
Signed-off-by: Robert Rose <robert.rose@mailbox.org>
(cherry picked from commit 6886c09)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
  • Loading branch information
rorosen authored and brandond committed May 31, 2024
1 parent 4d34f35 commit a250eba
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions pkg/deploy/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit a250eba

Please sign in to comment.