Skip to content
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

Add tests around how plugin framework provider configuration code handles user_project_override values, fix potential bug #15776

Conversation

modular-magician
Copy link
Collaborator

In this PR:

  • Add test cases to match existing user_project_override SDK tests
  • Ensure tests present about handling empty strings (will not be passing, link to related issue added in the code)
  • Ensure tests present about handling Unknown values (will not be passing, link to related issue added in the code)

Defect found:

During this PR I found that the FrameworkProviderConfig struct used when configuring the plugin framework version of the provider has a UserProjectOverride field but the value is never set. Also, it uses a regular Go boolean data type, instead of the new data type that improves handling of Null and Unknown values.

The SDK version of that config struct has an equivalent UserProjectOverride field and its value is set to the user-supplied value here

Fix:

In GoogleCloudPlatform/magic-modules@dbe4952 I changed the struct to use types.Bool, made that field have the value set, and I updated the one location where the (FrameworkProviderConfig).UserProjectOverride value is accessed.

This may have an impact on users, but it's by fixing a bug not by introducing a breaking change. It may be that this defect only would impact users when provisioning resources that are defined using the plugin framework, and currently there are only data sources defined in this way. So the defect may not have had a chance to cause any negative effects yet.

I've included a release note describing this.


Release Note Template for Downstream PRs (will be copied)

provider: fixed a bug where `user_project_override` would not be not used correctly when provisioning resources implemented using the plugin framework. Currently there are no resources implemented this way, so no-one should have been impacted.

Derived from GoogleCloudPlatform/magic-modules#8862

…dles `user_project_override` values, fix potential bug (hashicorp#8862)

* Add initial version of plugin framework provider config test affected by inaccessible functions

* Refactor provider config tests to use plugin-framework types

* Add test case about handling of Unknown values for `project`

* Update tests to check values in BOTH the data model and provider config struct after `LoadAndValidateFramework` runs

* Add some tests for `credentials` in plugin framework provider, including test case that fails

* Update `LoadAndValidateFramework` to take a pointer to the provider data model, so mutations to the data within the function change the original struct

This enables tests to track how the data is mutated

* Add remaining `credentials` test cases to check PF/SDK config parity

* Make tests unset ADC ENV automatically, update comments to tests setting ADC ENV

* Add test for behaviour when credentials value is unknown

* Add comment referring devs to where unknown value test is implemented

* Remove duplicated test case

* Fix filename so it's generated correctly

* Remove fmt line

* Update `project` tests that are affected by `LoadAndValidateFramework` now taking a pointer as an argument

* Update `FrameworkProviderConfig` to use plugin framework types package for `UserProjectOverride` boolean

* Add plugin framework version of tests for user_project_override, update test case names in SDK version of tests

* Add `user_project_override` test case for handling of unknown value

Signed-off-by: Modular Magician <magic-modules@google.com>
@modular-magician modular-magician merged commit 0af4c82 into hashicorp:main Sep 8, 2023
4 checks passed
@github-actions
Copy link

github-actions bot commented Oct 9, 2023

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 issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant