Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove org scoped proxies
  • Loading branch information
Emyrk committed Apr 4, 2023
commit a1a31e46724ffb2ca9043a6a95ca7cd9576efe5e
149 changes: 67 additions & 82 deletions coderd/apidoc/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

129 changes: 57 additions & 72 deletions coderd/apidoc/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions coderd/database/dbauthz/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -1685,16 +1685,18 @@ func (q *querier) GetWorkspaceByWorkspaceAppID(ctx context.Context, workspaceApp
return fetch(q.log, q.auth, q.db.GetWorkspaceByWorkspaceAppID)(ctx, workspaceAppID)
}

func (q *querier) GetWorkspaceProxies(ctx context.Context, organizationID uuid.UUID) ([]database.WorkspaceProxy, error) {
return fetchWithPostFilter(q.auth, q.db.GetWorkspaceProxies)(ctx, organizationID)
func (q *querier) GetWorkspaceProxies(ctx context.Context) ([]database.WorkspaceProxy, error) {
return fetchWithPostFilter(q.auth, func(ctx context.Context, _ interface{}) ([]database.WorkspaceProxy, error) {
return q.db.GetWorkspaceProxies(ctx)
})(ctx, nil)
}

func (q *querier) GetWorkspaceProxyByID(ctx context.Context, id uuid.UUID) (database.WorkspaceProxy, error) {
return fetch(q.log, q.auth, q.db.GetWorkspaceProxyByID)(ctx, id)
}

func (q *querier) InsertWorkspaceProxy(ctx context.Context, arg database.InsertWorkspaceProxyParams) (database.WorkspaceProxy, error) {
return insert(q.log, q.auth, rbac.ResourceWorkspaceProxy.InOrg(arg.OrganizationID), q.db.InsertWorkspaceProxy)(ctx, arg)
return insert(q.log, q.auth, rbac.ResourceWorkspaceProxy, q.db.InsertWorkspaceProxy)(ctx, arg)
}

func (q *querier) UpdateWorkspaceProxy(ctx context.Context, arg database.UpdateWorkspaceProxyParams) (database.WorkspaceProxy, error) {
Expand Down
10 changes: 3 additions & 7 deletions coderd/database/dbauthz/querier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -464,13 +464,9 @@ func (s *MethodTestSuite) TestWorkspaceProxy() {
}).Asserts(p, rbac.ActionDelete)
}))
s.Run("GetWorkspaceProxies", s.Subtest(func(db database.Store, check *expects) {
p1 := dbgen.WorkspaceProxy(s.T(), db, database.WorkspaceProxy{
OrganizationID: uuid.New(),
})
p2 := dbgen.WorkspaceProxy(s.T(), db, database.WorkspaceProxy{
OrganizationID: p1.OrganizationID,
})
check.Args(p1.OrganizationID).Asserts(p1, rbac.ActionRead, p2, rbac.ActionRead).Returns(slice.New(p1, p2))
p1 := dbgen.WorkspaceProxy(s.T(), db, database.WorkspacseProxy{})
p2 := dbgen.WorkspaceProxy(s.T(), db, database.WorkspaceProxy{})
check.Args().Asserts(p1, rbac.ActionRead, p2, rbac.ActionRead).Returns(slice.New(p1, p2))
}))
}

Expand Down
9 changes: 3 additions & 6 deletions coderd/database/dbfake/databasefake.go
Original file line number Diff line number Diff line change
Expand Up @@ -4952,15 +4952,13 @@ func (q *fakeQuerier) UpdateWorkspaceAgentStartupLogOverflowByID(_ context.Conte
return sql.ErrNoRows
}

func (q *fakeQuerier) GetWorkspaceProxies(_ context.Context, organizationID uuid.UUID) ([]database.WorkspaceProxy, error) {
func (q *fakeQuerier) GetWorkspaceProxies(_ context.Context) ([]database.WorkspaceProxy, error) {
q.mutex.Lock()
defer q.mutex.Unlock()

cpy := make([]database.WorkspaceProxy, 0, len(q.workspaceProxies))
for _, p := range q.workspaceProxies {
if p.OrganizationID == organizationID && !p.Deleted {
cpy = append(cpy, p)
}
cpy = append(cpy, p)
}
return cpy, nil
}
Expand All @@ -4982,14 +4980,13 @@ func (q *fakeQuerier) InsertWorkspaceProxy(_ context.Context, arg database.Inser
defer q.mutex.Unlock()

for _, p := range q.workspaceProxies {
if !p.Deleted && p.OrganizationID == arg.OrganizationID && p.Name == arg.Name {
if !p.Deleted && p.Name == arg.Name {
return database.WorkspaceProxy{}, errDuplicateKey
}
}

p := database.WorkspaceProxy{
ID: arg.ID,
OrganizationID: arg.OrganizationID,
Name: arg.Name,
Icon: arg.Icon,
Url: arg.Url,
Expand Down
Loading