from Hacker News

Show HN: Config-file-validator – CLI tool to validate all your config files

by treebeard5440 on 9/29/23, 12:44 PM with 17 comments

  • by jmholla on 9/29/23, 5:55 PM

    I was expecting this to validate the configuration files are also valid for their use cases, not just valid JSON, TOML, etc.

    If you're looking for that and Python is your jam, the library cerberus[0] is very good at it.

    [0]: https://github.com/pyeve/cerberus

  • by dangets on 9/29/23, 7:20 PM

    It doesn't include validators for TOML and INI, but if you're doing JSON and YAML, I would take a look at using or building upon CUE (https://cuelang.org/). It is a different take on schema definition (plus more), and is surprising terse and powerful model.
  • by treebeard5440 on 9/29/23, 12:56 PM

    I’m one of the maintainers of the project. We’re a DevOps team and maintain a lot of different types of configuration files for all the different tools and services we support - often in the same repo. Rather than using a lot of different validators for each config format we wanted a single tool to validate all types. This enabled us to include config validation as a quality gate in our CI/CD to detect config file syntax issues early before they failed in functional testing. We open-sourced it to help other teams with similar workflows. Please let me know if you have any comments or suggestions!
  • by jdwyah on 10/1/23, 3:08 PM

    I've been thinking about this a bunch. It's weird that we our apps are typesafe in lots of ways and then just hope that some magic string config & env vars are available, and there isn't even a comprehensive list of what our apps expect.

    Anyone else think a property spec like the specker thing, than maybe some code gen on top of that that enforces the code is actually using it is interesting?

  • by CableNinja on 9/29/23, 4:34 PM

    I recently made a python library that does this. You build up specs (a json/dict), and at each layer that descends, you add a `spec_chain` entry, and build another spec for the next level. Once the specs are built, you can validate, as well as get config defaults from it.

    https://pypi.org/project/specker

  • by ripperdoc on 9/29/23, 8:06 PM

    For validating the actual values and types in config files, I've been planning to use JSON Schema to define the configuration data and then validate files against it. But I haven't seen others talk about that a lot - is it something I'm missing?
  • by treebeard5440 on 9/30/23, 12:04 AM

    Anyone else have any suggestions for improvements or things that you'd expect to see in a tool like this? I'll take anything you've got :D All feedback so far has been added as Github issues.