Skip to content

Conversation

@nywilken
Copy link
Contributor

@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
Contributor

@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 a team and sylviamoss June 13, 2023 21:32
Copy link

@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. 🎉

@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 force-pushed the nywilken/go-cty-for-packer branch from 241f40c to 83e4627 Compare June 14, 2023 18:24
@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
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.

3 participants