Skip to content

Commit e44ca5c

Browse files
committed
feat: add queries for PGCoord HTMLDebug
1 parent 82d5130 commit e44ca5c

File tree

7 files changed

+208
-0
lines changed

7 files changed

+208
-0
lines changed

coderd/database/dbauthz/dbauthz.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,27 @@ func (q *querier) GetAllTailnetClients(ctx context.Context) ([]database.GetAllTa
881881
return q.db.GetAllTailnetClients(ctx)
882882
}
883883

884+
func (q *querier) GetAllTailnetCoordinators(ctx context.Context) ([]database.TailnetCoordinator, error) {
885+
if err := q.authorizeContext(ctx, rbac.ActionRead, rbac.ResourceTailnetCoordinator); err != nil {
886+
return nil, err
887+
}
888+
return q.db.GetAllTailnetCoordinators(ctx)
889+
}
890+
891+
func (q *querier) GetAllTailnetPeers(ctx context.Context) ([]database.TailnetPeer, error) {
892+
if err := q.authorizeContext(ctx, rbac.ActionRead, rbac.ResourceTailnetCoordinator); err != nil {
893+
return nil, err
894+
}
895+
return q.db.GetAllTailnetPeers(ctx)
896+
}
897+
898+
func (q *querier) GetAllTailnetTunnels(ctx context.Context) ([]database.TailnetTunnel, error) {
899+
if err := q.authorizeContext(ctx, rbac.ActionRead, rbac.ResourceTailnetCoordinator); err != nil {
900+
return nil, err
901+
}
902+
return q.db.GetAllTailnetTunnels(ctx)
903+
}
904+
884905
func (q *querier) GetAppSecurityKey(ctx context.Context) (string, error) {
885906
// No authz checks
886907
return q.db.GetAppSecurityKey(ctx)

coderd/database/dbmem/dbmem.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,6 +1276,18 @@ func (*FakeQuerier) GetAllTailnetClients(_ context.Context) ([]database.GetAllTa
12761276
return nil, ErrUnimplemented
12771277
}
12781278

1279+
func (*FakeQuerier) GetAllTailnetCoordinators(context.Context) ([]database.TailnetCoordinator, error) {
1280+
return nil, ErrUnimplemented
1281+
}
1282+
1283+
func (*FakeQuerier) GetAllTailnetPeers(context.Context) ([]database.TailnetPeer, error) {
1284+
return nil, ErrUnimplemented
1285+
}
1286+
1287+
func (*FakeQuerier) GetAllTailnetTunnels(context.Context) ([]database.TailnetTunnel, error) {
1288+
return nil, ErrUnimplemented
1289+
}
1290+
12791291
func (q *FakeQuerier) GetAppSecurityKey(_ context.Context) (string, error) {
12801292
q.mutex.RLock()
12811293
defer q.mutex.RUnlock()

coderd/database/dbmetrics/dbmetrics.go

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

coderd/database/dbmock/dbmock.go

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

coderd/database/querier.go

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

coderd/database/queries.sql.go

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

coderd/database/queries/tailnet.sql

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,3 +199,14 @@ SELECT tailnet_tunnels.src_id as peer_id, tailnet_peers.coordinator_id, tailnet_
199199
FROM tailnet_tunnels
200200
INNER JOIN tailnet_peers ON tailnet_tunnels.src_id = tailnet_peers.id
201201
WHERE tailnet_tunnels.dst_id = $1;
202+
203+
-- For PG Coordinator HTMLDebug
204+
205+
-- name: GetAllTailnetCoordinators :many
206+
SELECT * FROM tailnet_coordinators;
207+
208+
-- name: GetAllTailnetPeers :many
209+
SELECT * FROM tailnet_peers;
210+
211+
-- name: GetAllTailnetTunnels :many
212+
SELECT * FROM tailnet_tunnels;

0 commit comments

Comments
 (0)