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

SemVer issue with Terraform on v1 releases #200

Closed
stevehipwell opened this issue Oct 15, 2021 · 12 comments
Closed

SemVer issue with Terraform on v1 releases #200

stevehipwell opened this issue Oct 15, 2021 · 12 comments
Assignees
Labels
bug Something isn't working

Comments

@stevehipwell
Copy link

I ran the following command and got an error despite it being semantically the same as the documented tfswitch --latest-stable 0.13 command.

$ tfswitch --latest-stable 1
$ Invalid minor terraform version format. Format should be #.# where # are numbers. For example, 0.11 is valid version

I suspect this is because this tool was only designed to work with pre v1 versions of Terraform. Semantically in v0.11 there is no explicit minor version as the major version is 11.

@yermulnik
Copy link
Collaborator

yermulnik commented Oct 15, 2021

Semantically in v0.11 there is no explicit minor version as the major version is 11.

Cite from https://learn.hashicorp.com/tutorials/terraform/versions:

HashiCorp uses the format `major.minor.patch` for Terraform versions.

So semantically in v0.11 there is explicitly 0 for major and 11 for minor version.
IMHO.

@stevehipwell
Copy link
Author

@yermulnik sure you can also use major.minor.patch instead of 0.major.minor but the semantic meaning changes when the version is in the 0.x.y form; minor being a breaking change, as seen in pretty much all Terraform "minor" version releases. The actual SemVer spec for versions in the form 0.x.y says any change is breaking but Hashicorp uses the general use Go pre v1 pattern of 0.major.minor (the official Go docs actually agree with SemVer).

@stevehipwell
Copy link
Author

@yermulnik the actual point of this issue is that prior to Terraform v1 this tool would let you get the latest non-breaking changes to a release line, but since v1 you can only get the latest patches.

@yermulnik
Copy link
Collaborator

yermulnik commented Oct 15, 2021

The referred item 4 from semver 2.0.0 doesn't shift major.minor.patch to 0.major.minor. It only states that major version of 0 may introduce incompatible changes at any time and it should not be considered stable.
So what I mean is that tfswitch follows semver as is and I see no issue with its --latest-stable parameter whereas you seem to me to request a "feature" which contradicts with what semver is for.

@yermulnik
Copy link
Collaborator

I might be wrong though and I'd leave this to be considered by tfswitch maintainer(s).

@stevehipwell
Copy link
Author

@yermulnik you've misread the SemVer spec. In SemVer a major version change is always considered breaking, but item 4 says that if the major version is 0 any version change is a breaking change. Due to the way Go handles major version changes there is a convention in the Go community to use 0.x.y versions where the x or minor version is used to signify breaking changes, while y or patch is a non-breaking change. Hashicorp themselves have used this pattern for years and the implementation of --latest-stable only makes sense with this context; as otherwise pre v1 Terraform has no stability so every version would need to be explicitly declared.

To clarify, for Terraform version 1.0.0 is equivalent 0.11.0, 1.1.0 is equivalent to 0.11.1, but 1.0.1 has no equivalent in the 0.11.0 line; that is the cost of using a v0 version in Go.

For final reference take a look at the Terraform v1 Compatibility Promises.

@yermulnik
Copy link
Collaborator

you've misread the SemVer spec.

I did not.
What I meant was that you're substituting notions e.g. by referring to Go community convention (which is not what forms the semver, right?) and mixing up things by saying 0.major.minor is something semver provides. And this was the only thing I meant (please see my first message in this thread — it was in relation to semver only and was nothing to do with your request in particular).

From what I personally (as a user of tfswitch) see, your request is indeed worthwhile and the named tfswitch option should better be re-worked to consider TF major versions of 0 and >0 differently.

Cheers 😉

@warrensbox
Copy link
Owner

@stevehipwell

At this time, tfswitch --latest-stable 0.11 downloads the latest stable version for V0.11.
tfswitch --latest-stable 1.0 should download the latest stable version for V1.0.

Just to clarify are you saying that tfswitch --latest-stable 1 should download the latest stable version for V1.0 ?

@warrensbox
Copy link
Owner

@yermulnik @stevehipwell I was looking at the docs.
--latest-stable 1 should mimic ~> 1.

terraform {
  required_version = "~> 1"

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

The code above downloads 1.14 (latest at this time).
I need to make changes to the code to allow tfswitch --latest-stable 1 to download 1.14 (latest at this time).

@yermulnik
Copy link
Collaborator

@warrensbox Just for the sake of clarity: latest is 1.1.4

@warrensbox
Copy link
Owner

@warrensbox Just for the sake of clarity: latest is 1.1.4

Yes. that's what I meant. That's a typo.

@warrensbox warrensbox self-assigned this Mar 11, 2022
@warrensbox warrensbox added the bug Something isn't working label Mar 11, 2022
@warrensbox
Copy link
Owner

#216 fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants