-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
lang/funcs: lookup() can work with maps of lists, maps and objects #22269
Conversation
lookup() can already handle aribtrary objects of (whatever) and should handle maps of (whatever) similarly.
types match or can be converted.
lang/funcs/collection.go
Outdated
if len(args) == 3 { | ||
_, err = convert.Convert(args[2], ty.ElementType()) | ||
if err != nil { | ||
return cty.NilType, function.NewArgErrorf(0, "the default value and map elements must have the same type") |
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.
The 0
here indicates that the problem is with the zeroth argument; perhaps it would be clearer to indicate 2
so that Terraform will indicate the default value as the subject of the error when it prints out diagnostics, as a subtle additional indication that it's probably the default value that ought to change to match the map, rather than the other way around.
Looking good, thanks! I left some minor notes inline. |
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.
🎉
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
lookup() can already handle arbitrary objects of (whatever) and should
handle maps of (whatever) similarly.
The documentation does not mention any limitation to the types returned, which was inconsistent with the error message when a map of objects, lists or maps was used.
Fixes #22267