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

[2/3] [DXCDT-54] Upgrade terraform-plugin-sdk to v2 #122

Merged
merged 14 commits into from
Apr 5, 2022

Conversation

sergiught
Copy link
Contributor

@sergiught sergiught commented Apr 4, 2022

Description

In this PR we are upgrading the terraform-plugin-sdk to v2 following the guide at https://www.terraform.io/plugin/sdkv2/guides/v2-upgrade-guide.

Summary of changes:

It is recommended to review commit by commit as I'm unable to reduce the size of this PR, otherwise the binary won't compile until all issues are resolved.

Checklist

Note: Checklist required to be completed before a PR is considered to be reviewable.

Auth0 Code of Conduct

Auth0 General Contribution Guidelines

Changes include test coverage?

  • Yes
  • Not needed

Does the description provide the correct amount of context?

  • Yes, the description provides enough context for the reviewer to understand what these changes accomplish

Have you updated the documentation?

  • Yes, I've updated the appropriate docs
  • Not needed

Is this code ready for production?

  • Yes, all code changes are intentional and no debugging calls are left over

@sergiught sergiught self-assigned this Apr 4, 2022
@sergiught sergiught marked this pull request as ready for review April 4, 2022 12:40
@sergiught sergiught requested a review from a team as a code owner April 4, 2022 12:40
Base automatically changed from patch/DXCDT-102-pre-sdk-v2 to main April 5, 2022 06:06
Copy link
Contributor

@willvedd willvedd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm, happy this is finally coming together!

@@ -902,7 +902,6 @@ func rotateClientSecret(d *schema.ResourceData, m interface{}) error {
return err
}
}
d.SetPartial("client_secret_rotation_trigger")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Was this deletion intentional? Looks functional.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, this is intentional. The SetPartial func has been removed.

Hashicorp description of the reasons:

Removal of helper/schema.ResourceData.SetPartial
The helper/schema.ResourceData.SetPartial method was deprecated and has been removed. This method used to allow setting certain fields in state when helper/schema.ResourceData.Partial was set to true, but developers weren't clear under which circumstances that needed to happen.

This method should never need to be used. helper/schema.ResourceData.Partial should be set to true before returning an error if the error should prevent any state from being part of the config being automatically persisted in state. For most providers, this doesn't matter, as the refresh step will take care of setting the state to what it should be.

See issue #476 for more information.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks for the explanation 👍

"auth0": Provider(),
},
Steps: []resource.TestStep{
{
Config: random.Template(testAccClientConfigMobileUpdateError, rand),
ExpectError: regexp.MustCompile("config is invalid"),
ExpectError: regexp.MustCompile("Missing required argument"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Is this an error that has been updated with SDKv2?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that's correct. The SDKv2 now throws a different error.

Comment on lines +53 to +57
if err := readCustomDomainVerification(d, m); err != nil {
return resource.NonRetryableError(err)
}

return nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit (non-blocking): The best I can tell, resource.NonRetryableError will return nil in the restul of a nil error passed in. So I don't believe this additional conditional does anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually needed because of a behavior change in retryableError wrapper. From the docs:

Clearer Handling of nil for helper/resource.NonRetryableError and helper/resource.RetryableError
Previously, passing a nil error to helper/resource.RetryableError and helper/resource.NonRetryableError could lead to subtle bugs and even crashes. It will now return an error. Providers should check that the error is not nil before calling helper/resource.NonRetryableError or helper/resource.RetryableError.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok understood, thanks for the explanation 👍

@sergiught sergiught merged commit dd098e4 into main Apr 5, 2022
@sergiught sergiught deleted the feature/DXCDT-54-sdk-v2 branch April 5, 2022 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants