MCPcopy Create free account
hub / github.com/PostHog/duckgres / modelDescriptors

Function modelDescriptors

controlplane/admin/models_api.go:62–100  ·  view source on GitHub ↗

modelDescriptors returns the ordered registry of browsable models. Order is the sidebar order. Every persisted configstore model that an operator might want to inspect belongs here; if you add a model in configstore/models.go, add it here too (and assert it in models_api_test.go).

()

Source from the content-addressed store, hash-verified

60 // OrgUserSecret.Ciphertext, DuckLakeConfig.S3SecretKey, the singleton IDs —
61 // are dropped from the API response for free. Never swap this for a raw
62 // map scan: that would leak those columns.
63 newSlice func() any
64 // elem is the element type behind newSlice, used to derive column order.
65 elem reflect.Type
66}
67
68// modelDescriptors returns the ordered registry of typed models. Order is the
69// sidebar order for the curated groups; tables not listed here surface
70// automatically under "Other" via information_schema discovery.
71func modelDescriptors() []modelDescriptor {
72 mk := func(key, label string, group modelGroup, runtime bool, sample any) modelDescriptor {
73 // table name from the model's TableName() via the gorm Tabler contract.
74 table := ""
75 if t, ok := sample.(interface{ TableName() string }); ok {
76 table = t.TableName()
77 }
78 elem := reflect.TypeOf(sample)
79 return modelDescriptor{
80 Key: key,
81 Label: label,
82 Group: group,
83 Table: table,
84 Runtime: runtime,
85 elem: elem,
86 newSlice: func() any {
87 return reflect.New(reflect.SliceOf(elem)).Interface()
88 },
89 }
90 }
91 return []modelDescriptor{
92 mk("orgs", "Orgs", modelGroupTenants, false, configstore.Org{}),
93 mk("org-teams", "Org Teams", modelGroupTenants, false, configstore.OrgTeam{}),
94 mk("org-users", "Org Users", modelGroupTenants, false, configstore.OrgUser{}),
95 mk("org-user-secrets", "Org User Secrets", modelGroupTenants, false, configstore.OrgUserSecret{}),
96 mk("managed-warehouses", "Managed Warehouses", modelGroupTenants, false, configstore.ManagedWarehouse{}),
97
98 mk("cp-instances", "Control Plane Instances", modelGroupRuntime, true, configstore.ControlPlaneInstance{}),
99 mk("worker-records", "Worker Records", modelGroupRuntime, true, configstore.WorkerRecord{}),
100 mk("org-connection-queue", "Org Connection Queue", modelGroupRuntime, true, configstore.OrgConnectionQueueEntry{}),
101 mk("org-connection-leases", "Org Connection Leases", modelGroupRuntime, true, configstore.OrgConnectionLease{}),
102
103 // Admin section after Runtime: operators is a config-schema table

Callers 3

listModelsMethod · 0.85
getModelMethod · 0.85

Calls 1

TableNameMethod · 0.45

Tested by 1