puppetlabs / puppet-lint

Check that your Puppet manifests conform to the style guide
https://puppetlabs.github.io/puppet-lint/
MIT License
19 stars 13 forks source link

Read manifest from stdin and write modifications to stdout #214

Open bezier-h opened 2 months ago

bezier-h commented 2 months ago

Use Case

Git can be configured to automatically run filters on files when e.g. running git add thanks to filters. See the relevant documentation.

However this requires the linter to be able to read the file to process on its stdin and write its modifications to stdout. Git will indeed only use the stdout of the filter to determine what to add to the index, which with puppet-lint means it thinks the whole file has been deleted since it did not write anything to stdout.

Describe the Solution You Would Like

Changing the default behaviour of the tool would most probably incur breakage so it is not recommended.

There are two solutions I can think of:

Describe Alternatives You've Considered

Implementing the linter as a long running filter process as per the documentation, but that would require significant work, whereas the proposed solution is rather straightforward.

ekohl commented 2 months ago

I'd prefer a dash for the input filename since that's a common convention. Then it should error out if it receives multiple files