jkcfg / jk

Configuration as Code with ECMAScript
https://jkcfg.github.io
Apache License 2.0
404 stars 30 forks source link

jk validate and transform can't look at files outside the working directory #293

Closed squaremo closed 4 years ago

squaremo commented 4 years ago

jk validate accepts path directly as arguments on the command line; however, it uses std.read to load them for validation, and that can only read things in the "input directory". The input directory is deliberately not a flag for jk validate, since it's intended the files are supplied via e.g., find.

This gives us a bit of a conundrum! We could turn the directory limiting off for read, but that lets a validation function (or any other code) also read from anywhere.

dlespiau commented 4 years ago

I was thinking of a (new :scream:) flag to lift read limits:

--read-root top level directory read are constrained to

This would allow to restrict reads to the subtree defined by that root directory. For instance the root of a git checkout even if the script is in a subdirectory.

dlespiau commented 4 years ago

That said, I also feel the current way of handling input directories and limits is quite confusing. Not sure how to make it better, introducing a new flag isn't likely to be a good way to simplify things.

squaremo commented 4 years ago

Yes, I have still not internalised how input directories work, and have to think it through every time ..

squaremo commented 4 years ago

Implementation notes: