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

Cannot get latest version: module contains a go.mod file, so module path should be github.com/terraform-providers/terraform-provider-google/v3 #6306

Closed
KateGo520 opened this issue May 6, 2020 · 4 comments
Assignees

Comments

@KateGo520
Copy link

Background

The github.com/terraform-providers/terraform-provider-google uses Go modules and the current release stream version is v3. It must comply with the specification of "Releasing Modules for v2 or higher" available in the Modules documentation and enforced since the most recent versions of Go. Quoting the specification:

A package that has opted in to modules must include the major version in the import path to import any v2+ modules
To preserve import compatibility, the go command requires that modules with major version v2 or later use a module path with that major version as the final element. For example, version v2.0.0 of example.com/m must instead use module path example.com/m/v2.
https://github.com/golang/go/wiki/Modules#releasing-modules-v2-or-higher

Using go get (under go1.13 and go1.14) does not work for anything later than github.com/terraform-providers/[email protected], which was the last version to not have modules.
I consider this a pretty high severity issue since not doing so prevents any other Go project also using Go Modules to properly require terraform-providers/terraform-provider-google on versions higher than v1.20.0 as a dependency, resulting in errors like:

invalid version: module contains a go.mod file, so major version must be compatible: should be v0 or v1, not v3

SO anyone using Go modules will not be able to easily use any newer version of terraform-providers/terraform-provider-google

Steps to Reproduce

  1. Under a project making use of Go modules, run go get targeting any version >= v2.0.0 of the terraform-providers/terraform-provider-google:
$ go get github.com/terraform-providers/[email protected]
go: finding github.com/terraform-providers/terraform-provider-google v3.20.0
go: finding github.com/terraform-providers/terraform-provider-google v3.20.0
go get github.com/terraform-providers/[email protected]: github.com/terraform-providers/[email protected]: invalid version: module contains a go.mod file, so major version must be compatible: should be v0 or v1, not v3

Solution

Kill the go.mod files.

This would push them back to not being managed by Go modules (instead of incorrectly using Go modules). Importing specific versions would work, but they'd receive the +incompatible prefix and would need to be manually upgraded.

Probably best option short-term -- better to not use Go modules than use it incorrectly.

Also, best option for older branches/versions that aren't maintained.

Make breaking changes

Patch the go.mod file to declare the module as github.com/terraform-providers/terraform-provider-google/v3 as per the specs. AND adjust all internal imports.

This would probably only be acceptable on the v3 line, since it'd break any consumers.
Two methods can be use:

  • a new branch in the same repo
  • use the folders structure on mainline branch (see Major Subdirectory structure on the Modules page).

Then development would take place in the new branch/repository, with the existing only updated with tags and/or with new things to forward.

Major version bump / repository change

Leave v3 as a dead version and bump to v4 with the path changes.

References

@KateGo520
Copy link
Author

@modular-magician @chrisst

@chrisst
Copy link
Contributor

chrisst commented May 6, 2020

cc @megan07 who has been working on go modules as part of #5789

@megan07
Copy link
Contributor

megan07 commented May 14, 2020

Hi @KateGo520, thank you for opening this issue. We don't follow this convention because we don't support importing providers as Go Modules. I will refer you here which will explain the supported ways to interface with and depend on Terraform's providers.
Thanks!

@megan07 megan07 closed this as completed May 14, 2020
@ghost
Copy link

ghost commented Jun 14, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Jun 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants