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

Replace usage of deprecated fields in schema.Resource #231

Merged
merged 23 commits into from
Apr 14, 2022

Conversation

bendbennett
Copy link
Contributor

Closes #230.

@github-actions github-actions bot added size/M and removed size/S labels Apr 12, 2022
@github-actions github-actions bot added size/L and removed size/M labels Apr 12, 2022
@bendbennett bendbennett marked this pull request as ready for review April 12, 2022 12:59
@bendbennett bendbennett requested a review from a team as a code owner April 12, 2022 12:59
Copy link
Contributor

@detro detro left a comment

Choose a reason for hiding this comment

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

A suggestion, but otherwise it looks good.

Delete: schema.RemoveFromState,
CreateContext: CreateInteger,
ReadContext: schema.NoopContext,
DeleteContext: DeleteInteger,
Copy link
Contributor

Choose a reason for hiding this comment

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

It's annoying that there is no schema.RemoveFromStateContext

Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to implement the DeleteContextFunc once in a shared file and then have each resource use that instead to have to implement the dedicated DeleteX methods?

Not super important, but I thought I'd suggest.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@detro your suggestion makes sense to me. Have created a shared DeleteContext func and added it to provider.go.

Delete: schema.RemoveFromState,
CreateContext: CreatePet,
ReadContext: schema.NoopContext,
DeleteContext: DeletePet,
Copy link
Contributor

Choose a reason for hiding this comment

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

as per above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done (see above).

@github-actions github-actions bot removed the size/L label Apr 13, 2022
@bendbennett bendbennett requested review from detro and a team April 13, 2022 10:07
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func DeleteContext(_ context.Context, d *schema.ResourceData, _ interface{}) diag.Diagnostics {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: would it make sense to use a name for this that doesn't clash with the field it's used in?

Reading below:

{
  // ...
  DeleteContext: DeleteContext,
  // ...
}

it's a bit ... odd.

Admittedly, coming up with a name can be hard (as usually, naming things always is).
How about removeResourceFromState(), since that's what d.SetId("") is for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair enough. Done.

@bendbennett bendbennett requested review from detro and a team April 13, 2022 15:39
@bendbennett bendbennett merged commit e924ad8 into main Apr 14, 2022
@bendbennett bendbennett deleted the bendbennett/issues-230 branch April 14, 2022 11:34
Copy link

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 contributions.
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 May 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace usage of deprecated fields in schema.Resource
2 participants