-
Notifications
You must be signed in to change notification settings - Fork 89
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
Conversation
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.
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, 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") |
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.
Question: Was this deletion intentional? Looks functional.
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.
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.
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.
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"), |
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.
Question: Is this an error that has been updated with SDKv2?
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.
Yep, that's correct. The SDKv2 now throws a different error.
if err := readCustomDomainVerification(d, m); err != nil { | ||
return resource.NonRetryableError(err) | ||
} | ||
|
||
return 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.
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.
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.
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.
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.
Ah ok understood, thanks for the explanation 👍
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?
Does the description provide the correct amount of context?
Have you updated the documentation?
Is this code ready for production?