engine: resources, lang: Set resource fields more accurately

There were some bugs about setting resource fields that were structs
with various fields. This makes things more strict and correct. Now we
check for duplicate field names earlier (duplicates due to identical
aliases) and we also don't try and set private fields, or incorrectly
set partial structs.

Most interestingly, this also cleans up all of the resources and ensures
that each one has nicer docs and a clear struct tag for fields that we
want to use in mcl. These are mandatory now, and if you're missing the
tag, then we will ignore the field.
This commit is contained in:
James Shubin
2023-08-23 00:52:21 -04:00
parent b8d87e2d5a
commit c1850e0e20
24 changed files with 394 additions and 212 deletions

View File

@@ -53,10 +53,19 @@ type PasswordRes struct {
init *engine.Init
// Length is the number of characters to return.
// FIXME: is uint16 too big?
Length uint16 `yaml:"length"` // number of characters to return
Saved bool // this caches the password in the clear locally
CheckRecovery bool // recovery from integrity checks by re-generating
Length uint16 `lang:"length" yaml:"length"`
// Saved caches the password in the clear locally.
Saved bool
// CheckRecovery specifies that we should recover from, regenerate, and
// carry on casually without erroring the resource if the "check"
// facility fails. This can happen when loading a saved password from
// disk which is not of the expected length. In this case, we'd discard
// the old saved password and create a new one without erroring.
CheckRecovery bool
path string // the path to local storage
recWatcher *recwatch.RecWatcher