Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package github

import (
"context"
"log"

"github.com/hashicorp/terraform-plugin-log/tflog"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
Expand All @@ -29,7 +29,9 @@ func dataSourceGithubActionsOrganizationRegistrationTokenRead(ctx context.Contex
client := meta.(*Owner).v3client
owner := meta.(*Owner).name

log.Printf("[DEBUG] Creating a GitHub Actions organization registration token for %s", owner)
tflog.Debug(ctx, "Creating a GitHub Actions organization registration token", map[string]any{
"owner": owner,
})
token, _, err := client.Actions.CreateOrganizationRegistrationToken(ctx, owner)
if err != nil {
return diag.Errorf("error creating a GitHub Actions organization registration token for %s: %v", owner, err)
Expand Down
7 changes: 5 additions & 2 deletions github/data_source_github_actions_registration_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package github
import (
"context"
"fmt"
"log"

"github.com/hashicorp/terraform-plugin-log/tflog"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
Expand Down Expand Up @@ -36,7 +36,10 @@ func dataSourceGithubActionsRegistrationTokenRead(ctx context.Context, d *schema
owner := meta.(*Owner).name
repoName := d.Get("repository").(string)

log.Printf("[DEBUG] Creating a GitHub Actions repository registration token for %s/%s", owner, repoName)
tflog.Debug(ctx, "Creating a GitHub Actions repository registration token", map[string]any{
"owner": owner,
"repository": repoName,
})
token, _, err := client.Actions.CreateRegistrationToken(ctx, owner, repoName)
if err != nil {
return diag.Errorf("error creating a GitHub Actions repository registration token for %s/%s: %v", owner, repoName, err)
Expand Down
8 changes: 6 additions & 2 deletions github/data_source_github_branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package github
import (
"context"
"errors"
"log"
"net/http"

"github.com/google/go-github/v84/github"
"github.com/hashicorp/terraform-plugin-log/tflog"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
Expand Down Expand Up @@ -54,7 +54,11 @@ func dataSourceGithubBranchRead(ctx context.Context, d *schema.ResourceData, met
var ghErr *github.ErrorResponse
if errors.As(err, &ghErr) {
if ghErr.Response.StatusCode == http.StatusNotFound {
log.Printf("[DEBUG] Missing GitHub branch %s/%s (%s)", orgName, repoName, branchRefName)
tflog.Debug(ctx, "Missing GitHub branch", map[string]any{
"owner": orgName,
"repository": repoName,
"branch_ref": branchRefName,
})
d.SetId("")
return nil
}
Expand Down