Skip to content

Commit

Permalink
rego: Return true for file.exists for directories too (#2191)
Browse files Browse the repository at this point in the history
I'm not sure why we made it to return `true` only for non-directory
files. But I think it makes sense to have it be `true` for directories
as well.
  • Loading branch information
JAORMX authored Jan 24, 2024
1 parent 6b83dce commit b14eecf
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions internal/engine/eval/rego/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,14 @@ func FileExists(res *engif.Result) func(*rego.Rego) {
fs := res.Fs

cpath := filepath.Clean(path)
finfo, err := fs.Stat(cpath)
_, err := fs.Stat(cpath)
if err != nil {
if errors.Is(err, os.ErrNotExist) {
return ast.BooleanTerm(false), nil
}
return nil, err
}

if finfo.IsDir() {
return ast.BooleanTerm(false), nil
}

return ast.BooleanTerm(true), nil
},
)
Expand Down

0 comments on commit b14eecf

Please sign in to comment.