Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit49be7c5

Browse files
committed
feat: Add endpoint to get all workspaces a user can access
This iterates through user organizations to get permittedworkspaces. This will allow admins to manage user workspaces!
1 parent3660483 commit49be7c5

File tree

10 files changed

+177
-280
lines changed

10 files changed

+177
-280
lines changed

‎cmd/templater/main.go

Lines changed: 0 additions & 279 deletions
This file was deleted.

‎coderd/coderd.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ func New(options *Options) (http.Handler, func()) {
258258
})
259259
r.Get("/gitsshkey",api.gitSSHKey)
260260
r.Put("/gitsshkey",api.regenerateGitSSHKey)
261+
r.Get("/workspaces",api.workspacesByOwner)
261262
})
262263
})
263264
})

‎coderd/database/databasefake/databasefake.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,28 @@ func (q *fakeQuerier) GetWorkspacesByOrganizationID(_ context.Context, req datab
478478
returnworkspaces,nil
479479
}
480480

481+
func (q*fakeQuerier)GetWorkspacesByOrganizationIDs(_ context.Context,req database.GetWorkspacesByOrganizationIDsParams) ([]database.Workspace,error) {
482+
q.mutex.RLock()
483+
deferq.mutex.RUnlock()
484+
485+
workspaces:=make([]database.Workspace,0)
486+
for_,workspace:=rangeq.workspaces {
487+
for_,id:=rangereq.Ids {
488+
ifworkspace.ID!=id {
489+
continue
490+
}
491+
ifworkspace.Deleted!=req.Deleted {
492+
continue
493+
}
494+
workspaces=append(workspaces,workspace)
495+
}
496+
}
497+
iflen(workspaces)==0 {
498+
returnnil,sql.ErrNoRows
499+
}
500+
returnworkspaces,nil
501+
}
502+
481503
func (q*fakeQuerier)GetWorkspacesByOwnerID(_ context.Context,req database.GetWorkspacesByOwnerIDParams) ([]database.Workspace,error) {
482504
q.mutex.RLock()
483505
deferq.mutex.RUnlock()

‎coderd/database/querier.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/queries.sql.go

Lines changed: 43 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/queries/workspaces.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ LIMIT
1111
-- name: GetWorkspacesByOrganizationID :many
1212
SELECT*FROM workspacesWHERE organization_id= $1AND deleted= $2;
1313

14+
-- name: GetWorkspacesByOrganizationIDs :many
15+
SELECT*FROM workspacesWHERE organization_id= ANY(@ids :: uuid [ ])AND deleted= @deleted;
16+
1417
-- name: GetWorkspacesByTemplateID :many
1518
SELECT
1619
*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp