coreos / butane

Butane translates human-readable Butane Configs into machine-readable Ignition Configs.
https://coreos.github.io/butane/
Apache License 2.0
255 stars 70 forks source link

Add generic mechanism for filtering out Ignition spec fields; use it in spec doc generation #467

Closed bgilbert closed 1 year ago

bgilbert commented 1 year ago

flatcar, openshift, and r4e all want to prevent certain Ignition fields from being used. Rather than open-coding a filter function at the end of each spec's translation pass, add a generic filter mechanism that maps filter expressions onto errors. The filter expressions are strings similar to ContextPath but without slice indexes. This is a breaking API change, since config/util.Translate() now requires a config object with a FieldFilters() method.

Adjust context paths in some existing checks to be compatible with this approach.

Use the new API from https://github.com/coreos/ignition/pull/1622 to connect the new filter mechanism to docs generation. This allows us to remove unless: directives from the doc YAML (and from Ignition's doc generator) and automatically omit fields that are filtered in each spec.

The refactor makes the flatcar clevis filter more strict, including in stable specs; it now triggers on clevis sections with only irrelevant secondary fields. Any config newly affected by this was at least misleading if not outright incorrect.