feat: notify on workspace update (#15979)

Relates to https://github.com/coder/coder/issues/15845

When the `/workspace/<name>/builds` endpoint is hit, we check if the
requested template version is different to the previously used template
version. If these values differ, we can assume that the workspace has
been manually updated and send the appropriate notification. Automatic
updates happen in the lifecycle executor and bypasses this endpoint
entirely.
This commit is contained in:
Danielle Maywood
2025-01-02 12:19:34 +00:00
committed by GitHub
parent 445392bdd8
commit f3fe3bc785
10 changed files with 397 additions and 28 deletions

View File

@ -1048,6 +1048,22 @@ func TestNotificationTemplates_Golden(t *testing.T) {
},
},
},
{
name: "TemplateWorkspaceManuallyUpdated",
id: notifications.TemplateWorkspaceManuallyUpdated,
payload: types.MessagePayload{
UserName: "Bobby",
UserEmail: "bobby@coder.com",
UserUsername: "bobby",
Labels: map[string]string{
"organization": "bobby-organization",
"initiator": "bobby",
"workspace": "bobby-workspace",
"template": "bobby-template",
"version": "alpha",
},
},
},
}
// We must have a test case for every notification_template. This is enforced below: