Skip to content

Commit 337df0c

Browse files
committed
fix(types): fix misleading comments and ownerOpeation typo in OwnerChangeCalculator
- Update dedup loop comments to accurately describe that any existing operation (pending, complete, failed, etc.) suppresses re-queuing, not just waiting or completed ones. - Rename loop variable ownerOpeation → ownerOperation in both add and remove loops for readability. - Fix pendingAdminMembers doc comment: these are users with pending invitations, not org members. Signed-off-by: Onur Yilmaz <onur.yilmaz@sap.com>
1 parent 63e0181 commit 337df0c

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

api/v1/githuborganization_types.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,11 @@ func (g GithubOrganization) OwnerChangeCalculator(ownersFromKubernetes []Member)
226226
if !githubOwnerFound {
227227
// action: add the owner to github
228228

229-
// check if there is a waiting or already-completed task
230-
// A completed add operation means the user was already successfully added; do not re-queue.
229+
// check if there is any existing task (pending, complete, failed, etc.)
230+
// Any existing add operation suppresses re-queuing, regardless of state.
231231
ownerOperationFound := false
232-
for _, ownerOpeation := range newStatus.Operations.OrganizationOwnerOperations {
233-
if strings.EqualFold(ownerOpeation.User, kubernetesOwner.GithubUsername) && ownerOpeation.Operation == GithubUserOperationTypeAdd {
232+
for _, ownerOperation := range newStatus.Operations.OrganizationOwnerOperations {
233+
if strings.EqualFold(ownerOperation.User, kubernetesOwner.GithubUsername) && ownerOperation.Operation == GithubUserOperationTypeAdd {
234234
ownerOperationFound = true
235235
break
236236
}
@@ -265,11 +265,11 @@ func (g GithubOrganization) OwnerChangeCalculator(ownersFromKubernetes []Member)
265265
if !kubernetesOwnerFound {
266266
// action: remove the owner from github
267267

268-
// check if there is a waiting or already-completed task
269-
// A completed remove operation means the user was already successfully removed; do not re-queue.
268+
// check if there is any existing task (pending, complete, failed, etc.)
269+
// Any existing remove operation suppresses re-queuing, regardless of state.
270270
ownerOperationFound := false
271-
for _, ownerOpeation := range newStatus.Operations.OrganizationOwnerOperations {
272-
if strings.EqualFold(ownerOpeation.User, githubOwner.GithubUsername) && ownerOpeation.Operation == GithubUserOperationTypeRemove {
271+
for _, ownerOperation := range newStatus.Operations.OrganizationOwnerOperations {
272+
if strings.EqualFold(ownerOperation.User, githubOwner.GithubUsername) && ownerOperation.Operation == GithubUserOperationTypeRemove {
273273
ownerOperationFound = true
274274
break
275275
}

internal/github/organizations.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func (o *DefaultOrganizationProvider) OwnersExtended(ctx context.Context) ([]Git
122122
return append(active, pending...), nil
123123
}
124124

125-
// pendingAdminMembers returns org members who have a pending invitation with the admin role.
125+
// pendingAdminMembers returns users with pending admin invitations to the org.
126126
// ListMembers only returns active members, so without this, users whose invite is still pending
127127
// are invisible to OwnersExtended and get re-invited on every reconcile.
128128
func (o *DefaultOrganizationProvider) pendingAdminMembers(ctx context.Context) ([]GithubMember, error) {

0 commit comments

Comments
 (0)