coder / coder/internal

Add code-generation & linter for system notification templates

Offen
#36 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
project/notifications
Vorherrschende Sprache
Keine Sprachdaten
Sterne
3
Forks
0
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

Ideally this code generation would produced a file called `coderd/notifications/system_templates_generated.go`:

```go
// Workspace Events
var (
TemplateWorkspaceDeleted = uuid.MustParse("f517da0b-cdc9-410f-ab89-a86107c420ed")
...
)

func AllSystemTemplates() []uuid.UUID {
return {
TemplateWorkspaceDeleted,
...
}
}

// GetSystemTemplateByID returns the static contents of the requested system notification template.
func GetSystemTemplateByID(id uuid.UUID) database.NotificationTemplate {
switch id {
case TemplateWorkspaceDeleted:
return database.NotificationTemplate {
id: id,
name: "Workspace Deleted",
...
}
...
}
}
```

_NOTE: this must ONLY consider templates of `kind=system`_.

We need this code-generation to solve a few problems:

1. Tests that currently reference the `notification_templates` table won't need to use a real pg db anymore, speeding up tests
2. `AllSystemTemplates()` will allow us to determine if we're missing any test cases
3. We could generate golden test files to validate that a template produces precisely identical HTML + plaintext outputs for given inputs

Over and above this, we'll need a linter to validate that this new file is not out-of-sync with the database after migrations have run.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

Start by locating the notification_templates table, its migrations, and the existing system-template code. Define how the generator produces coderd/notifications/system_templates_generated.go and how generated golden tests fit the stated goals. Done means system templates only are generated, and a linter detects when the generated file is out of sync after migrations.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
go, postgres
Bereich
backend, databases, tooling
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
30/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.