-
Notifications
You must be signed in to change notification settings - Fork 28
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
Add support for format versions 1.0 and above #41
Add support for format versions 1.0 and above #41
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks pretty good to me! Thank you for raising the PR.
I left some relatively minor comments in-line.
The next logical step would be perhaps trying it out in the context of terraform-exec
where you can run the E2E tests against a custom build via
TFEXEC_E2ETEST_VERSIONS=refs/heads/alisdair/json-format-version-1.0 go test ./tfexec/internal/e2etest/...
A future release of Terraform will ship with a 1.0 format version for all stable JSON formats, which will be backwards compatible with the existing format. This will also mark a release where the JSON compatibility guarantee is more clearly defined, and so format versions less than 2.0 should always be backwards compatible with consumers which support 1.0. This commit prepares for that change by adding support for version constraints rather than supported fixed sets of versions. This is done using the go-version package. Includes test data from a pre-release of Terraform 1.1 which includes the planned JSON format version changes.
d93236f
to
5dd30a1
Compare
I tried running $ go mod edit -replace github.com/hashicorp/terraform-json=/Users/alisdair/code/terraform-json
$ TFEXEC_E2ETEST_VERSIONS=refs/heads/alisdair/json-format-version-1.0 go test ./tfexec/internal/e2etest/...
2021/09/14 14:21:29
--- FAIL: TestProvidersSchema (1.63s)
--- FAIL: TestProvidersSchema/0_basic (1.43s)
--- FAIL: TestProvidersSchema/0_basic/basic-refs/heads/alisdair/json-format-version-1.0 (1.43s)
util_test.go:112: [INFO] running Terraform command: /var/folders/2p/ys5rmmyd02b4f74gzxlv5nj00000gp/T/tfinstall607081317/gitref-refs-heads-alisdair-json-format-version-1.0/terraform2149754593 init -no-color -force-copy -input=false -backend=true -get=true -upgrade=false
util_test.go:112: [INFO] running Terraform command: /var/folders/2p/ys5rmmyd02b4f74gzxlv5nj00000gp/T/tfinstall607081317/gitref-refs-heads-alisdair-json-format-version-1.0/terraform2149754593 providers schema -json -no-color
providers_schema_test.go:324: mismatch (-want +got):
&tfjson.ProviderSchemas{
- FormatVersion: "0.2",
+ FormatVersion: "1.0", (and some similar errors). At first glance it seems like updating those assertions accordingly would be a reasonable step once 1.1 is released. |
A future release of Terraform will ship with a 1.0 format version for all stable JSON formats, which will be backwards compatible with the existing format. This will also mark a release where the JSON compatibility guarantee is more clearly defined, and so format versions less than 2.0 should always be backwards compatible with consumers which support 1.0.
This commit prepares for that change by adding support for version constraints rather than supported fixed sets of versions. This is done using the go-version package.
Includes test data from a pre-release of Terraform 1.1 which includes the planned JSON format version changes (this branch).