-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Make plugin-framework provider configuration code treat empty values like the SDK #8798
Conversation
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are. Terraform GA: Diff ( 8 files changed, 195 insertions(+), 148 deletions(-)) |
Tests analyticsTotal tests:
|
69d5653
to
2a7cffa
Compare
This PR currently contains all the unit tests I've managed to get approved and merged to main, unit tests I've got in open PRs, and code changes to make the PF config code behave more like the SDK config code w.r.t empty strings |
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are. Terraform GA: Diff ( 3 files changed, 503 insertions(+), 133 deletions(-)) |
Tests analyticsTotal tests:
|
ea3c199
to
78cee10
Compare
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.
Added some comments to help with review
78cee10
to
53a3cf4
Compare
…re overridden by an ENV
This is because 123s is transformed to 2m3s, but 45s remains 45s
53a3cf4
to
d5f4195
Compare
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are. Terraform GA: Diff ( 3 files changed, 238 insertions(+), 147 deletions(-)) |
Tests analyticsTotal tests: Action takenFound 7 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected testsTestAccBigtableAppProfile_bigtableAppProfileMulticlusterExample|TestAccBigtableAppProfile_bigtableAppProfileAnyclusterExample|TestAccBigtableAppProfile_bigtableAppProfileSingleclusterExample|TestAccGKEHub2Scope_gkehubScopeBasicExample|TestAccGKEHub2ScopeIamBindingGenerated|TestAccGKEHub2ScopeIamMemberGenerated|TestAccGKEHub2ScopeIamPolicyGenerated |
Rerun these tests in REPLAYING mode to catch issues
|
// Make the plugin framwork code behave like the SDK by ignoring zero values. This means re-setting zero values to null. | ||
// This is added to fix https://github.com/hashicorp/terraform-provider-google/issues/14255 in a v4.x.x release | ||
// TODO(SarahFrench) remove as part of https://github.com/hashicorp/terraform-provider-google/issues/14447 in 5.0.0 | ||
p.HandleZeroValues(ctx, data, diags) | ||
if diags.HasError() { | ||
return | ||
} |
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.
For 5.0.0, when we stop ignoring empty strings provided in a user's Terraform configuration, I plan to delete this section and remove the HandleZeroValues
function
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.
We are adding this functionality back for users that could not upgrade since 4.60 right? To give them access to remaining 4.x versions
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.
Yeah that's right. Users affected by hashicorp/terraform-provider-google#14255 could navigate the issue easily by removing empty strings from their provider config block, but that becomes less easy if they have a lot of different provider configs or if an empty string was 'baked into' a module that a user didn't have control over.
By making this change we're allowing any users on old provider versions to upgrade to the final 4.x.x version prior to 5.0.0 with everything behaving as they'd expect. Then they'll have the upgrade guide warning them about empty strings no longer being ignored in 5.0.0.
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.
Straightforward except for the batching bit, but looks correct.
The batching bit was a pain for me to figure out, but it works! I'll do some final manual testing tomorrow and will merge this PR then. Thanks for the approval! 🚀 |
…ntials=""` and `GOOGLE_CREDENTIALS` interact
Instead of manual testing, I've added an acceptance test in 16b27d4 that shows the behaviour (specifically for the bug mentioned in hashicorp/terraform-provider-google#14255) and how it's fixed following this PR. In future I'll update that test with another step when we intentionally reverse this bug fix in 5.0.0 |
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are. Terraform GA: Diff ( 4 files changed, 307 insertions(+), 147 deletions(-)) |
Tests analyticsTotal tests:
|
Following addition of that test and all checks passing, I'll merge this PR once merging to main is resumed |
…like the SDK (GoogleCloudPlatform#8798) * Make PF config code change `project = ""` to null value before checking ENVs * Make plugin framework config code change all empty strings in config to null values * Fix defect in unit test for `project`, uncomment * Uncomment empty string unit tests * Fix defect in test; expeceted value should be null list * Add handling of empty lists in `HandleZeroValues` * Fix typo in comment * Add test case asserting `impersonate_service_account` empty strings are overridden by an ENV * Update SDK `batching` tests: rename test cases, make it clear values are arbitary * Update `HandleZeroValues` to handle `batching` argument * Uncomment empty string test * Change test inputs from 123s to 45s This is because 123s is transformed to 2m3s, but 45s remains 45s * Protect against Batching being null/unknown in `HandleZeroValues` * Add non-VCR acceptance test that shows provider behaviour when `credentials=""` and `GOOGLE_CREDENTIALS` interact
…like the SDK (GoogleCloudPlatform#8798) * Make PF config code change `project = ""` to null value before checking ENVs * Make plugin framework config code change all empty strings in config to null values * Fix defect in unit test for `project`, uncomment * Uncomment empty string unit tests * Fix defect in test; expeceted value should be null list * Add handling of empty lists in `HandleZeroValues` * Fix typo in comment * Add test case asserting `impersonate_service_account` empty strings are overridden by an ENV * Update SDK `batching` tests: rename test cases, make it clear values are arbitary * Update `HandleZeroValues` to handle `batching` argument * Uncomment empty string test * Change test inputs from 123s to 45s This is because 123s is transformed to 2m3s, but 45s remains 45s * Protect against Batching being null/unknown in `HandleZeroValues` * Add non-VCR acceptance test that shows provider behaviour when `credentials=""` and `GOOGLE_CREDENTIALS` interact
This PR fixes hashicorp/terraform-provider-google#14255
This PR makes the plugin-framework code behave more like the SDK by ignoring empty strings, and is a bug fix to be included in a v4.x.x release. The bug it's fixing is an unintentional behaviour change introduced when the provider was muxed.
Later, I will remove this fix in 5.0.0, as an intentional breaking change as part of : hashicorp/terraform-provider-google#14447
Also, this PR changes some arbitrary strings from "123s" to "45s" as I realised that "123s" is changed to "2m3s" during the provider configuration logic. I thought this change would help avoid confusion if tests are updated in future to inspect where that second, parsed value is used.
If this PR is for Terraform, I acknowledge that I have:
make test
andmake lint
in the generated providers to ensure it passes unit and linter tests.Release Note Template for Downstream PRs (will be copied)