-
Notifications
You must be signed in to change notification settings - Fork 44
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
[dynamic] send an empty config on destroy calls #2815
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.
LGTM.
Would be great if we can turn the test into an integration test with pulumiTest
but I do not know if we have logs for that.
// TestConfigInDestroy asserts that a nil config is passed to SDKv2 providers on destroy. | ||
// | ||
// This acts as a regression test for https://github.com/pulumi/pulumi-terraform-provider/issues/55. | ||
func TestConfigInDestroy(t *testing.T) { |
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.
Can we turn this into an integration test using pulumiTest?
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.
It's probably possible to turn this into an integration test with our existing logs, but it would require a lot of messaging of log data. I took a crack at it, and it's a pretty painful process.
I don't think this will get us to a more flexible test here, since we are still log dependent.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2815 +/- ##
==========================================
+ Coverage 68.63% 68.65% +0.02%
==========================================
Files 325 325
Lines 41536 41537 +1
==========================================
+ Hits 28507 28516 +9
+ Misses 11423 11418 -5
+ Partials 1606 1603 -3 ☔ View full report in Codecov by Sentry. |
Similar to pulumi/pulumi-terraform-provider#36, older versions of terraform-plugin-sdk/v2 require an empty (non-nil) `config` field to avoid crashing. ```go configVal, err := msgpack.Unmarshal(req.Config.MsgPack, schemaBlock.ImpliedType()) if err != nil { resp.Diagnostics = convert.AppendProtoDiag(ctx, resp.Diagnostics, err) return resp, nil } ``` ([src](https://github.com/pulumi/terraform-plugin-sdk/blob/1798ae4ae71f7ffff29312a07c92d41205aff03b/helper/schema/grpc_provider.go#L926-L930)) Newer versions of SDKv2 add a [guard](https://github.com/pulumi/terraform-plugin-sdk/blob/da29621efae69dd03dfdc540aa5f63beab1b764c/helper/schema/grpc_provider.go#L810-L822) before this line is reached. Fixes #55
1e779b3
to
1ef41e9
Compare
This was motivated while trying to add a test for #2815. Beyond adding comments, the major change is how the failure for differences in nested fields looks. It used to look like this: ```console go test -test.run \^TestConfigInDestroy\$ panic: fatal: An assertion has failed: field config does not match logged field \ &{{} [] [] 0x14000410008} != &{{} [] [] 0x14000410008} ``` Observe that both sides of the `!=` are identical. It now looks like this: ```console $ go test -test.run \^TestConfigInDestroy\$ panic: fatal: An assertion has failed: field "terraformv6_pulumi config msgpack" does not match logged field \ [134 83 71 ...] != [134 82 69 ...] ``` The path to the nested field is specified (`"terraformv6_pulumi config msgpack"`) and we see a difference in the value displayed.
This PR has been shipped in release v3.100.0. |
Similar to pulumi/pulumi-terraform-provider#36, older versions of terraform-plugin-sdk/v2 require an empty (non-nil)
req.Config
field to avoid crashing.(src)
Newer versions of SDKv2 add a guard before this line is reached.
Fixes pulumi/pulumi-terraform-provider#55