-
Notifications
You must be signed in to change notification settings - Fork 230
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
meta.SDKVersion
reporting incorrect version
#1257
Comments
Since this is previously existing functionality that is not working as intended we will target fixing this in an upcoming terraform-plugin-sdk release. It appears an automated update to the file contents was not ported over to the newer release process. It is important to note however that Go module code such as provider code, can fetch this information automatically using Go standard library functionality. The runtime/debug.ReadBuildInfo() function returns the Deps field which contains module paths and version information. This is how Terraform core, for example, is able to log "interesting" dependencies: https://github.com/hashicorp/terraform/blob/07b814c030daae39dea764571bef9cecf26e49be/version/dependencies.go#L8-L46 Given that, we may opt to fix the issue while also deprecating the exported function to suggest using |
Reference: #1257 The release process is also updated to automatically overwrite the version variable as it did in the previous release process. While this should ensure this version information is correct going forward, consumers should instead prefer the Go standard library `runtime/debug` package build information, which is guaranteed to always be correct.
…1260) Reference: #1257 The release process is also updated to automatically overwrite the version variable as it did in the previous release process. While this should ensure this version information is correct going forward, consumers should instead prefer the Go standard library `runtime/debug` package build information, which is guaranteed to always be correct.
thanks for the update @bflad 🙇 using |
I think using The information is pretty easy to grok using that Example using the
|
Also worth noting that using this approach, in the rare case, if you ever need to use a specific commit of Example using cloudflare provider: $ go get -u github.com/hashicorp/terraform-plugin-framework@0fbaf4b17f282c2030858ae2c419b1d043325376
$ go build .
$ go version -m ./terraform-provider-cloudflare
./terraform-provider-cloudflare: go1.21.1
path github.com/cloudflare/terraform-provider-cloudflare
mod github.com/cloudflare/terraform-provider-cloudflare (devel)
# ... other dependencies
dep github.com/hashicorp/terraform-plugin-framework v1.4.2-0.20231011150141-0fbaf4b17f28 h1:gwqWSq4edVnLt79kUcf4O7Kd8c4CE/5wmGrF06h3Nlo=
And the resulting {
Path: "github.com/hashicorp/terraform-plugin-framework",
Version: "v1.4.2-0.20231011150141-0fbaf4b17f28",
Sum: "h1:gwqWSq4edVnLt79kUcf4O7Kd8c4CE/5wmGrF06h3Nlo=",
Replace: nil
} It's unlikely you'd need to ever need to do that, but wanted to highlight it. More documentation on that version field here: https://go.dev/ref/mod#versions |
much appreciate the additional context here @austinvalle. thank you both! |
Before this change, we relied on the plugin libraries to expose their version. Unfortunately, this was incorrectly set in SDKv2[1] and non-existent in the framework[2]. The recommended approach is to instead dig into the build information via`runtime/debug.ReadBuildInfo()`[3] which is what we introduce here in a slightly safer and consistent way. [1]: hashicorp/terraform-plugin-sdk#1257 [2]: hashicorp/terraform-plugin-framework#855 [3]: https://pkg.go.dev/runtime/debug#ReadBuildInfo Signed-off-by: Jacob Bednarz <jacob.bednarz@gmail.com>
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. |
SDK version
Relevant provider source code
terraform-plugin-sdk/meta/meta.go
Line 17 in ec118d6
Terraform Configuration Files
n/a
Example usage
cloudflare/terraform-provider-cloudflare uses this value to append to the UA string.
https://github.com/cloudflare/terraform-provider-cloudflare/blob/658bb74d9a8ee1e258e10936bbe3c6c206ca4fe7/internal/sdkv2provider/provider.go#L380C3-L381
Expected Behavior
meta.SDKVersion
should report v2.29.0Actual Behavior
meta.SDKVersion
reports v2.10.1Steps to Reproduce
References
The text was updated successfully, but these errors were encountered: