Skip to content
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

Bug fix: decode TOML array of tables #652

Merged
merged 3 commits into from
Apr 26, 2022
Merged

Bug fix: decode TOML array of tables #652

merged 3 commits into from
Apr 26, 2022

Conversation

gcheadle-vmware
Copy link
Contributor

@gcheadle-vmware gcheadle-vmware commented Apr 19, 2022

fixes: #630

added case []map[string]interface{}: to conversion process.

@@ -74,7 +74,13 @@ func (c Conversion) fromUnorderedMaps(object interface{}) interface{} {
typedObj[i] = c.fromUnorderedMaps(item)
}
return typedObj

case []map[string]interface{}:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having the case map[interface{}]interface{}: earlier in this function makes me think that we should cover the similar case: []map[interface{}]interface{}:. However, I could not construct a TOML map with non 'string' map keys.

Ultimately, I was left with this question:

  • "Why is the input of an array of maps not covered by the []interface{} case?"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another way to ask the question:

  • "Why does toml.decode return different types of slices rather than always returning []interface{}"

Found others hitting up against the toml.Unmarshal inconsistencies: BurntSushi/toml#169

pkg/orderedmap/convert.go Show resolved Hide resolved
pkg/orderedmap/convert.go Outdated Show resolved Hide resolved
Copy link
Contributor

@pivotaljohn pivotaljohn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

In addition to @cppforlife's formatting nits, I'm suggesting a note to explain both where this specific type of slice is coming from and why we can't just combine all the cases... for now.

Thanks for tackling this one, @gcheadle-vmware.

pkg/orderedmap/convert.go Show resolved Hide resolved
@gcheadle-vmware gcheadle-vmware merged commit b11b9ea into develop Apr 26, 2022
@pivotaljohn pivotaljohn deleted the toml-decode branch April 27, 2022 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

@ytt:toml.decode() fails to marshal TOML array of table values
4 participants