-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat: add sharing info to /workspaces endpoint #21049
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
geokat
wants to merge
17
commits into
main
Choose a base branch
from
geokat/internal-858-sharing-info-in-workspaces-response
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+837
−92
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
c0ff276
codersdk changes
geokat 7f5e552
hide `shared_with` in workspace response behind experiment
geokat 3bd2ff3
Deserialize user and group ACLs when reading workspaces from DB
geokat 7501cbc
Fetch user and group data from DB
geokat 2c3eb60
Add user and group data to endpoint response
geokat e37af52
Only display member and group data if user has required authorization
geokat 94b256f
Clean up, refactor
geokat 029708b
Add integration tests
geokat 025f6f0
Parallelize user/group fetching
geokat 7cef973
Go back to fetching user and group data with system context
geokat 01c6ad6
make gen
geokat ceef205
Fetch user/group visible info for workspaces ACL actors through works…
geokat ca50988
Fix migration numbering: 402 already exists in main
geokat 2322a26
Add missing OwnerName in ConvertWorkspaceRows
geokat 3777de0
Get rid of SharedWith pointer usage which enabled support for `shared…
geokat 5762ebc
chore: fix test helper function so that it doesn't save nulls for use…
geokat a50b597
refactor: use separate columns in the workspaces_expanded view for th…
geokat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
41 changes: 41 additions & 0 deletions
41
coderd/database/migrations/000403_workspaces_expanded_acl_actor_info.down.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| DROP VIEW workspaces_expanded; | ||
|
|
||
| -- Revert to passing through raw user_acl and group_acl columns. | ||
| CREATE VIEW workspaces_expanded AS | ||
| SELECT workspaces.id, | ||
| workspaces.created_at, | ||
| workspaces.updated_at, | ||
| workspaces.owner_id, | ||
| workspaces.organization_id, | ||
| workspaces.template_id, | ||
| workspaces.deleted, | ||
| workspaces.name, | ||
| workspaces.autostart_schedule, | ||
| workspaces.ttl, | ||
| workspaces.last_used_at, | ||
| workspaces.dormant_at, | ||
| workspaces.deleting_at, | ||
| workspaces.automatic_updates, | ||
| workspaces.favorite, | ||
| workspaces.next_start_at, | ||
| workspaces.group_acl, | ||
| workspaces.user_acl, | ||
| visible_users.avatar_url AS owner_avatar_url, | ||
| visible_users.username AS owner_username, | ||
| visible_users.name AS owner_name, | ||
| organizations.name AS organization_name, | ||
| organizations.display_name AS organization_display_name, | ||
| organizations.icon AS organization_icon, | ||
| organizations.description AS organization_description, | ||
| templates.name AS template_name, | ||
| templates.display_name AS template_display_name, | ||
| templates.icon AS template_icon, | ||
| templates.description AS template_description, | ||
| tasks.id AS task_id | ||
| FROM ((((workspaces | ||
| JOIN visible_users ON ((workspaces.owner_id = visible_users.id))) | ||
| JOIN organizations ON ((workspaces.organization_id = organizations.id))) | ||
| JOIN templates ON ((workspaces.template_id = templates.id))) | ||
| LEFT JOIN tasks ON ((workspaces.id = tasks.workspace_id))); | ||
|
|
||
| COMMENT ON VIEW workspaces_expanded IS 'Joins in the display name information such as username, avatar, and organization name.'; |
65 changes: 65 additions & 0 deletions
65
coderd/database/migrations/000403_workspaces_expanded_acl_actor_info.up.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| DROP VIEW workspaces_expanded; | ||
|
|
||
| -- Expand more by including group_acl_display_info and | ||
| -- user_acl_display_info columns with the actors' name and avatar. | ||
| CREATE VIEW workspaces_expanded AS | ||
| SELECT workspaces.id, | ||
| workspaces.created_at, | ||
| workspaces.updated_at, | ||
| workspaces.owner_id, | ||
| workspaces.organization_id, | ||
| workspaces.template_id, | ||
| workspaces.deleted, | ||
| workspaces.name, | ||
| workspaces.autostart_schedule, | ||
| workspaces.ttl, | ||
| workspaces.last_used_at, | ||
| workspaces.dormant_at, | ||
| workspaces.deleting_at, | ||
| workspaces.automatic_updates, | ||
| workspaces.favorite, | ||
| workspaces.next_start_at, | ||
| workspaces.group_acl, | ||
| workspaces.user_acl, | ||
| visible_users.avatar_url AS owner_avatar_url, | ||
| visible_users.username AS owner_username, | ||
| visible_users.name AS owner_name, | ||
| organizations.name AS organization_name, | ||
| organizations.display_name AS organization_display_name, | ||
| organizations.icon AS organization_icon, | ||
| organizations.description AS organization_description, | ||
| templates.name AS template_name, | ||
| templates.display_name AS template_display_name, | ||
| templates.icon AS template_icon, | ||
| templates.description AS template_description, | ||
| tasks.id AS task_id, | ||
| -- Workspace ACL actors' display info | ||
| COALESCE(( | ||
| SELECT jsonb_object_agg( | ||
| acl.key, | ||
| jsonb_build_object( | ||
| 'name', COALESCE(g.name, ''), | ||
| 'avatar_url', COALESCE(g.avatar_url, '') | ||
| ) | ||
| ) | ||
| FROM jsonb_each(workspaces.group_acl) AS acl | ||
| LEFT JOIN groups g ON g.id = acl.key::uuid | ||
| ), '{}'::jsonb) AS group_acl_display_info, | ||
| COALESCE(( | ||
| SELECT jsonb_object_agg( | ||
| acl.key, | ||
| jsonb_build_object( | ||
| 'name', COALESCE(vu.name, ''), | ||
| 'avatar_url', COALESCE(vu.avatar_url, '') | ||
| ) | ||
| ) | ||
| FROM jsonb_each(workspaces.user_acl) AS acl | ||
| LEFT JOIN visible_users vu ON vu.id = acl.key::uuid | ||
| ), '{}'::jsonb) AS user_acl_display_info | ||
| FROM ((((workspaces | ||
| JOIN visible_users ON ((workspaces.owner_id = visible_users.id))) | ||
| JOIN organizations ON ((workspaces.organization_id = organizations.id))) | ||
| JOIN templates ON ((workspaces.template_id = templates.id))) | ||
| LEFT JOIN tasks ON ((workspaces.id = tasks.workspace_id))); | ||
|
|
||
| COMMENT ON VIEW workspaces_expanded IS 'Joins in the display name information such as username, avatar, and organization name.'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.