Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

PermsSyncer: refactor fetchUserPermsViaExternalAccounts results#44251

Merged
bobheadxi merged 2 commits into
mainfrom
authz-fetch-user-perms-results
Nov 15, 2022
Merged

PermsSyncer: refactor fetchUserPermsViaExternalAccounts results#44251
bobheadxi merged 2 commits into
mainfrom
authz-fetch-user-perms-results

Conversation

@bobheadxi

@bobheadxi bobheadxi commented Nov 10, 2022

Copy link
Copy Markdown
Member

Refactors fetchUserPermsViaExternalAccounts to always return a result type, and collects the multiple return values into this one result type. This does not cause any behaviour changes because the callers check for error first anyway.

I want to eventually have each authz provider report separate states from each job back to PermsSyncer, so this result type will be extended: https://github.com/sourcegraph/sourcegraph/pull/44257

Test plan

Existing tests pass

@bobheadxi bobheadxi requested review from a team November 10, 2022 23:49
@cla-bot cla-bot Bot added the cla-signed label Nov 10, 2022
@sourcegraph-bot

sourcegraph-bot commented Nov 10, 2022

Copy link
Copy Markdown
Contributor

Codenotify: Notifying subscribers in CODENOTIFY files for diff a55b91d...172db6b.

Notify File(s)
@indradhanush enterprise/cmd/repo-updater/internal/authz/perms_syncer.go
@unknwon enterprise/cmd/repo-updater/internal/authz/perms_syncer.go

@bobheadxi

bobheadxi commented Nov 11, 2022

Copy link
Copy Markdown
Member Author

@kopancek kopancek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, but I would maybe go even further and apply the same behavior to repo syncing, see my comment (non-blocking for this PR).

Comment on lines 304 to 307

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also sync permissions based on repositories, see method syncRepoPerms

Should we extend this type to include that as well? E.g. something like:

Suggested change
type fetchUserPermsViaExternalAccountsResults struct {
repoIDs []uint32
subRepoPerms map[api.ExternalRepoSpec]*authz.SubRepoPermissions
}
type PermsResults struct {
repoIDs []uint32
userIDs []uint32
subRepoPerms map[api.ExternalRepoSpec]*authz.SubRepoPermissions
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so - syncRepoPerms intentionally does not return anything because it does not have another aggregation layer the way user perms does

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i.e.

  • User perms: syncUserPerms -> fetchUserPermsViaExternalAccounts -> provider
  • Repo perms: syncRepoPerms -> provider

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

User and repo perms also return very different things, i.e. in user-centric sync we only return repo lists and in repo-centric sync we only return user lists, creating a struct to carry both would just be a mutually exclusive result set

@bobheadxi bobheadxi force-pushed the authz-fetch-user-perms-results branch from 850a68d to 9d688b9 Compare November 14, 2022 18:37
@bobheadxi bobheadxi marked this pull request as ready for review November 14, 2022 18:38
@bobheadxi bobheadxi requested a review from a team November 14, 2022 18:38
Comment thread enterprise/cmd/repo-updater/internal/authz/perms_syncer.go Outdated
@bobheadxi bobheadxi merged commit 9322c58 into main Nov 15, 2022
@bobheadxi bobheadxi deleted the authz-fetch-user-perms-results branch November 15, 2022 17:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants