v0.x: the config stack a tool declares is its precedence¶
Spec 0204 makes the layer list a tool declares the order its configuration resolves in. Before it, the list said which layers a tool wired, and the order it gave was documentation: the store always appended the layers in the framework's order.
What changed¶
props.Tool.Config.Layersis the stack, lowest precedence first. The store appends each layer in exactly that order, so moving an entry moves its precedence. Unstated, it resolves to the framework default:defaults,files,project,env,flags.- Three orders are refused, by
props.New, by the store and by the generator, because each makes a tool quietly unsafe:defaultsmust be the lowest layer when present. A layer below the compiled-in defaults can never be read.flagsmust be the highest layer when present. A layer above it means a flag the user passed does not take.projectmust sit belowenv. The trust filter assumes a repository's file cannot outrank the environment.
props.Tool.ConfigLayersis deprecated. A tool still setting it resolves exactly as before: its layers, in the framework's order, whatever order it lists them in.- The manifest field moves.
properties.config_layersbecomesproperties.config.layers. The firstregeneratemoves an existing list into the new field in the framework's order, logs the move with the other derived values, and renders the root asprops.Tool{Config: props.ConfigSpec{Layers: ...}}. What the tool resolves does not change. --config-layersandgtb set config.layerstake an ordered list, lowest precedence first, and refuse the three orders above.
Config files in other formats¶
A config file's format now comes from its extension (spec 0204 D2), and every format except YAML is a link: pkg/config/formats/<format>, blank-imported from main, for toml, json, hcl, ini, xml, dotenv (.env) and properties.
- A
--configfile with one of those extensions is refused unless the tool links the format. A.jsonfile used to be read as YAML, which mostly worked because JSON is nearly a subset of YAML; it is now refused with a hint naming the link. Linkpkg/config/formats/json, or rename the file to.yaml. - Any other extension is read as YAML, as before.
~/.mytool.confkeeps working. - An embedded
ConfigPathsasset in another format is now decoded as that format.props.Assetsmerged a.tomlasset and re-emitted it as TOML, which the store then read as YAML. The tool must link the format for the asset to be read.
Migrating a hand-written tool¶
Replace the deprecated field with the spec, in the order you want the layers to resolve:
// Before
props.Tool{ConfigLayers: []props.ConfigLayer{props.LayerFlags, props.LayerEnv, props.LayerFiles, props.LayerDefaults}}
// After
props.Tool{Config: props.ConfigSpec{Layers: []props.ConfigLayer{props.LayerDefaults, props.LayerFiles, props.LayerEnv, props.LayerFlags}}}
A list written highest-first, as in the example, has to be reversed. Written as it was, props.New refuses it because defaults is not the lowest layer.
Migrating a generated project¶
Run gtb regenerate project. Nothing else is needed.