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

refactor: removed resource wrapper #1440

Closed
wants to merge 1 commit into from

Conversation

tenthirtyam
Copy link
Collaborator

Summary of Pull Request

Refactored to use the context aware functions instead of the deprecated schema.ReadFunc. schema.CreateFunc, schema.UpdateFunc. and schema.DeleteFunc functions.

Refactored to remove redundancy by creating a generic wrapper function that handles the common logic for all actions (read, create, update, delete).

  • Added a constant for the NSX version where the resource was removed rather than repeating it.

Type of Pull Request

  • This is a bug fix.
  • This is an enhancement or feature.
  • This is a code style/formatting update.
  • This is a documentation update.
  • This is a refactoring update.
  • This is a chore update
  • This is something else.
    Please describe:

Related to Existing Issues

Test and Documentation Coverage

For bug fixes or features:

  • Tests have been completed.
  • Documentation has been added/updated.

Breaking Changes?

  • Yes, there are breaking changes.
  • No, there are no breaking changes.

Refactored to use the context aware functions instead of the deprecated `schema.ReadFunc`. `schema.CreateFunc`, `schema.UpdateFunc`. and `schema.DeleteFunc` functions.

Refactored to remove redundancy by creating a generic wrapper function that handles the common logic for all actions (read, create, update, delete).

- Added a constant for the NSX version where the resource was removed rather than repeating it.

Signed-off-by: Ryan Johnson <ryan.johnson@broadcom.com>
@tenthirtyam tenthirtyam added provider Provider refactor Refactor needs-review Needs Review labels Oct 17, 2024
@tenthirtyam tenthirtyam self-assigned this Oct 17, 2024
return originalFunc(d, m)

switch f := originalFunc.(type) {
case schema.ReadContextFunc:
Copy link
Member

Choose a reason for hiding this comment

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

@tenthirtyam the functions in provider resources do not implement the xxxContext functions. We are aware Read, Write, Update, and Deleted are deprecated in favor of xxxContext functions, but don't we have to change resources to implement these function to make the code work in this way?

if commonVersionCheck(m) {
return originalFunc(d, m)

switch f := originalFunc.(type) {
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for this. I could not get this cast to work properly, and this is why I did not implement a generic wrapper in the first place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-review Needs Review provider Provider refactor Refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants