Documentation
¶
Overview ¶
Package yamlstrict decodes a YAML (or JSON) config file and fails on any key the target type does not have, naming the key by its dotted path. sqi-server (internal/config) and sqi-worker (internal/worker/config) both read their config files through it, so a misspelled key is an error on both rather than a silently dropped line that leaves a setting on its default.
It exists as a leaf because internal/config pulls internal/auth/oidc, so the worker binary can never import it. This package imports nothing internal.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Decode ¶
Decode decodes data into v and fails on a key v's shape does not have, or a value of the wrong shape (a section where a value belongs, or the reverse). yaml reports such a key by line and bare name only, so each failure is rewritten to name the key's dotted path, and every one is reported. Empty data decodes to nothing and is not an error. A second YAML document with anything in it is an error, since only the first would be read.
func DecodeNode ¶
DecodeNode decodes n into v, a pointer to a struct, as strictly as Decode decodes a file: a key v's struct does not have is an error, worded as yaml's own decoder words one so Decode names it by dotted path, and it is reported together with every type error in the rest of n. A custom UnmarshalYAML that decodes a mapping calls it in place of n.Decode, which does not inherit the outer decoder's strictness.
The accepted keys are read from v's yaml struct tags, so they cannot drift from the fields. A YAML merge key (<<) is accepted and the keys it merges in are checked too.
func Unmarshalers ¶
Unmarshalers returns every type reachable from t, through struct fields, pointers, slices, arrays and map keys and values, that implements yaml.Unmarshaler, each once, in the order first reached. A test of a config type calls it so a new custom UnmarshalYAML cannot silently bypass the strict decode: each one found must be reviewed (a mapping must go through DecodeNode) and listed.
Types ¶
This section is empty.