You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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.
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!
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
locked and limited conversation to collaborators
Jun 14, 2020
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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:
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:SO anyone using Go modules will not be able to easily use any newer version of terraform-providers/terraform-provider-google
Steps to Reproduce
go get
targeting any version >= v2.0.0 of the terraform-providers/terraform-provider-google: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 themodule
asgithub.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:
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
The text was updated successfully, but these errors were encountered: