-
Notifications
You must be signed in to change notification settings - Fork 16
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
Fix issue with unmarshaling yaml maps #67
Conversation
We could alternatively maintain a fork of |
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.
LGTM! What a nasty yak shave!
Thanks for the review. A nasty shave indeed, but it seemed necessary for the problem I'm working on. Unfortunately, the last version I pushed when I opened the PR didn't quite work. The behavior was not the same as the native Unmarshal for unexpected conditions like an empty string or invalid YAML. I've worked around this in the most recent commit and tests seem to pass now. Mind taking another look? |
Actually, hold off on the review, it's still not right. 👎 |
Okay, now it should be ready for another round of review! |
Nope, still finding other errors with the variants of unmarshaling. I'll need to write a more abstract unmarshaler that handles different types. This only works for |
Finally got to the bottom of it with the latest update. |
Added unit test for |
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.
LGTM! I had a few nits about code style and defensive coding, but feel free to ignore/punt as these are minor issues IMO.
All good suggestions. Updated and incorporated in 6e977ec. |
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.
LGTM!
Thanks for the helpful review! |
This works around an issue in the
yaml
package that causes YAML maps to be unable to be marshalled to JSON.What was happening was that unmarshaling a map variable like this:
would result in a variable of type
map[interface{}]interface{}
rather thanmap[string]interface{}
. The former cannot be marshaled to JSON correctly since the JSON package (and the JSON spec) require that keys are strings. Hence you could not marshal the map to JSON in a boilerplate template like this:where
toPrettyJson
is a function in sprig. It would instead just render an empty string.