Open kmkacpermajor opened 1 month ago
@kmkacpermajor thanks for filing this - can you provide some more concrete details? what exactly does your configuration and/or gomplate commandline look like?
Sure, To recreate this:
touch test_file
ln -s test_file test_link
rm test_file
gomplate --config gomplate.config
Error: failed to gather templates for rendering: walkDir: ignore matching failed for.: applyPatterns: stat: stat test_link: no such file or directory.
gomplate.config
excludes:
- '*'
- '!*.tmpl'
inputDir: .
outputMap: |
{{ .in | strings.ReplaceAll ".tmpl" "" }}
I'm on Ubuntu 22.04.1 LTS on WSL2, gomplate v4.1.0
I can see that it is a problem with xignore library.
I think that if we operate only on files instead of links, then if the file doesn't exist it would be okay to mark it as unmatched. Problem is that it uses fs.Stat to check if current "file" is a file or a directory (in applyPatterns and makeResult).
Workaround would be to just ignore (continue in for) non existing files. They won't appear neither in matchedFiles or unmatchedFiles, so that is probably not a great fix... It would be great to just use os.Lstat since we only check if it is a dir. It returns FileInfo just like fs.Stat. But I'm not a GO developer, so I don't really know if it would hurt compatibilty-wise or something...
Discussed in https://github.com/hairyhenderson/gomplate/discussions/2194
I can't seem to find an option to turn off following symlinks in gomplate.
If there would be a config option to change os.Stat() to os.Lstat(), it would be great. It would read the information off of symlink, and then for my usage it would just be excluded.