Skip to content

refactor: migrate resource_github_issue_label to context-aware CRUD a… - #3342

Merged
stevehipwell merged 3 commits into
integrations:mainfrom
slymanmrcan:refactor/migrate-resource-github-issue-label-to-tflog-and-context
Jun 25, 2026
Merged

stevehipwell merged 3 commits into
integrations:mainfrom
slymanmrcan:refactor/migrate-resource-github-issue-label-to-tflog-and-context

Conversation

@slymanmrcan

@slymanmrcan slymanmrcan commented Apr 17, 2026 •

Copy link
Copy Markdown
Contributor

Addresses parts of #3070
Addresses parts of #2996


Before the change?

  • resource_github_issue_label uses legacy Create/Read/Update/Delete
    schema functions and log.Printf for logging.

After the change?

  • Migrated to CreateContext/ReadContext/UpdateContext/DeleteContext
  • Function signatures updated to (ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics
  • Replaced log.Printf with tflog.Info for structured logging
  • Removed manual context.Background() calls
  • Wrapped error returns with diag.FromErr()

Pull request checklist

  • Schema migrations have been created if needed — N/A, no schema change
  • Tests for the changes have been added — N/A, no behavior change
  • Docs have been reviewed and added / updated if needed — N/A

Does this introduce a breaking change?

  • No

@github-actions

Copy link
Copy Markdown

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

@deiga

deiga commented Apr 18, 2026

Copy link
Copy Markdown
Collaborator

Please remove the resolves comment, since it adresses the issue only partly. And "resolves" will close the issue

deiga
deiga previously approved these changes Apr 18, 2026

@deiga deiga left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM!

Thanks for the contribution!

@deiga deiga added this to the v6.13.0 Release milestone Apr 18, 2026
@deiga deiga added the Type: Maintenance Any dependency, housekeeping, and clean up Issue or PR label Apr 18, 2026
@slymanmrcan

Copy link
Copy Markdown
Contributor Author

I just removed it from the description

@deiga

deiga commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

Would you be available to rebase this (possibly multiple times) during the next week? We're going to release 6.13.0 and will try to land some of these open PRs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors resource_github_issue_label to use Terraform Plugin SDK v2 context-aware CRUD function signatures and structured logging via tflog, aligning the resource with ongoing provider-wide migrations tracked in #2996 and #3070.

Changes:

  • Migrated the resource from legacy Create/Read/Update/Delete to CreateContext/ReadContext/UpdateContext/DeleteContext.
  • Updated CRUD implementations to return diag.Diagnostics and wrap errors with diag.FromErr.
  • Replaced log.Printf usage with tflog.Info structured logging and removed context.Background() usage.

Comment thread github/resource_github_issue_label.go Outdated
Comment thread github/resource_github_issue_label.go Outdated
@slymanmrcan

Copy link
Copy Markdown
Contributor Author

Yes, I can rebase it during the next week as needed.

I’ll rebase now and address the Copilot review comments as well.

@slymanmrcan
slymanmrcan force-pushed the refactor/migrate-resource-github-issue-label-to-tflog-and-context branch from 241dc85 to 40c2608 Compare June 5, 2026 04:45
deiga
deiga previously approved these changes Jun 5, 2026

@deiga deiga left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@stevehipwell even though there are other parts here that could be refactored, I would suggest we do the minimum here to get this merged.

@deiga
deiga requested a review from stevehipwell June 5, 2026 17:31

@stevehipwell stevehipwell left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

For me the bare minimum here would be to separate create & update and remove the call to read from them.

@slymanmrcan
slymanmrcan force-pushed the refactor/migrate-resource-github-issue-label-to-tflog-and-context branch from ba9fec5 to 9c162ad Compare June 11, 2026 10:55
@slymanmrcan

Copy link
Copy Markdown
Contributor Author

Thanks, I separated the create and update handlers and removed the explicit read call from both paths while keeping the existing idempotent create behavior for default GitHub labels.

Comment thread github/resource_github_issue_label.go Outdated
Comment thread github/resource_github_issue_label.go Outdated
Comment thread github/resource_github_issue_label.go Outdated
Comment thread github/resource_github_issue_label.go Outdated
Comment thread github/resource_github_issue_label.go Outdated
Comment thread github/resource_github_issue_label.go Outdated
@slymanmrcan
slymanmrcan force-pushed the refactor/migrate-resource-github-issue-label-to-tflog-and-context branch from 9c162ad to ad3d0c9 Compare June 11, 2026 12:16
Comment thread github/resource_github_issue_label.go
Comment thread github/resource_github_issue_label.go Outdated
Comment thread github/resource_github_issue_label.go Outdated
Comment thread github/resource_github_issue_label.go Outdated
Comment thread github/resource_github_issue_label.go Outdated
Comment thread github/resource_github_issue_label.go Outdated
Comment thread github/resource_github_issue_label.go
Comment thread github/resource_github_issue_label.go Outdated
@slymanmrcan
slymanmrcan force-pushed the refactor/migrate-resource-github-issue-label-to-tflog-and-context branch from ad3d0c9 to 43498d3 Compare June 13, 2026 13:43

@stevehipwell stevehipwell left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@slymanmrcan this is looking good. There are still a couple of outstanding comments to address and it looks like you haven't run the strict linting for new code?

@slymanmrcan
slymanmrcan force-pushed the refactor/migrate-resource-github-issue-label-to-tflog-and-context branch 4 times, most recently from 88958c6 to 3fef38e Compare June 15, 2026 23:47
@slymanmrcan

Copy link
Copy Markdown
Contributor Author

Thanks, my mistake. I missed the strict new-code lint locally.
I’ve run it now and addressed the findings in the latest push.

@slymanmrcan
slymanmrcan force-pushed the refactor/migrate-resource-github-issue-label-to-tflog-and-context branch from c20bfef to 9da13ec Compare June 19, 2026 10:28
@slymanmrcan

Copy link
Copy Markdown
Contributor Author

Thanks for the review! I’ve pushed the fixes now: color/description are set from Read again, and Create preserves the previous GetLabel-then-EditLabel behavior for existing labels.

Comment thread github/resource_github_issue_label.go Outdated
Comment thread github/resource_github_issue_label.go Outdated
@deiga

deiga commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

@slymanmrcan could you please rebase the branch?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread github/resource_github_issue_label.go Outdated
@slymanmrcan
slymanmrcan force-pushed the refactor/migrate-resource-github-issue-label-to-tflog-and-context branch from bce3ab2 to 29f6931 Compare June 24, 2026 10:08

@stevehipwell stevehipwell left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

As per my previous comment, this resource should fail on create if the label already exists. You can either import or use github_isue_labels to handle the existing label scenario.

Comment thread github/resource_github_issue_label.go Outdated
@slymanmrcan
slymanmrcan force-pushed the refactor/migrate-resource-github-issue-label-to-tflog-and-context branch from e4ff06a to 27f907c Compare June 24, 2026 10:54
@slymanmrcan

Copy link
Copy Markdown
Contributor Author

thanks for review
@stevehipwell @deiga

  • removed GetLabel/EditLabel adopt logic from create, now fails if label already exists
  • fixed description to use d.Get instead of d.GetOk to allow clearing it

Comment thread github/resource_github_issue_label.go Outdated
Comment thread github/resource_github_issue_label.go Outdated
Comment thread github/resource_github_issue_label.go Outdated
@slymanmrcan
slymanmrcan force-pushed the refactor/migrate-resource-github-issue-label-to-tflog-and-context branch from 27f907c to e637931 Compare June 24, 2026 12:01
@stevehipwell

Copy link
Copy Markdown
Collaborator

@slymanmrcan could you please fix the lint failures?

@slymanmrcan
slymanmrcan force-pushed the refactor/migrate-resource-github-issue-label-to-tflog-and-context branch from e637931 to b82248d Compare June 24, 2026 13:05
@slymanmrcan

Copy link
Copy Markdown
Contributor Author

Thanks, fixing it now.

@stevehipwell

Copy link
Copy Markdown
Collaborator

@slymanmrcan you appear to have been caught out by a regression.

@deiga any thoughts?

@deiga
deiga requested a review from robert-crandall June 25, 2026 10:07

@stevehipwell stevehipwell left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@robert-crandall robert-crandall left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for this! The migration to context-aware CRUD with diag and tflog is clean and consistent, and I really appreciate how quickly you turned around the feedback. The color/description read-back restores drift detection, and setting the description unconditionally so it can be cleared is exactly right. Nice, well-scoped change. 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Maintenance Any dependency, housekeeping, and clean up Issue or PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants