-
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
core: Add list() interpolation function #7528
Conversation
Direction looks good. +1 for this as a stop-gap solution until we can parse non-primitives directly in HIL. |
989924a
to
2c5e424
Compare
I've cleaned this up:
I'll remove the WIP now - cc @phinze. |
LGTM for strings. Agreed we should make it work for lists and maps as well. |
The list() interpolation function provides a way to add support for list literals (of strings) to HIL without having to invent new syntax for it and modify the HIL parser. It presents as a function, thus: - list() -> [] - list("a") -> ["a"] - list("a", "b") -> ["a", "b"] Thanks to @wr0ngway for the idea of this approach, fixes #7460.
Allow lists and maps within the list interpolation function via variable interpolation. Since this requires setting the variadic type to TypeAny, we check for non-heterogeneous lists in the callback.
2c5e424
to
2bd7cfd
Compare
Expanded the list interpolation to accept lists and maps, and the concat function to accept lists of lists and lists of maps. This now also fixes #7146 |
switch arg := arg.(type) { | ||
case string: | ||
// we also allow bare strings for backwards compatibility | ||
outputList = append(outputList, ast.Variable{Type: ast.TypeString, Value: arg}) |
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.
Let's nuke the BC here. I believe we've already gone talking about this case like it's gone! 😀
Nice work @jbardin!! A few inline nits, but this looks super solid overall. |
This will allow the concat interpolation function to accept lists of lists, and lists of maps as well as strings. We still allow bare strings for backwards compatibility, but remove some of the old comment wording as it could cause confusion of this function with actual string concatenation. Since maps are now supported in the config, this removes the superfluous (and failing) TestInterpolationFuncConcatListOfMaps.
73d6158
to
8dcbc0b
Compare
Used Printable, since it will usually make a better user-facing error. |
LGTM |
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. |
The list() interpolation function provides a way to add support for list literals to HIL without having to invent new syntax for it and modify the HIL parser.
It presents as a function, thus:
Thanks to @wr0ngway for the idea of this approach, fixes #7460.
Assuming this is the route we wish to follow, we should make it work with types other than strings - the initial quick implementation is to get a feel for using a function rather than syntax.
cc @phinze, @mitchellh, @jbardin