terraform icon indicating copy to clipboard operation
terraform copied to clipboard

lang/funcs: Add sortsemver function

Open vsimon opened this issue 6 years ago • 15 comments
trafficstars

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.

vsimon avatar Sep 04 '19 20:09 vsimon

CLA assistant check
All committers have signed the CLA.

hashicorp-cla avatar Sep 04 '19 20:09 hashicorp-cla

Codecov Report

Merging #22689 (66423da) into master (4e345b6) will increase coverage by 0.01%. The diff coverage is 100.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:

codecov[bot] avatar Aug 08 '20 07:08 codecov[bot]

Hello, it's been awhile but I've updated this aged PR to address:

  1. Using hashicorp/go-version and its NewSemver function for parsing.
  2. Adding a version constraint. Constraints are defined and supported by https://godoc.org/github.com/hashicorp/go-version#Constraint
  3. Using sort.Stable (and by extension go-version's LessThan function)
  4. Updating tests and documentation

vsimon avatar Aug 10 '20 17:08 vsimon

ping @teamterraform

vsimon avatar Oct 26 '20 05:10 vsimon

ping @teamterraform

vsimon avatar Nov 29 '20 09:11 vsimon

Sorry for pings @apparentlymart @mildwonkey but would you know if anybody would be able to look at this?

vsimon avatar Dec 02 '20 22:12 vsimon

ping

vsimon avatar Dec 28 '20 22:12 vsimon

ping @alisdair 🙏

vsimon avatar Jan 05 '21 22:01 vsimon

ping @teamterraform @alisdair for a re-look 🙏

vsimon avatar Jun 30 '21 16:06 vsimon

This would be a big help to my projects @teamterraform @alisdair

superbobdthm avatar Jun 30 '21 16:06 superbobdthm

ping @teamterraform @alisdair for a re-look

@vsimon Thank you for your continual effort to get this merged.

superbobdthm avatar Jun 30 '21 16:06 superbobdthm

ping @teamterraform @alisdair for a re-look

arvsr1988 avatar May 26 '22 08:05 arvsr1988

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.

crw avatar Jun 11 '22 00:06 crw

Would love to see this integrated even if the plan for built-ins changes over time

boxrick avatar Mar 31 '23 19:03 boxrick

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!

crw avatar Aug 30 '24 17:08 crw

After repeated discussions in triage, I am going to close this pull request, per the above comment. Thanks!

crw avatar May 21 '25 22:05 crw

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.

github-actions[bot] avatar Jun 21 '25 02:06 github-actions[bot]