maint: migrate data sources to tflog structured logging#3346
Conversation
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
|
👋 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 |
|
Please remove the resolves comment, since it adresses the issue only partly. And "resolves" will close the issue |
|
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 |
There was a problem hiding this comment.
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 withtflog.Debug(ctx, "...", map[string]any{...})in multiple data sources. - Removed
logimports and introducedterraform-plugin-log/tflogimports (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.Debugis used in this file buttflogis not imported, which will cause a compile error. Add thegithub.com/hashicorp/terraform-plugin-log/tflogimport (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"
)
Before the change?
data_source_github_actions_organization_registration_token,data_source_github_actions_registration_token,and
data_source_github_branchused the standardlogpackage withlog.Printf("[DEBUG] ..."),embedding values directly in the message string.
After the change?
Replaced
logimports withgithub.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
Does this introduce a breaking change?
Please see our docs on breaking changes to help!