Skip to content

Commit

Permalink
Debugg repo user access
Browse files Browse the repository at this point in the history
  • Loading branch information
iul1an committed Sep 3, 2024
1 parent b58e38f commit 78e2768
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions internal/controller/repository/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ func (c *external) Observe(ctx context.Context, mg resource.Managed) (managed.Ex
}

if !reflect.DeepEqual(util.SortByKey(ghMToPermission), util.SortByKey(crMToPermission)) {
fmt.Println("XXXXXXXXXXXXXXXXXXXXXXXXX")
fmt.Printf("CR collaborators: %v\n", crMToPermission)
fmt.Printf("Repo collaborators: %v\n", ghMToPermission)
fmt.Printf("Differences:\n%v", cmp.Diff(ghMToPermission, crMToPermission))
fmt.Println("XXXXXXXXXXXXXXXXXXXXXXXXX")
return notUpToDate, nil
}

Expand All @@ -173,6 +178,11 @@ func (c *external) Observe(ctx context.Context, mg resource.Managed) (managed.Ex
}

if !reflect.DeepEqual(util.SortByKey(ghTToPermission), util.SortByKey(crTToPermission)) {
fmt.Println("XXXXXXXXXXXXXXXXXXXXXXXXX")
fmt.Printf("CR team collaborators: %v\n", crTToPermission)
fmt.Printf("Repo team collaborators: %v\n", ghTToPermission)
fmt.Printf("Differences:\n%v", cmp.Diff(ghTToPermission, crTToPermission))
fmt.Println("XXXXXXXXXXXXXXXXXXXXXXXXX")
return notUpToDate, nil
}

Expand Down Expand Up @@ -935,6 +945,11 @@ func updateRepoUsers(ctx context.Context, cr *v1alpha1.Repository, gh *ghclient.
}

toDelete, toAdd, toUpdate := util.DiffPermissions(ghUToPermission, crMToPermission)
fmt.Println("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
fmt.Printf("Users toDelete: %v\n", toDelete)
fmt.Printf("Users toAdd: %v\n", toAdd)
fmt.Printf("Users toUpdate: %v\n", toUpdate)
fmt.Println("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")

for userName := range toDelete {
_, err := gh.Repositories.RemoveCollaborator(ctx, cr.Spec.ForProvider.Org, repoName, userName)
Expand Down Expand Up @@ -962,6 +977,11 @@ func updateRepoTeams(ctx context.Context, cr *v1alpha1.Repository, gh *ghclient.
}

toDelete, toAdd, toUpdate := util.DiffPermissions(ghTToPermission, crTToPermission)
fmt.Println("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
fmt.Printf("Teams toDelete: %v\n", toDelete)
fmt.Printf("Teams toAdd: %v\n", toAdd)
fmt.Printf("Teams toUpdate: %v\n", toUpdate)
fmt.Println("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")

for teamSlug := range toDelete {
_, err := gh.Teams.RemoveTeamRepoBySlug(ctx, cr.Spec.ForProvider.Org, teamSlug, cr.Spec.ForProvider.Org, repoName)
Expand Down

0 comments on commit 78e2768

Please sign in to comment.