Skip to content
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

~> 1.0 should give me the same version as >= 1.0.0, < 2.0.0 does #226

Closed
skyzyx opened this issue May 10, 2022 · 4 comments
Closed

~> 1.0 should give me the same version as >= 1.0.0, < 2.0.0 does #226

skyzyx opened this issue May 10, 2022 · 4 comments
Assignees
Labels
enhancement Refactor existing code for better performance and quality

Comments

@skyzyx
Copy link

skyzyx commented May 10, 2022

Is your feature request related to a problem? Please describe.

(Branching off from #224)

I've been observing that using ~> 1.0 with tfswitch gives me the latest 1.0.x release rather than the latest 1.x release.

Terraform's docs say:

~>: Allows only the rightmost version component to increment. For example, to allow new patch releases within a specific minor release, use the full version number: ~> 1.0.4 will allow installation of 1.0.5 and 1.0.10 but not 1.1.0. This is usually called the pessimistic constraint operator.

~> 1.0 is expected to be equivalent to >= 1.0.0, < 2.0.0, but shorter.

I just upgraded a bunch of Homebrew packages yesterday, so now I have 0.13.1218. But I've been observing it since Terraform 1.1 came out.

This is my alias for cd:

cdtfswitch() {
    builtin cd "$@" || true
    cdir=$PWD
    if [ -e "$cdir/versions.tf" ]; then
        tfswitch
    fi
}

versions.tf is:

terraform {
  required_version = "~> 1.0"

  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 4.0"
    }
  }
}

Describe the solution you'd like

~> 1.0 should give me the same version as >= 1.0.0, < 2.0.0 does.

@skyzyx skyzyx added the enhancement Refactor existing code for better performance and quality label May 10, 2022
@llamahunter
Copy link

@warrensbox
Copy link
Owner

@skyzyx
The latest terraform version is 1.1.9
Run show latest: tfswitch -U

In my version.tf, I have:

terraform {
  required_version = "~> 1.0"

  required_providers {
    aws        = ">= 2.52.0"
    kubernetes = ">= 1.11.1"
  }
}

When I run tfswitch in that directory, I get:

➜  test_versiontf git:(version_url_tweaks) ✗ tfswitch
Reading required version from terraform file
Reading required version from constraint: ~> 1.0
Matched version: 1.1.9
Switched terraform to version "1.1.9"

➜  test_versiontf git:(version_url_tweaks) ✗ terraform -v
Terraform v1.1.9
on darwin_amd64

Which is >= 1.0.0, < 2.0.0

I am using tfswitch Version: 0.13.1221. Can you install the latest tfswitch and try again?

@skyzyx
Copy link
Author

skyzyx commented May 11, 2022

OK. It has been an issue. Let me test this and try again.

@skyzyx
Copy link
Author

skyzyx commented May 20, 2022

Tested and working. Sorry for the late response. Resolving. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Refactor existing code for better performance and quality
Projects
None yet
Development

No branches or pull requests

3 participants