You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Our current YAML parsing works, but there might be a less-boilerplatey way to do YAML unmarshaling while:
enforcing required fields
enforcing that no extra unknown fields were present
doing custom validation on field values
The upstream YAML parser has an interesting bug go-yaml/yaml#460 where it will enforce that no extra fields are present, but that feature doesn't work if you call node.Decode(). That may limit our options for doing this cleanly.
Example of problematic code: in spec.go, there is some repeated almost-copy-pasted boilerplate code that looks like this:
Before this, each UnmarshalYAML function was a copy-pasted block of
20-ish lines of boilerplate. With this change, each UnmarshalYAML
function turns into a one-liner which calls unmarshalPlain.
This requires a somewhat regrettable amount of reflection code, but it's
arguably no more confusing than what was there before, while having the
benefit of being more concise and DRY.
Fixes#30.
Before this, each UnmarshalYAML function was a copy-pasted block of
20-ish lines of boilerplate. With this change, each UnmarshalYAML
function turns into a one-liner which calls unmarshalPlain.
This requires a somewhat regrettable amount of reflection code, but it's
arguably no more confusing than what was there before, while having the
benefit of being more concise and DRY.
Fixes#30.
I'm attempting to use stacked PRs here; I intend to switch the base
branch of this PR to `main` once the `drevell/for-each-values-from`
branch is merged.
TL;DR
Our current YAML parsing works, but there might be a less-boilerplatey way to do YAML unmarshaling while:
The upstream YAML parser has an interesting bug go-yaml/yaml#460 where it will enforce that no extra fields are present, but that feature doesn't work if you call
node.Decode()
. That may limit our options for doing this cleanly.Example of problematic code: in
spec.go
, there is some repeated almost-copy-pasted boilerplate code that looks like this:Copy-pasted code like this is almost always harmful.
Detailed design
No response
Alternatives considered
No response
Additional information
No response
The text was updated successfully, but these errors were encountered: