Skip to content

maint: migrate data sources to tflog structured logging#3346

Open
feyzsari wants to merge 4 commits into
integrations:mainfrom
feyzsari:maint/migrate-tflog-data-sources
Open

maint: migrate data sources to tflog structured logging#3346
feyzsari wants to merge 4 commits into
integrations:mainfrom
feyzsari:maint/migrate-tflog-data-sources

Conversation

@feyzsari

@feyzsari feyzsari commented Apr 17, 2026

Copy link
Copy Markdown

Before the change?

data_source_github_actions_organization_registration_token, data_source_github_actions_registration_token,
and data_source_github_branch used the standard log package with log.Printf("[DEBUG] ..."),
embedding values directly in the message string.

After the change?

Replaced log imports with github.com/hashicorp/terraform-plugin-log/tflog.
Log calls now use tflog.Debug(ctx, "...", map[string]any{...}) with structured fields,
providing proper integration with Terraform's logging system (TF_LOG, TF_LOG_PROVIDER)
and enabling field-based log filtering.

Pull request checklist

  • Schema migrations have been created if needed (example)
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)

Does this introduce a breaking change?

Please see our docs on breaking changes to help!

  • Yes
  • No

Replace standard log.Printf calls with tflog.Debug using structured
fields in the following data sources:
- data_source_github_actions_organization_registration_token
- data_source_github_actions_registration_token
- data_source_github_branch

Part of integrations#2629
@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! 🚀

@github-actions github-actions Bot added the Type: Maintenance Any dependency, housekeeping, and clean up Issue or PR label Apr 17, 2026
deiga
deiga previously approved these changes Apr 17, 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.

Sweet! Thanks!🙏

@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 added this to the v6.13.0 Release milestone Apr 18, 2026
@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 migrates several GitHub data sources from the standard library log.Printf debug logging to Terraform’s structured logging via tflog, improving integration with TF_LOG / TF_LOG_PROVIDER and enabling field-based filtering.

Changes:

  • Replaced log.Printf("[DEBUG] ...") calls with tflog.Debug(ctx, "...", map[string]any{...}) in multiple data sources.
  • Removed log imports and introduced terraform-plugin-log/tflog imports (where needed) to support structured logging fields.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
github/data_source_github_branch.go Switches “missing branch” debug logging to tflog.Debug with structured fields.
github/data_source_github_actions_registration_token.go Switches “creating repo registration token” debug logging to structured tflog.Debug.
github/data_source_github_actions_organization_registration_token.go Switches “creating org registration token” debug logging to structured tflog.Debug.
Comments suppressed due to low confidence (1)

github/data_source_github_branch.go:11

  • tflog.Debug is used in this file but tflog is not imported, which will cause a compile error. Add the github.com/hashicorp/terraform-plugin-log/tflog import (and keep import ordering/gofmt).
import (
	"context"
	"errors"
	"net/http"

	"github.com/google/go-github/v85/github"
	"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

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

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants