23andMe / Yamale

A schema and validator for YAML.
MIT License
679 stars 88 forks source link

Option to disable recursive file search #181

Open reconman opened 2 years ago

reconman commented 2 years ago

I wanted to use Yamale to validate all YAML files in my Github repository.

But Yamale also wants to validate my .github/workflows/CI.yml file.

Can you introduce a command line option to disable recursive file searches so sub-folders are ignored?

mildebrandt commented 2 years ago

Thanks for the suggestion, I'll think about how this can be done. In the meantime, you can do something like the following:

find *.yaml -exec yamale -s schema.yaml {} \;
reconman commented 2 years ago

Instead of \; at the end, it should be +, otherwise the exit code will be 0 (success) instead of 1.

This is useful for calling it as part of build pipelines, as the pipeline will fail if any command returns non-0.

Additionally, the pattern in the find has to be more restrictive, otherwise you would validate the schema.yaml against itself.