Add a flag to treat warnings as errors
When running ldap2pg, it can be useful to be able to upgrade a warning to an error, so that we get a failure. This is a good way to quickly see if something could be wrong with my configuration, while allowing ldap2pg to adopt warnings for corner cases.
Thanks @andersbogsnes
In #337 , I change a warning to an error. I also changed behaviour on mispelled attribute to raise an error. This make ldap2pg less sloppy.
This is a good reason to implement #286 . It's easy to check for warning if we count them.
@andersbogsnes do you prefer to stop on first warning (i.e. make warning critical) or continue but fail in the end if there has been one or more warning ?
If I'm running in strict mode, it's generally because I want to fail fast and get immediate feedback - that is also the behaviour of other tooling, including python:
Sphinx: https://www.sphinx-doc.org/en/master/man/sphinx-build.html (See the -W flag) Python: https://docs.python.org/3/using/cmdline.html#cmdoption-w (when running in -Werror mode)
Great. So i suggest a --strict switch flag with the YAML counterpart strict: yes. Fail fast on first warning.
As of ldap2pg v6, this would apply to the following warning:
- Bad DN
- Unexpected DN
- Reusing unmanaged role
Not for the following warning:
- Running a prerelease
- Dry run
By the way, I suggest to replace the following warning by an error
- Bad verbosity (flags.go)
- Bad integer (ldap/rc.go)