-
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
Split of "" should be empty. Length of empty array should be 0 #2973
Conversation
c6ca63a
to
ff8fb43
Compare
Hi Tom, |
@radeksimko - no, or at least not entirely if you add just my test changes to your branch, then the tests fail, like so:
|
ff8fb43
to
f0059d3
Compare
I went back and forth on this as I worked on the https://twitter.com/phinze/status/614116280480739328 I think this sums it up nicely:
So I figured we'd toss in a Seems like a tough trade off between "one more interp func" and POLA. Thoughts? |
Although quite kludgy, I think one way to do this at the moment is to use a My five cents: I think having split returning a unitary list for empty strings is expected for anyone coming from any (all?) other language, but it feels like it should have the alternative behaviour since we can't pass around lists "natively" (i.e., resorting to |
Now that #3239 is merged, and thus we have the In other words, it should now be possible to write the original example as |
f0059d3
to
96275ee
Compare
Sounds great to me. I've added a test explicitly testing the combination of all 3 functions, as I didn't see that currently. |
A PR that's iterated into a test addition. 💓 Thanks @bobtfish! |
Split of "" should be empty. Length of empty array should be 0
🎉 |
…userdata_validation Port user_data length validation to aws_launch_configuration
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. |
In place we want to do:
count = "${length(split(",", var.list_of_things))}"
and in some cases have an empty list (i.e. ""), and therefore get 0 resources.To do this, splitting the string "" needs to return an empty array (rather than an array with one item which is empty), and the length function needs to do the right thing if it sees an empty array.