Merge pull request #3799 from fastest963/fileNotDir

Resolve symlinks in config directory
This commit is contained in:
Kyle Havlovitz 2018-01-18 11:26:23 -08:00 committed by GitHub
commit a9139cac59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 1 deletions

View File

@ -165,12 +165,25 @@ func (b *Builder) ReadPath(path string) ([]Source, error) {
var sources []Source
for _, fi := range fis {
fp := filepath.Join(path, fi.Name())
// check for a symlink and resolve the path
if fi.Mode()&os.ModeSymlink > 0 {
var err error
fp, err = filepath.EvalSymlinks(fp)
if err != nil {
return nil, err
}
fi, err = os.Stat(fp)
if err != nil {
return nil, err
}
}
// do not recurse into sub dirs
if fi.IsDir() {
continue
}
src, err := b.ReadFile(filepath.Join(path, fi.Name()))
src, err := b.ReadFile(fp)
if err != nil {
return nil, err
}