MCPcopy Index your code
hub / github.com/coder/coder / getDebug

Function getDebug

enterprise/tailnet/htmldebug.go:63–92  ·  view source on GitHub ↗
(ctx context.Context, store database.Store)

Source from the content-addressed store, hash-verified

61}
62
63func getDebug(ctx context.Context, store database.Store) (HTMLDebug, error) {
64 out := HTMLDebug{}
65 coords, err := store.GetAllTailnetCoordinators(ctx)
66 if err != nil && !xerrors.Is(err, sql.ErrNoRows) {
67 return HTMLDebug{}, xerrors.Errorf("failed to query coordinators: %w", err)
68 }
69 peers, err := store.GetAllTailnetPeers(ctx)
70 if err != nil && !xerrors.Is(err, sql.ErrNoRows) {
71 return HTMLDebug{}, xerrors.Errorf("failed to query peers: %w", err)
72 }
73 tunnels, err := store.GetAllTailnetTunnels(ctx)
74 if err != nil && !xerrors.Is(err, sql.ErrNoRows) {
75 return HTMLDebug{}, xerrors.Errorf("failed to query tunnels: %w", err)
76 }
77 now := time.Now() // call this once so all our ages are on the same timebase
78 for _, coord := range coords {
79 out.Coordinators = append(out.Coordinators, coordToHTML(coord, now))
80 }
81 for _, peer := range peers {
82 ph, err := peerToHTML(peer, now)
83 if err != nil {
84 return HTMLDebug{}, err
85 }
86 out.Peers = append(out.Peers, ph)
87 }
88 for _, tunnel := range tunnels {
89 out.Tunnels = append(out.Tunnels, tunnelToHTML(tunnel, now))
90 }
91 return out, nil
92}
93
94func coordToHTML(d database.TailnetCoordinator, now time.Time) *HTMLCoordinator {
95 return &HTMLCoordinator{

Callers 2

TestGetDebugFunction · 0.85
ServeHTTPDebugMethod · 0.85

Calls 8

coordToHTMLFunction · 0.85
peerToHTMLFunction · 0.85
tunnelToHTMLFunction · 0.85
GetAllTailnetPeersMethod · 0.65
GetAllTailnetTunnelsMethod · 0.65
IsMethod · 0.45
ErrorfMethod · 0.45

Tested by 1

TestGetDebugFunction · 0.68