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

Commit36451d5

Browse files
committed
feat: add owner groups to workspace data
1 parent426e9f2 commit36451d5

File tree

12 files changed

+266
-127
lines changed

12 files changed

+266
-127
lines changed

‎coderd/database/dbauthz/dbauthz.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,6 +1145,10 @@ func (q *querier) GetGroupsByOrganizationID(ctx context.Context, organizationID
11451145
returnfetchWithPostFilter(q.auth,q.db.GetGroupsByOrganizationID)(ctx,organizationID)
11461146
}
11471147

1148+
func (q*querier)GetGroupsByUserId(ctx context.Context,userID uuid.UUID) ([]database.Group,error) {
1149+
panic("not implemented")
1150+
}
1151+
11481152
func (q*querier)GetHealthSettings(ctx context.Context) (string,error) {
11491153
// No authz checks
11501154
returnq.db.GetHealthSettings(ctx)

‎coderd/database/dbmem/dbmem.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2264,6 +2264,10 @@ func (q *FakeQuerier) GetGroupsByOrganizationID(_ context.Context, id uuid.UUID)
22642264
returngroups,nil
22652265
}
22662266

2267+
func (q*FakeQuerier)GetGroupsByUserId(ctx context.Context,userID uuid.UUID) ([]database.Group,error) {
2268+
panic("not implemented")
2269+
}
2270+
22672271
func (q*FakeQuerier)GetHealthSettings(_ context.Context) (string,error) {
22682272
q.mutex.RLock()
22692273
deferq.mutex.RUnlock()

‎coderd/database/dbmetrics/dbmetrics.go

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

‎coderd/database/dbmock/dbmock.go

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

‎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: 44 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/queries/groupmembers.sql

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,18 @@ WHERE
2323
AND
2424
users.deleted='false';
2525

26+
-- name: GetGroupsByUserId :many
27+
SELECT
28+
groups.*
29+
FROM
30+
groups
31+
LEFT JOIN
32+
group_members
33+
ON
34+
group_members.group_id=groups.id
35+
WHERE
36+
group_members.user_id= @user_id;
37+
2638
-- InsertUserGroupsByName adds a user to all provided groups, if they exist.
2739
-- name: InsertUserGroupsByName :exec
2840
WITH groupsAS (

‎coderd/provisionerdserver/provisionerdserver.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,14 @@ func (s *server) acquireProtoJob(ctx context.Context, job database.ProvisionerJo
467467
iferr!=nil {
468468
returnnil,failJob(fmt.Sprintf("get owner: %s",err))
469469
}
470+
ownerGroups,err:=s.Database.GetGroupsByUserId(ctx,owner.ID)
471+
ownerGroupNames:=make([]string,0,len(ownerGroups))
472+
for_,group:=rangeownerGroups {
473+
ownerGroupNames=append(ownerGroupNames,group.Name)
474+
}
475+
iferr!=nil {
476+
returnnil,failJob(fmt.Sprintf("get owner groups: %s",err))
477+
}
470478
err=s.Pubsub.Publish(codersdk.WorkspaceNotifyChannel(workspace.ID), []byte{})
471479
iferr!=nil {
472480
returnnil,failJob(fmt.Sprintf("publish workspace update: %s",err))
@@ -567,6 +575,7 @@ func (s *server) acquireProtoJob(ctx context.Context, job database.ProvisionerJo
567575
WorkspaceOwner:owner.Username,
568576
WorkspaceOwnerEmail:owner.Email,
569577
WorkspaceOwnerName:owner.Name,
578+
WorkspaceOwnerGroups:ownerGroupNames,
570579
WorkspaceOwnerOidcAccessToken:workspaceOwnerOIDCAccessToken,
571580
WorkspaceId:workspace.ID.String(),
572581
WorkspaceOwnerId:owner.ID.String(),

‎coderd/wsbuilder/wsbuilder.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,32 @@ func (e BuildError) Unwrap() error {
197197
returne.Wrapped
198198
}
199199

200+
typeAdderinterface {
201+
Add()int
202+
}
203+
204+
typemyAdderstruct {
205+
valint
206+
}
207+
208+
func (m*myAdder)Add()int {
209+
returnm.val
210+
}
211+
212+
funcsum(adder []Adder)int {
213+
sum:=0
214+
for_,a:=rangeadder {
215+
sum+=a.Add()
216+
}
217+
returnsum
218+
}
219+
220+
varx=sum([]Adder{&myAdder{
221+
val:2,
222+
},&myAdder{
223+
val:4,
224+
}})
225+
200226
// Build computes and inserts a new workspace build into the database. If authFunc is provided, it also performs
201227
// authorization preflight checks.
202228
func (b*Builder)Build(

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp