-
Notifications
You must be signed in to change notification settings - Fork 231
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
helper/schema: Ensure (ResourceData).GetRawConfig() is populated in provider Configure functions #1271
Conversation
…rovider Configure functions Reference: #1270 This change is intended to be as targeted as possible to prevent other unintended changes. In other RPCs, the protocol configuration data is able to be set upfront via `terraform.InstanceState`, however for provider configuration it is still using the legacy `terraform.ResourceConfig` value which previously did not have the same data field. This adds the data field while trying to be pragmatic about potentially breaking compatibility with the unfortunately exported APIs in this SDK. New test failures prior to updating logic: ``` --- FAIL: TestProviderConfigure (0.00s) --- FAIL: TestProviderConfigure/ConfigureContextFunc-GetRawConfig (0.00s) /Users/bflad/src/github.com/hashicorp/terraform-plugin-sdk/helper/schema/provider_test.go:338: Unexpected diagnostics (-wanted +got): diag.Diagnostics( - nil, + {{Summary: "unexpected GetRawConfig difference: expected: {{{{} map[test:{{{"...}}, ) --- FAIL: TestProviderConfigure/ConfigureFunc-GetRawConfig (0.00s) /Users/bflad/src/github.com/hashicorp/terraform-plugin-sdk/helper/schema/provider_test.go:338: Unexpected diagnostics (-wanted +got): diag.Diagnostics( - nil, + {{Summary: "unexpected GetRawConfig difference: expected: {{{{} map[test:{{{"...}}, ) --- FAIL: TestGRPCProviderServerConfigureProvider (0.00s) --- FAIL: TestGRPCProviderServerConfigureProvider/ConfigureContextFunc-GetRawConfig (0.00s) /Users/bflad/src/github.com/hashicorp/terraform-plugin-sdk/helper/schema/grpc_provider_test.go:343: unexpected difference: &tfprotov5.ConfigureProviderResponse{ - Diagnostics: []*tfprotov5.Diagnostic{ - &{ - Severity: s"ERROR", - Summary: "unexpected difference: expected: {{{{} map[test:{{{} %!s(cty.pri"..., - }, - }, + Diagnostics: nil, } --- FAIL: TestGRPCProviderServerConfigureProvider/ConfigureFunc-GetRawConfig (0.00s) /Users/bflad/src/github.com/hashicorp/terraform-plugin-sdk/helper/schema/grpc_provider_test.go:343: unexpected difference: &tfprotov5.ConfigureProviderResponse{ - Diagnostics: []*tfprotov5.Diagnostic{ - &{ - Severity: s"ERROR", - Summary: "unexpected difference: expected: {{{{} map[test:{{{} %!s(cty.pri"..., - }, - }, + Diagnostics: nil, } ```
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, one general question, the linked issue also mentions GetRawPlan
and GetRawState
, are we going to eventually populate those as well?
This change also fixes `GetOkExists()` handling for provider configuration. Updated tests prior to logic updates: ``` --- FAIL: TestProviderConfigure (0.00s) --- FAIL: TestProviderConfigure/ConfigureContextFunc-GetOkExists-zero-value (0.00s) /Users/bflad/src/github.com/hashicorp/terraform-plugin-sdk/helper/schema/provider_test.go:924: Unexpected diagnostics (-wanted +got): diag.Diagnostics( - nil, + {{Summary: "unexpected GetOkExists difference: expected: false, got: true"}}, ) --- FAIL: TestProviderConfigure/ConfigureFunc-GetOkExists-zero-value (0.00s) /Users/bflad/src/github.com/hashicorp/terraform-plugin-sdk/helper/schema/provider_test.go:924: Unexpected diagnostics (-wanted +got): diag.Diagnostics( - nil, + {{Summary: "unexpected GetOkExists difference: expected: false, got: true"}}, ) ```
Provider configuration only contains configuration data. It does not participate in the plan (similar to data sources) nor does Terraform preserve a prior state. |
This verifies it is safe to always set the `ResourceConfig` regardless of the presence of `InstanceDiff`, ensuring that `GetOkExists()` should work in both cases without affecting existing behavior.
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions. |
Closes #1270
This change is intended to be as targeted as possible to prevent other unintended changes. In other RPCs, the protocol configuration data is able to be set upfront via
terraform.InstanceState
, however for provider configuration it is still using the legacyterraform.ResourceConfig
value which previously did not have the same data field. This adds the data field while trying to be pragmatic about potentially breaking compatibility with the unfortunately exported APIs in this SDK.This change also tangentially fixes
GetOkExists
to now return atrue
second result when a configurationNew test failures prior to updating logic:
In terms of prior (errant)
GetOkExists()
behavior, this causes this behavior change/fix: