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

Commit54d65b5

Browse files
committed
remove new query
1 parent11e16ce commit54d65b5

File tree

9 files changed

+31
-94
lines changed

9 files changed

+31
-94
lines changed

‎coderd/database/dbauthz/dbauthz.go

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

1144-
func (q*querier)GetGroupsByUserID(ctx context.Context,userID uuid.UUID) ([]database.Group,error) {
1145-
panic("not implemented")
1146-
}
1147-
11481144
func (q*querier)GetHealthSettings(ctx context.Context) (string,error) {
11491145
// No authz checks
11501146
returnq.db.GetHealthSettings(ctx)

‎coderd/database/dbmem/dbmem.go

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

2257-
func (q*FakeQuerier)GetGroupsByUserID(ctx context.Context,userID uuid.UUID) ([]database.Group,error) {
2258-
panic("not implemented")
2259-
}
2260-
22612257
func (q*FakeQuerier)GetHealthSettings(_ context.Context) (string,error) {
22622258
q.mutex.RLock()
22632259
deferq.mutex.RUnlock()

‎coderd/database/dbmetrics/dbmetrics.go

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

‎coderd/database/querier.go

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

‎coderd/database/queries.sql.go

Lines changed: 2 additions & 46 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: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,6 @@ 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-
3826
-- InsertUserGroupsByName adds a user to all provided groups, if they exist.
3927
-- name: InsertUserGroupsByName :exec
4028
WITH groupsAS (

‎coderd/provisionerdserver/provisionerdserver.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -467,14 +467,23 @@ 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-
}
470+
orgGroups,err:=s.Database.GetGroupsByOrganizationID(ctx,workspace.OrganizationID)
475471
iferr!=nil {
476472
returnnil,failJob(fmt.Sprintf("get owner groups: %s",err))
477473
}
474+
ownerGroupNames:= []string{}
475+
for_,group:=rangeorgGroups {
476+
members,err:=s.Database.GetGroupMembers(ctx,group.ID)
477+
iferr!=nil {
478+
returnnil,failJob(fmt.Sprintf("get group members: %s",err))
479+
}
480+
for_,member:=rangemembers {
481+
ifmember.ID==owner.ID {
482+
ownerGroupNames=append(ownerGroupNames,group.Name)
483+
break
484+
}
485+
}
486+
}
478487
err=s.Pubsub.Publish(codersdk.WorkspaceNotifyChannel(workspace.ID), []byte{})
479488
iferr!=nil {
480489
returnnil,failJob(fmt.Sprintf("publish workspace update: %s",err))

‎provisioner/terraform/provision.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ package terraform
22

33
import (
44
"context"
5+
"encoding/json"
56
"fmt"
67
"os"
78
"strings"
89
"time"
910

1011
"github.com/spf13/afero"
12+
"golang.org/x/xerrors"
1113

1214
"cdr.dev/slog"
1315
"github.com/coder/terraform-provider-coder/provider"
@@ -186,6 +188,11 @@ func provisionEnv(
186188
richParams []*proto.RichParameterValue,externalAuth []*proto.ExternalAuthProvider,
187189
) ([]string,error) {
188190
env:=safeEnviron()
191+
ownerGroups,err:=json.Marshal(metadata.WorkspaceOwnerGroups)
192+
iferr!=nil {
193+
returnnil,xerrors.Errorf("marshal owner groups: %w",err)
194+
}
195+
189196
env=append(env,
190197
"CODER_AGENT_URL="+metadata.GetCoderUrl(),
191198
"CODER_WORKSPACE_TRANSITION="+strings.ToLower(metadata.GetWorkspaceTransition().String()),
@@ -194,6 +201,7 @@ func provisionEnv(
194201
"CODER_WORKSPACE_OWNER_EMAIL="+metadata.GetWorkspaceOwnerEmail(),
195202
"CODER_WORKSPACE_OWNER_NAME="+metadata.GetWorkspaceOwnerName(),
196203
"CODER_WORKSPACE_OWNER_OIDC_ACCESS_TOKEN="+metadata.GetWorkspaceOwnerOidcAccessToken(),
204+
"CODER_WORKSPACE_OWNER_GROUPS="+string(ownerGroups),
197205
"CODER_WORKSPACE_ID="+metadata.GetWorkspaceId(),
198206
"CODER_WORKSPACE_OWNER_ID="+metadata.GetWorkspaceOwnerId(),
199207
"CODER_WORKSPACE_OWNER_SESSION_TOKEN="+metadata.GetWorkspaceOwnerSessionToken(),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp