-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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: Add "anytrue" function #26498
lang/funcs: Add "anytrue" function #26498
Conversation
This commit adds an `anytrue` function to Terraform configuration. It's mostly a complement to the recently introduced `alltrue` function.
Codecov Report
|
Thanks for opening this PR, @artburkart! What you've written here looks like a good thing we could move forward with. I think there are some opportunities to simplify it further, if you'd be interested:
What do you think? 🤔 |
That sounds valid to me. Thanks for the explanatory links and code snippet. I'll give it a shot. 👍 |
Rather than manually type check, lean on cty to do it for us. Also, use "Or" and "And" operation methods rather than integration methods, since we're not working on the boundary between cty and the native Go type system.
380a1ba
to
1a259c5
Compare
Is this more along the lines of what you were looking for? |
This looks good to me, @artburkart! Thanks for working with me on this. My one remaining note is that I think the explicit check for length == 0 doesn't seem to be needed anymore, because the situations where the loop iterates zero times would produce the same results, I think? Not a big deal, but where possible I try to avoid using If you're ready to mark this as "Ready for review" then I'd love to merge it, either way. |
@apparentlymart — I've removed the |
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.
Thanks @artburkart! This looks great and I'm going to merge it now.
I'm also going to backport it into the v0.14 branch so it can be included in the forthcoming v0.14.0 release (because the main branch is now v0.15), because I think it makes sense to release both alltrue
and anytrue
together.
That sounds great 👍 |
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. |
This commit adds an
anytrue
function to Terraform configuration. It'smostly a complement to the recently introduced
alltrue
function.