@@ -4,12 +4,12 @@ import (
44 "context"
55 "errors"
66 "fmt"
7- "log"
87 "net/http"
98 "net/url"
109 "strings"
1110
1211 "github.com/google/go-github/v84/github"
12+ "github.com/hashicorp/terraform-plugin-log/tflog"
1313 "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
1414 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1515)
@@ -83,11 +83,16 @@ func dataSourceGithubRepositoryFileRead(ctx context.Context, d *schema.ResourceD
8383 // split and replace owner and repo
8484 parts := strings .Split (repo , "/" )
8585 if len (parts ) == 2 {
86- log .Printf ("[DEBUG] repo has a slash, extracting owner from: %s" , repo )
86+ tflog .Debug (ctx , "repo has a slash, extracting owner from" , map [string ]any {
87+ "repo" : repo ,
88+ })
8789 owner = parts [0 ]
8890 repo = parts [1 ]
8991
90- log .Printf ("[DEBUG] owner: %s repo:%s" , owner , repo )
92+ tflog .Debug (ctx , "owner and repo" , map [string ]any {
93+ "owner" : owner ,
94+ "repo" : repo ,
95+ })
9196 }
9297
9398 file := d .Get ("file" ).(string )
@@ -102,7 +107,11 @@ func dataSourceGithubRepositoryFileRead(ctx context.Context, d *schema.ResourceD
102107 var ghErr * github.ErrorResponse
103108 if errors .As (err , & ghErr ) {
104109 if ghErr .Response .StatusCode == http .StatusNotFound {
105- log .Printf ("[DEBUG] Missing GitHub repository file %s/%s/%s" , owner , repo , file )
110+ tflog .Debug (ctx , "Missing GitHub repository file" , map [string ]any {
111+ "owner" : owner ,
112+ "repo" : repo ,
113+ "file" : file ,
114+ })
106115 d .SetId ("" )
107116 return nil
108117 }
@@ -145,12 +154,21 @@ func dataSourceGithubRepositoryFileRead(ctx context.Context, d *schema.ResourceD
145154 })
146155 }
147156
148- log .Printf ("[DEBUG] Data Source fetching commit info for repository file: %s/%s/%s" , owner , repo , file )
157+ tflog .Debug (ctx , "Data Source fetching commit info for repository file" , map [string ]any {
158+ "owner" : owner ,
159+ "repo" : repo ,
160+ "file" : file ,
161+ })
149162 commit , err := getFileCommit (ctx , client , owner , repo , file , ref )
150163 if err != nil {
151164 return diag .FromErr (err )
152165 }
153- log .Printf ("[DEBUG] Found file: %s/%s/%s, in commit SHA: %s " , owner , repo , file , commit .GetSHA ())
166+ tflog .Debug (ctx , "Found file, in commit SHA" , map [string ]any {
167+ "owner" : owner ,
168+ "repo" : repo ,
169+ "file" : file ,
170+ "sha" : commit .GetSHA (),
171+ })
154172
155173 if err = d .Set ("commit_sha" , commit .GetSHA ()); err != nil {
156174 return diag .FromErr (err )
0 commit comments