mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
refactor: rename Ai* database identifiers to AI* (AIGOV-369) (#26327)
Adds `ai` to sqlc's `gen.go.initialisms` in `coderd/database/sqlc.yaml` so the generated DB code follows Go's initialism convention. Adds the matching `ai` -> `AI` case to the dbgen PascalCase helper (`scripts/dbgen/main.go`) so the corresponding `dbmem` / mock identifiers stay in sync. `make gen` regenerates the rest; hand-written call sites that consume DB-generated identifiers (`enterprise/audit/table.go`, `coderd/database/modelmethods.go`, `enterprise/coderd/aigatewaykeys.go`, `coderd/database/dbauthz/*`, etc.) are updated to match. Scope is deliberately limited to the database layer: - `coderd/rbac/*` (resource and scope generators) is untouched — `ResourceAi*` / `ScopeAi*` constants stay on main's casing. - `codersdk/*` (Go SDK) is untouched — `codersdk.ResourceAi*` / `codersdk.APIKeyScopeAi*` constants stay on main's casing, so external Go SDK consumers see no source-level break. - `Aibridge*` identifiers (one SQL token `aibridge`, not `ai_bridge`) are out of scope. On-the-wire values are unchanged: enum strings, RBAC resource type strings, API key scope strings, and JSON tags all stay the same. The HTTP/JSON surface is unaffected. Refs: [AIGOV-369](https://linear.app/codercom/issue/AIGOV-369/change-ai-references-in-coderddatabasemodelsgo-to-ai) 🤖 Generated with [Coder Agents](https://coder.com)
This commit is contained in:
@@ -84,38 +84,38 @@ type AuditableGroup struct {
|
||||
Members []GroupMemberTable `json:"members"`
|
||||
}
|
||||
|
||||
// AuditableGroupAiBudget is the audit-log representation of GroupAiBudget.
|
||||
// AuditableGroupAIBudget is the audit-log representation of GroupAIBudget.
|
||||
// It enriches the raw record with the group's name and a human-readable
|
||||
// spend limit so audit entries can display meaningful values instead of
|
||||
// UUIDs and micros.
|
||||
type AuditableGroupAiBudget struct {
|
||||
GroupAiBudget
|
||||
type AuditableGroupAIBudget struct {
|
||||
GroupAIBudget
|
||||
GroupName string `json:"group_name"`
|
||||
SpendLimit string `json:"spend_limit"`
|
||||
}
|
||||
|
||||
func (b GroupAiBudget) Auditable(groupName string) AuditableGroupAiBudget {
|
||||
return AuditableGroupAiBudget{
|
||||
GroupAiBudget: b,
|
||||
func (b GroupAIBudget) Auditable(groupName string) AuditableGroupAIBudget {
|
||||
return AuditableGroupAIBudget{
|
||||
GroupAIBudget: b,
|
||||
GroupName: groupName,
|
||||
SpendLimit: fmt.Sprintf("$%.2f", float64(b.SpendLimitMicros)/1_000_000),
|
||||
}
|
||||
}
|
||||
|
||||
// AuditableUserAiBudgetOverride is the audit-log representation of
|
||||
// UserAiBudgetOverride. It enriches the raw record with the username, the
|
||||
// AuditableUserAIBudgetOverride is the audit-log representation of
|
||||
// UserAIBudgetOverride. It enriches the raw record with the username, the
|
||||
// attributed group's name, and a human-readable spend limit so audit
|
||||
// entries can display meaningful values instead of UUIDs and micros.
|
||||
type AuditableUserAiBudgetOverride struct {
|
||||
UserAiBudgetOverride
|
||||
type AuditableUserAIBudgetOverride struct {
|
||||
UserAIBudgetOverride
|
||||
Username string `json:"username"`
|
||||
GroupName string `json:"group_name"`
|
||||
SpendLimit string `json:"spend_limit"`
|
||||
}
|
||||
|
||||
func (o UserAiBudgetOverride) Auditable(username, groupName string) AuditableUserAiBudgetOverride {
|
||||
return AuditableUserAiBudgetOverride{
|
||||
UserAiBudgetOverride: o,
|
||||
func (o UserAIBudgetOverride) Auditable(username, groupName string) AuditableUserAIBudgetOverride {
|
||||
return AuditableUserAIBudgetOverride{
|
||||
UserAIBudgetOverride: o,
|
||||
Username: username,
|
||||
GroupName: groupName,
|
||||
SpendLimit: fmt.Sprintf("$%.2f", float64(o.SpendLimitMicros)/1_000_000),
|
||||
|
||||
Reference in New Issue
Block a user