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

[HPR-1108] Add compile time check for go-cty #186

Merged
merged 2 commits into from Jun 15, 2023

Conversation

nywilken
Copy link
Member

@nywilken nywilken commented Jun 13, 2023

In v1.11.0, the go-cty package dropped support for encoding/gob. Gob support is used
by the SDK to serialize HCL2 object specs over the wire. If a plugin or Packer upgrades
their version of zclconf/go-cty to one that does not contain Gob support the plugin will build
but crash when trying to run a build on an HCL2 template. By adding this check, a consumer of the SDK
will fail to compile if they are using an unsupported version of go-cty. This check is being added
as a guard to prevent Packer SDK consumers from becoming out of sync with unsupported go-cty versions.

~> go get github.com/hashicorp/go-cty v1.13.0
~> make dev
rpc/cty_encode.go:15:24 cannot use cty.Value{} (value of type cty.Value) as type gob.GobEncoder

TODO

In v1.11.0, the go-cty package dropped support for encoding/gob. Gob support is used
by the SDK to serialize HCL2 object specs over the wire. If a plugin or Packer upgrades
their version of zclconf/go-cty to one that does not contain Gob support the plugin will build
but crash when trying to run a build on an HCL2 template. By adding this check, a consumer of the SDK
will fail to compile if they are using an unsupported version of go-cty. This check is being added
as a guard to prevent Packer SDK consumers from becoming out of sync with unsupported go-cty versions.

```
~> go get github.com/hashicorp/go-cty v1.13.0
~> make dev
rpc/cty_encode.go:15:24 cannot use cty.Value{} (value of type cty.Value) as type gob.GobEncoder
```
@nywilken nywilken requested a review from a team as a code owner June 13, 2023 20:08
Copy link

@JenGoldstrich JenGoldstrich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@nywilken nywilken requested review from sylviamoss and a team June 13, 2023 21:32
Copy link
Member

@sylviamoss sylviamoss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am still amazed by this simple way to prevent plugins to upgrade to an incompatible gocty version. 🎉

rpc/cty_encode.go Outdated Show resolved Hide resolved
@nywilken nywilken modified the milestone: 0.1.0 Jun 14, 2023
@nywilken nywilken added the version/bump minor A PR that changes behavior or contains breaking changes template configuration options. label Jun 14, 2023
@nywilken nywilken added this to the 0.5.0 milestone Jun 14, 2023
* Add link to GitHub Issue
@nywilken nywilken changed the title Add compile time check for go-cty [HPR-1108] Add compile time check for go-cty Jun 14, 2023
@nywilken nywilken merged commit df99313 into main Jun 15, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
version/bump minor A PR that changes behavior or contains breaking changes template configuration options.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants