23andMe / Yamale

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

fix(cli): check schema to be a valid path first #241

Closed AndreyNautilus closed 5 months ago

AndreyNautilus commented 5 months ago

Check that schema_name is a valid file before iterating over parent directories of data_path (the change is taken from quite old PR). Fix for https://github.com/23andMe/Yamale/issues/238 .

Details

It is a breaking change in terms of behaviour (as pointed out in the old PR), because invocations like yamale a/b/c.yaml --schema=x/y/z/schema.yaml will now first check $PWD/x/y/z.yaml file for being a schema instead of starting from $PWD/a/b/x/y/z/schema.yaml and iterating over parents ($PWD/a/x/y/z/schema, $PWD/x/y/z/schema, etc). This changes the order in which schema files are used. But, to be honest, I don't think this will cause many troubles, because the "fixed" behaviour corresponds to linux-way of referencing files, while the "old" behaviour was a bit counter-intuitive.

It is possible to implement a fix without changing the behaviour - basically check schema_name for being a file after all other attempts fail, but that will require a bit more changes and may complicate the code. I can implement it if you insist.

PR structure

There are 2 commits: