Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate defining a schema for faucet.yaml & gauge.yaml #3482

Open
gizmoguy opened this issue Mar 5, 2020 · 2 comments
Open

Investigate defining a schema for faucet.yaml & gauge.yaml #3482

gizmoguy opened this issue Mar 5, 2020 · 2 comments

Comments

@gizmoguy
Copy link
Member

gizmoguy commented Mar 5, 2020

There are systems like https://github.com/alecthomas/voluptuous which let you programmatically define a YAML configuration schema.

Defining our configuration via a schema that can be validated against would give us some benefits:

  1. Easy to validate for parsing issues (and automatically generating nice error messages)
  2. Easy to autogenerate documentation
  3. Easy to deprecate and change options

I suggest voluptuous as that's what https://github.com/home-assistant/core uses and they seem to have good success, however there might be better systems.

@gizmoguy gizmoguy added this to the faucet 1.10.0 milestone Mar 5, 2020
@shivarammysore
Copy link
Contributor

One suggestion that I can add to a schema definition is use of OpenAPI The advantage with this model is that we can easily use tooling built for this.

@shivarammysore
Copy link
Contributor

A couple of notes from our experience that may be helpful:
Overloaded Keys
A key within faucet.yaml should not be overloaded from a schema perspective. For example, there is at least one faucet.yaml overloaded key - vlans. It is a top-level index of a network’s vlan objects; and, within a routers item it is an array of vlan names.

Faucet Index Objects
Faucet.yaml uses index objects where keys are network-specific identifiers for faucet-defined semantics. From a human ease-of-use perspective this seems fine; however, from a semantic perspective it is a problem.

This design prevents these index keys from being properly typed. Instead, faucet should consider using arrays of faucet defined objects that used faucet-defined keys to specify network typed values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants