Open
Description
Ideally this code generation would produced a file called coderd/notifications/system_templates_generated.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:
- Tests that currently reference the
notification_templates
table won't need to use a real pg db anymore, speeding up tests AllSystemTemplates()
will allow us to determine if we're missing any test cases- 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.