tfutils / tfenv

Terraform version manager
MIT License
4.42k stars 446 forks source link

fix: filter out Artifactory version & sort versions #402

Open samuel-phan opened 1 year ago

samuel-phan commented 1 year ago

fix #400 #401

fcatacut commented 11 months ago

@Zordrak any chance that this PR can be reviewed? We're also running into issue #400, and this PR looks to resolve it.

fbritoferreira commented 9 months ago

We running into the same issue, would it be possible to merge this?

dvaumoron commented 9 months ago

The p flag for the s command of sed is meant to display the changed line, it doesn't seem possible to exclude the artifactory line and retrieve the version on other line in one command. So if you want to do it with one sed call, you should use two commands :

sed -En -e 's#.*[A-Za-z]+/([0-9]+\.[0-9]+\.[0-9]+(-(rc|beta|alpha|oci)-?[0-9]*)?).*##' -e 's#.*([0-9]+\.[0-9]+\.[0-9]+(-(rc|beta|alpha|oci)-?[0-9]*)?).*#\1#p'

That did not remove duplicates, and i am not sure that will be more readable than the use of two grep calls.

Changing the showed line 77 in the PR with grep -v -E "[A-Za-z]+/[0-9]+\.[0-9]+\.[0-9]+ wouldn't be enough to make it more generic ?

dvaumoron commented 9 months ago

the errors seems to be linked to https://github.com/golang/go/issues/49425

dvaumoron commented 9 months ago

the first go version without this bug is the 1.11, the first terraform release with 1.11+ compatibility instead of 1.10+ is the 0.11.9, i will upgrade the tests accordingly