-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Update go-toml to v2 #9131
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
Update go-toml to v2 #9131
Conversation
|
Skipping CI for Draft Pull Request. |
|
FYI @pelletier, if I properly attributed your solution |
Updates host file parsing to use new v2 method rather than the removed toml.Tree. Signed-off-by: Derek McGowan <derek@mcg.dev>
|
Removed the "DisallowUnknownFields" because the CRI tests will fail. I didn't look into it more but seems likely we have some bad test configuration we should look at and consider enabling it. Also when configuration fails the error isn't super clear now. |
This seems regression. Can we at least print a warning when an unknown field is present in a toml? |
services/server/config/config.go
Outdated
| if err := file.Unmarshal(config); err != nil { | ||
| // TODO: Add DisallowUnknownFields, requires better testing and bubbling errors | ||
| if err := toml.NewDecoder(f).Decode(config); err != nil { | ||
| return nil, fmt.Errorf("failed to unmarshal TOML: %w", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just in case you don't already know, you can type-assert the error returned by Decode into a toml.DecodeError, which allows you to print a more human friendly error (example).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, added better error handling using the toml error types, thanks.
Not a regression, they were ignored before. I added a warning log. Now it will try to parse disallowing the unknown fields, catch the error, log the unknown fields, then try again allowing the unknown fields. |
Add error log for failure to parse toml Signed-off-by: Derek McGowan <derek@mcg.dev>
|
/cherrypick release/1.7 |
|
@djdongjin: #9131 failed to apply on top of branch "release/1.7": DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Updates host file parsing to use new v2 method rather than the removed toml.Tree.