@@ -117,6 +117,7 @@ func resourceGithubRepositoryCollaborators() *schema.Resource {
117117}
118118
119119func resourceGithubRepositoryCollaboratorsDiff (ctx context.Context , d * schema.ResourceDiff , m any ) error {
120+ tflog .Debug (ctx , "Diffing user collaborators" )
120121 if d .HasChange ("user" ) {
121122 users := d .Get ("user" ).(* schema.Set ).List ()
122123 seen := make (map [string ]any )
@@ -181,6 +182,11 @@ func resourceGithubRepositoryCollaboratorsCreate(ctx context.Context, d *schema.
181182 teams := d .Get ("team" ).(* schema.Set ).List ()
182183 ignoreTeams := d .Get ("ignore_team" ).(* schema.Set ).List ()
183184
185+ tflog .Debug (ctx , "Creating repository collaborators" , map [string ]any {
186+ "users" : users ,
187+ "teams" : teams ,
188+ "ignoreTeams" : ignoreTeams ,
189+ })
184190 inUsers , err := getUserCollaborators (users )
185191 if err != nil {
186192 return diag .FromErr (err )
@@ -226,6 +232,7 @@ func resourceGithubRepositoryCollaboratorsCreate(ctx context.Context, d *schema.
226232}
227233
228234func resourceGithubRepositoryCollaboratorsRead (ctx context.Context , d * schema.ResourceData , m any ) diag.Diagnostics {
235+ tflog .Debug (ctx , "Reading repository collaborators" )
229236 meta , _ := m .(* Owner )
230237 client := meta .v3client
231238 owner := meta .name
@@ -255,10 +262,6 @@ func resourceGithubRepositoryCollaboratorsRead(ctx context.Context, d *schema.Re
255262 return diag .FromErr (err )
256263 }
257264
258- if err := d .Set ("user" , ghUsers .flatten ()); err != nil {
259- return diag .FromErr (err )
260- }
261-
262265 if isOrg {
263266 ghTeams , err := listTeamCollaborators (ctx , client , owner , repoName , inTeams , inIgnoreTeams )
264267 if err != nil {
@@ -280,6 +283,11 @@ func resourceGithubRepositoryCollaboratorsRead(ctx context.Context, d *schema.Re
280283 return diag .FromErr (err )
281284 }
282285
286+ combinedUsersAndInvitations := slices .Concat (ghUsers , ghInvitations )
287+ if err := d .Set ("user" , combinedUsersAndInvitations .flatten ()); err != nil {
288+ return diag .FromErr (err )
289+ }
290+
283291 if err = d .Set ("invitation_ids" , ghInvitations .flattenInvitations ()); err != nil {
284292 return diag .FromErr (err )
285293 }
@@ -288,6 +296,7 @@ func resourceGithubRepositoryCollaboratorsRead(ctx context.Context, d *schema.Re
288296}
289297
290298func resourceGithubRepositoryCollaboratorsUpdate (ctx context.Context , d * schema.ResourceData , m any ) diag.Diagnostics {
299+ tflog .Debug (ctx , "Updating repository collaborators" )
291300 meta , _ := m .(* Owner )
292301 client := meta .v3client
293302 owner := meta .name
@@ -333,6 +342,7 @@ func resourceGithubRepositoryCollaboratorsUpdate(ctx context.Context, d *schema.
333342}
334343
335344func resourceGithubRepositoryCollaboratorsDelete (ctx context.Context , d * schema.ResourceData , m any ) diag.Diagnostics {
345+ tflog .Debug (ctx , "Deleting repository collaborators" )
336346 meta , _ := m .(* Owner )
337347 client := meta .v3client
338348 owner := meta .name
@@ -364,6 +374,7 @@ func resourceGithubRepositoryCollaboratorsDelete(ctx context.Context, d *schema.
364374}
365375
366376func resourceGithubRepositoryCollaboratorsImport (ctx context.Context , d * schema.ResourceData , m any ) ([]* schema.ResourceData , error ) {
377+ tflog .Debug (ctx , "Importing repository collaborators" )
367378 meta := m .(* Owner )
368379 client := meta .v3client
369380 owner := meta .name
@@ -496,7 +507,10 @@ func getTeamIdentity(d any) (teamIdentity, error) {
496507
497508func listUserCollaborators (ctx context.Context , client * github.Client , owner , repoName string ) (userCollaborators , error ) {
498509 col := make ([]userCollaborator , 0 )
499-
510+ tflog .Debug (ctx , "Listing user collaborators" , map [string ]any {
511+ "owner" : owner ,
512+ "repoName" : repoName ,
513+ })
500514 affiliations := []string {"direct" , "outside" }
501515 for _ , affiliation := range affiliations {
502516 opt := & github.ListCollaboratorsOptions {
@@ -633,6 +647,14 @@ func updateUserCollaboratorsAndInvites(ctx context.Context, client *github.Clien
633647 lookup [inUser .login ] = inUser
634648 }
635649
650+ tflog .Debug (ctx , "Updating user collaborators and invitations" , map [string ]any {
651+ "repoName" : repoName ,
652+ "inUsers" : inUsers ,
653+ "lookup" : lookup ,
654+ "seen" : seen ,
655+ "remove" : remove ,
656+ })
657+
636658 ghUsers , err := listUserCollaborators (ctx , client , owner , repoName )
637659 if err != nil {
638660 return nil , err
0 commit comments