-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DecodeWithOptions method for Node #691
base: v3
Are you sure you want to change the base?
Conversation
@niemeyer is there any chance to get this merged? #460 is a blocker for us to adopt v3, while v2 has bugs that require us to move away from it. |
This commit is the latest v3 with go-yaml/yaml#691 cherry-picked on top of it, to provide support for strict unmarshaling when doing custom unmarshaling (see go-yaml/yaml#460) Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
* Use gopkg.in/yaml.v3 everywhere This replaces all usages of gopkg.in/yaml.v2 by v3 everywhere, adapts the UnmarshalYAML methods to the new signature, and replaces the UnmarshalStrict calls by the decoder with KnownFields flag. util.YAMLMarshalUnmarshal doesn't work because it doesn't support unmarshaling map[interface{}]interface{} Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com> * Fix yaml.YAMLMarshalUnmarshal yaml.v3 can't unmarshal to map[interface{}]interface{}, but actually map[string]interface{} should be enough. Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com> * go mod tidy Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com> * Add faillint for gopkg.in/yaml.v2 Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com> * Use custom fork of gopkg.in/yaml.v3 This commit is the latest v3 with go-yaml/yaml#691 cherry-picked on top of it, to provide support for strict unmarshaling when doing custom unmarshaling (see go-yaml/yaml#460) Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com> * Fix TestAlertmanagerNotificationLimitsOverrides There's no such field as `alertmanager_notification_limits_per_integration` and the fixed strict parsing has detected this. How does this test pass in `main`? Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com> * Remove cfg.validateYAMLEmptyNodes and adapt test gopkg.in/yaml.v3 implementation doesn't seem to set the entire value to zero value if an empty node is specified in the YAML. So we don't need that check again, and we can adapt the test just to check that this assertion is true. Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
I think this is nice and I would also love this to be merged in. The only issue left from #460 is that you cannot know inside |
@niemeyer WDYT? Thanks very much. it's a great PR. |
Ping @niemeyer , is there anything missing for this to get merged? I'm up for even cutting a new PR as you prefer if that's the case, I'm really missing this feature. PS: I doodled with an alternative interface here https://github.com/fornellas/yaml/tree/node_known_fields. |
Suggested fix for #460.
In my opinion it's the most straightforward way to fix the issue while keeping backwards compatibility and considering the small number of options (currently only one).
Obviously open for discussion.