terraform
terraform copied to clipboard
lang/funcs: Add sortsemver function
Reference: #22688 To support re-ordering the elements of a given list of strings so that the elements matching a given version constraint are returned in precedence order.
Codecov Report
Merging #22689 (66423da) into master (4e345b6) will increase coverage by
0.01%. The diff coverage is100.00%.
| Impacted Files | Coverage Δ | |
|---|---|---|
| backend/remote/backend.go | 62.42% <ø> (ø) |
|
| lang/funcs/string.go | 100.00% <100.00%> (ø) |
|
| lang/functions.go | 96.29% <100.00%> (+0.02%) |
:arrow_up: |
| internal/providercache/dir.go | 67.34% <0.00%> (-6.13%) |
:arrow_down: |
Hello, it's been awhile but I've updated this aged PR to address:
- Using hashicorp/go-version and its NewSemver function for parsing.
- Adding a version constraint. Constraints are defined and supported by https://godoc.org/github.com/hashicorp/go-version#Constraint
- Using sort.Stable (and by extension go-version's LessThan function)
- Updating tests and documentation
ping @teamterraform
ping @teamterraform
Sorry for pings @apparentlymart @mildwonkey but would you know if anybody would be able to look at this?
ping
ping @alisdair 🙏
ping @teamterraform @alisdair for a re-look 🙏
This would be a big help to my projects @teamterraform @alisdair
ping @teamterraform @alisdair for a re-look
@vsimon Thank you for your continual effort to get this merged.
ping @teamterraform @alisdair for a re-look
Thanks for this submission! As to why this PR has not been reviewed, please see this comment: https://github.com/hashicorp/terraform/issues/28855#issuecomment-856345294, specifically:
We're being pretty cautious about adding new functions that overlap with existing use-cases because Terraform has grown quite an unwieldy collection of builtins over the years, and so we've been considering various ways to allow for externally-defined functions (e.g. https://github.com/hashicorp/terraform/issues/2771) to avoid continuing to grow that set. However, that's not something we'll be working on in the very near future, due to our current focus being elsewhere, so we'll revisit this at a later time and post any updates in those other issues.
In this case, at this time, the team believes a sortSemVer function would be better suited as a plugin than as a built-in function. I will certainly update this PR when this "function plugin" functionality is available. Thanks again for your submission and for the interest in this function.
Would love to see this integrated even if the plan for built-ins changes over time
Just a heads-up that Provider-defined Functions were released in Terraform 1.8. Please see the documentation here: https://developer.hashicorp.com/terraform/plugin/framework/functions
I will leave this PR open as I believe the champions of this issue believe this should be a built-in function, but if you find a way to contribute this via the provider functions, please let us know. Thanks!
After repeated discussions in triage, I am going to close this pull request, per the above comment. Thanks!
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.